var popup="";
var NS = (document.layers) ? 1 : 0;
var IE = (document.all) ? 1: 0;
var styleSwitch;

if (NS)		{
	styleSwitch="";
}else	{
	styleSwitch=".style";
}

function apriNEW(u,w,h,scr)
{
  popup=window.open(u,"popup","resizable=no,scrollbars="+scr+",height="+h+",width="+w+",location=no,menubar=no,screenX=50,screenY=50,status=no,toolbar=no"); 
  popup.focus();
}

function apriZOOM(url,width,height)
{ 
 if (popup!="")
 {
 popup.close();
 } 
  popup=window.open(url,"popup","resizable=no,scrollbars=no,height="+height+",width="+width+",location=no,menubar=no,screenX=10,screenY=10,status=no,toolbar=no"); 
  popup.document.write('<html>\n<head>\n<title>Dettaglio</title>\n</head>\n<body topmargin=0 leftmargin=0 bgcolor="#ffffff" text="#000000" link="#000000" vlink="#000000" alink="#000000" onload="preloadImages()">\n<a href="javascript:close()"><img src="'+url+'" border="0" alt=""></a><br>\n</body>\n</html>\n');
  popup.focus();
}


function scriviMenu(divid, menuid, liv2) {
	d=document.getElementById(divid);
    var s="";	
    var menu=sottomenu[menuid-1];
    for(i=0; i<menu.length; ++i) {
        var link= menu[i][0];
        var label= menu[i][1];
        var evidenzia=false;
        if ((liv2-1) == i){
         evidenzia=true;
        }
        s= s+ creaVoceSottomenu(link, label, evidenzia);
    }
	d.innerHTML= s;

}
function evidenziaMenu(liv1,liv2){
  
   	if (liv1!=0) {
	    scriviMenu("menu_div",liv1, liv2);
       	livello1=document.getElementById('liv_1_' + liv1);
    	setActiveLevel('liv_1_' + liv1);
    	livello1.className = 'livello2_on';
   	}
 }

function doublequote(s) {
   return '"' + s + '"' ;
} 


function creaVoceSottomenu(link, label, evidenzia) {
   var onMousOverAction=" OnMouseOver=\"this.className = 'livello3_on'\"";
   var onMousOutAction=" OnMouseOut=\"this.className = 'livello3'\"";
   var fontClass="livello3";
   var onClickAction="";
   var styleCursor="";
   if (evidenzia){
    onMousOverAction=" ";
    onMousOutAction=" ";
    fontClass="livello3_on";
    onClickAction= "onClick=\"return true;\"";
    styleCursor=" style=\"cursor:hand\"";
   }

	s= '<a href="' + link + '" ' + onClickAction + 
	    'class=' + doublequote(fontClass) + onMousOverAction + onMousOutAction + styleCursor + '>' +
		'&nbsp;' +
		'<img src=\"' + base_tmpl + 'images2/separ_point.gif\" width=\"8\" height=\"8\" alt=\"\" border=\"0\">' +
		'&nbsp;' +
		label +
		'<img src=\"' + base_tmpl+ 'images2/space.gif\" width=\"10\" height=\"1\" alt=\"\" border=\"0\">' +
		'</a>'
		;
	return s;
}

var activeLevelId="";

function setActiveLevel(id) {
    activeLevelId= id;
}

function setStyle(element, style) {
    if(element.id!=activeLevelId) {
       element.className= style;
       element.style.cursor='hand'
    } else {
       element.style.cursor='hand'// se metto 'default' diventa a forma di freccia!
    }
}

function canClick(levelId) {
    return (levelId!=activeLevelId);
}