// getElById restituisce il riferimento all'elemento corrispondente all'id cercato
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,scrollbars=no,resizable=yes');
}

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;
}