//Popup handling
function popup(path, width, height) {
	width=(!width) ? 600 : width;
	height=(!height) ? 460 : height;	
	var left = (screen.availWidth/2) - (width/2);
	var top = (screen.availHeight/3)+100 - (height/2);
	ht=document.getElementsByTagName("body");
	//ht[0].style.filter="Alpha(opacity=60);";
	var finestra=window.open(path,'popupX','toolbar=no,button=no,scrollbars=yes,resizable=yes,width='+width+',height='+height+', left='+left+', top='+top+'');
	finestra.focus();
}

//Layers handling
function __hideDiv(layer_name) 
{ 
	if (document.getElementById) {
		document.getElementById(layer_name).style.visibility = "hidden"; 
		document.getElementById(layer_name).style.display = "none";
	}
} 
function __showDiv(layer_name) 
{
	if (document.getElementById) {
		document.getElementById(layer_name).style.visibility = "visible"; 
		document.getElementById(layer_name).style.display = "block";
	}
}
function handleLayer(arg) 
{
    if (arg) 
	{
		if (document.getElementById) {
			if (document.getElementById(arg).style.display=="none") {            
			    __showDiv(arg);
			} else {
			    __hideDiv(arg);			
			}
		}
    }
}

// Funzione che apre un div e chiude tutti gli altri //
function THISonTHAToff(code) {

    ff = document.getElementsByTagName("div");
    for (i = 0; i < ff.length; i++) {
        if (ff[i].id.substr(0,5)=="onOff") {
            ff[i].style.display = "none";
        }
    }   
    for (i = 0; i < ff.length; i++) {
        if (ff[i].id == code) {
            if (ff[i].style.display == "none") {
                ff[i].style.display = "";
            }
        }
    }
}

// Funzione che apre e chiude un div cliccando sul link //
function THISonTHISoff(code) {
    var x = code.split("_");
    x = x[0];
    ff = document.getElementsByTagName(x);
    for (i = 0; i < ff.length; i++) {
        if (ff[i].id == code) {
            if (ff[i].style.display == "") {
                ff[i].style.display = "none";
            } else
            if (ff[i].style.display == "none") {
                ff[i].style.display = "";
            }
        }
    }
}