function getObj(obj) {
	
	if (document.all && !document.getElementById) {
		//alert("Internet Explorer 4");
		// Internet Explorer 4
		return document.all(obj);
	}
	if (document.all && document.getElementById) {
		//alert("Internet Explorer 5");
		// Internet Explorer 5
		return document.getElementById(obj);
	}
	if (document.layers) {
		//alert("Netscape 4");
		// Netscape 4
		return document.layers(obj);
	}
	if (!document.all && document.getElementById) {
		//alert("Netscape 6");
		// Netscape 6
		return document.getElementById(obj);
	}
	

}

function sendForm() {
	document.forms[0].submit();
}

function redirect(url,target) {
	if(target == null || target=="")
		window.location = url;
	else
		eval(target).window.location = url;
}

function isEmail(str) {
   return (	str.length > 0 &&
		   	str.indexOf(".") > 2 && 
			str.lastIndexOf(".") > str.indexOf("@") && 
			str.indexOf("@") > 0);
}

function doPrint() {
	window.print();
}

var last_v_img = "img_row_0";

function setImage(path,img_obj,row_obj) {
	if(window.last_v_img != "") 
		getObj(last_v_img).className = "img_not_selected";
	

	getObj(row_obj).className = "img_selected";
	
	document.images[img_obj].src = path;
	
	last_v_img = row_obj;
}

function askDelete(link_redirect) {
	if(confirm("Eliminare definitivamente?"))
		redirect(link_redirect);
}

function highlightItem(id,img) {

	if(document.getElementById(id))
		document.getElementById(id).src = 'images/'+img;
}

function openDetail(id,classe) {
	return openURL('product_detail.php?id='+id+'&class='+classe,'','width=627,height=664,scrollbars=yes,resizable=no');	
}

function openURL(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function display(f) {
	if(getObj(f).style.display == "none")
		getObj(f).style.display = "block";
	else
		getObj(f).style.display = "none";
}
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
