//MENU SX 



var stayFolded=false;

var coloreout='#000000';
var coloreover='#FFFFFF';
var coloreout2='#00804E';
var coloreover2='#F0F0F0';
var fondoacceso2='#00804E';
var fondospento2='#F0F0F0';
var coloreVuoto='';
var acceso='url(img/menu_1liv_on.gif)';
var spento='url(img/menu_1liv_off.gif)';

function accendi1(sender){
	sender.style.backgroundImage=acceso;
	sender.style.cursor='hand';
	sender.style.color=coloreover;
}
function spegni1(sender){
	sender.style.backgroundImage=spento;
	sender.style.color=coloreout;
}

function accendi2(sender){
	sender.style.cursor='hand';
	sender.style.backgroundColor=fondoacceso2;
	sender.style.color=coloreover2;
}
function spegni2(sender){
	sender.style.color=coloreout2;
	sender.style.backgroundColor=fondospento2
}


/************************************************************************************
Browsercheck
************************************************************************************/
var ie = (document.all) ? 1:0;
var gk = (document.getElementById) ? 1:0;
var browser=((ie || gk) && parseInt(navigator.appVersion)>=4)
//alert(browser);  

/************************************************************************************
Making cross-browser objects
************************************************************************************/
function makeMenu(obj){
	 	

	this.divObj=(ie) ? document.all[obj]:document.getElementById(obj);
	this.css=(ie) ? document.all[obj].style:document.getElementById(obj).style;
	this.height=(ie) ? eval(obj+'.offsetHeight'):document.getElementById(obj).offsetHeight;
	this.x=(ie)? this.css.pixelLeft:this.divObj.offsetLeft;
	this.y=(ie)? this.css.pixelTop:this.divObj.offsetTop;							
	this.hideIt=b_hideIt;
	this.showIt=b_showIt;
	this.vis=b_vis;
	this.moveIt=b_moveIt;
	
	
	
	return this;
	
}
function b_showIt(){this.css.visibility="visible"}
function b_hideIt(){this.css.visibility="hidden"}
function b_vis(){if(this.css.visibility=="hidden" || this.css.visibility=="hide") return true;}
function b_moveIt(x,y){this.x=x; this.y=y; this.css.left=this.x; this.css.top=this.y;}
/************************************************************************************
Initiating the page. Just add to the arrays here to get more menuitems
and add divs in the page
************************************************************************************/
/*
function a(id) { 
	if (ie) return document.all[id];
	if (gk) return document.document.getElementById(id); 
	return document.layers[id];
}
*/

function init(){

 var currentDiv;
 var divCount= -1;
 
/*  if(document.layers["divCont"] == null){
	return; 
 } */
 
 do {
  divCount++;
  currentDiv= (ie)?document.all["divTop"+divCount]:document.getElementById("divTop"+divCount);
 }while(currentDiv)

if(divCount==0){
return;
}
 

 
 oTop=new Array()
 for(i=0;i<divCount;i++) {
  oTop[i]=new makeMenu('divTop'+i,'divCont');
 }

 oSub=new Array()
 for(i=0;i<divCount;i++){
  oSub[i]=new makeMenu('divSub'+i,'divCont.document.divTop'+i);
 }

 for(i=0;i<oSub.length;i++){ oSub[i].hideIt(); }
 for(i=1;i<oTop.length;i++){ oTop[i].moveIt(0,oTop[i-1].y+oTop[i-1].height); }

num=0;
snum=0;


if(location.href.indexOf("?")!=-1){
	params=location.href.split("?")[1];
	if(params.indexOf("_")!=-1){
	var zero = params.split("_")[0];
	var uno = params.split("_")[1];
if(isNumeric(zero) && isNumeric(uno)){
			num=params.split("_")[0];
			snum=params.split("_")[1];
		}
	}
}

 menu(num, snum);
 
}
 
 
function isNumeric(strString) {
	var validChars = "0123456789";
	var chr;		
	for (i = 0; i < strString.length; i++) {
	 	chr = strString.charAt(i);
		if (validChars.indexOf(chr) == -1)
		return false;
	 	}	
 return true;
}


/************************************************************************************
This is the function that changes the sub menus to folded or unfolded state.
************************************************************************************/

function menu(num,snum){
	if(browser){
		if((!stayFolded)||(snum=0)){
			for(i=0;i<oSub.length-1;i++){
			  if (ie) {
			  	document.all['f_'+i].style.backgroundImage=spento;				  
			  }
			  else{
			   document.getElementById('f_'+i).style.backgroundImage=spento;				 
			  }			 		          							
				if(i!=num){
					oSub[i].hideIt();														
				}
			}
		}
		
		if(oSub[num].vis()){			
			oSub[num].showIt();
			if  (snum==0) {	
				if (ie) {
					document.all['f_'+num].style.backgroundImage=acceso;
					document.all['f_'+num].style.color=coloreover;
					document.all['f_'+num].onmouseout="return false";	  
				}
				else{
					document.getElementById('f_'+num).style.backgroundImage=acceso;
					document.getElementById('f_'+num).style.color=coloreover;
					document.getElementById('f_'+num).onmouseout="return false";
				}
			}			          							
	
			if(snum!=0){
				if (ie) {
					document.all['s_'+num+'_'+snum].style.color=coloreover2;
					document.all['s_'+num+'_'+snum].style.backgroundColor=fondoacceso2;
					document.all['s_'+num+'_'+snum].onmouseout="return false";
					document.all['f_'+num].style.backgroundImage=spento;
					document.all['f_'+num].style.color=coloreout;						  
				}
				else{
					document.getElementById('s_'+num+'_'+snum).style.color=coloreover2;
					document.getElementById('s_'+num+'_'+snum).style.backgroundColor=fondoacceso2;
					document.getElementById('s_'+num+'_'+snum).onmouseout="return false";
					document.getElementById('f_'+num).style.backgroundImage=spento;
					document.getElementById('f_'+num).style.color=coloreout;						
				}	          							
			}										
		}else{
			oSub[num].hideIt();
		  if (ie) {
		  	document.all['f_'+num].style.backgroundImage=spento;			  
		  }
		  else{
		   document.getElementById('f_'+num).style.backgroundImage=spento;
		  }		          							

		}
		for(i=1;i<oTop.length;i++){ 
			if(!oSub[i-1].vis()){
				oTop[i].moveIt(0,oTop[i-1].y+oTop[i-1].height+oSub[i-1].height);
			}			
			else{
				oTop[i].moveIt(0,oTop[i-1].y+oTop[i-1].height);
			}
		}
	}
}
//Initiating the menus onload, if it's a 4.x+ browser.
//if(browser) onload=init;


