function gEBID(id_elemento) {
	var elemento; // elemento da restituire
	
	if(document.getElementById) {
		elemento = document.getElementById(id_elemento); // IE > 5
	} else {
		elemento = document.all[id_elemento]; // IE < 5
	}
	
	return elemento;
}

function img_swap(prodID, newImage) {
	loading('loading', 'on');
	swappa(prodID, newImage);
	gEBID(prodID).onload = function() { loading('loading', 'off'); }
}

function loading(itemID,status) {
	if (status == "on") {
		gEBID(itemID).style.visibility = "visible";
		gEBID(itemID).innerHTML = '<img src="../images/indicator_medium.gif" alt="Loading..." />';
	} else {
		gEBID(itemID).style.visibility = 'hidden';
		gEBID(itemID).innerHTML = '';
	}
}

function swappa(itemID, newItem) {
	gEBID(itemID).src = newItem;
}

function imgPreload() {
	var d=document;
	if(d.images){
		if(!d.SA_p) d.SA_p=new Array();
    	var i;
    	var j=d.SA_p.length;
    	var a=imgPreload.arguments;
    	for(i=0; i<a.length; i++) {
    		if (a[i].indexOf("#")!=0){
    			d.SA_p[j]=new Image;
    			d.SA_p[j++].src=a[i];
    		}
    	}
    }
}

function privacyPop(theURL) {
  window.open(theURL,'privacy','width=550,height=400,scrollbars=yes,resizable=yes,status=yes');
}

function zoom(theURL) { //v2.0
  window.open(theURL,'zoom','width=200,height=200,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes');
}

function zoomSized(theURL,w,h) { //v2.0
  window.open(theURL,'zoom','width='+w+',height='+h+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes');
}

function popUp(theURL, sizeX, sizeY, winName) { //v2.0
	if (sizeX <= 0) { sizeX = 500; }
	if (sizeY <= 0) {sizeY = 350; }
	if (winName == "") { winName = "zoom"; }
	var options = "width=" + sizeX + ",height=" + sizeY + ",statusBar=yes,scrollbars=yes,resizable=yes";
	window.open(theURL,winName,options);
}


function MM_findObj(n, d) {
	var p,i,x;
	if(!d) d=document;
	if((p = n.indexOf("?")) > 0 && parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document;
		n = n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) x=d.all[n];
	for (i=0; !x && i < d.forms.length; i++) x=d.forms[i][n];
	for(i=0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
	if(!x && d.getElementById) x = d.getElementById(n);
	return x;
}

function isOn(nr) {
	if (gEBID(nr).style.display == 'block') {
		return true;
	} else {
		return false;
	}
}

function displayOff(nr){
	if (isOn(nr)) { gEBID(nr).style.display = 'none'; }
}
function displayOn(nr){
	gEBID(nr).style.display = 'block';
}

function add2cart(item) {
	theUrl = "basket.php?basket=" + item;
	popUp(theUrl, 700, 420, 'basket');
}