var stayFolded=false
var exImg=new Image(); exImg.src='widgets/frgiu.gif' //Voce selezionata
var unImg=new Image(); unImg.src='widgets/frsx.gif' //Voce non selezionata


if (document.getElementById)
{
	var browser=1;
}
else{
	var n = (document.layers) ? 1:0;
	var ie = (document.all) ? 1:0;
	var browser=((n || ie) && parseInt(navigator.appVersion)>=4)  
}

/*
	var n = (document.layers) ? 1:0;
	var ie = (document.all) ? 1:0;
	var browser=((n || ie) && parseInt(navigator.appVersion)>=4)  
*/

function makeMenu(obj,nest){
	if (document.getElementById)
	{
		//alert(document.getElementById(obj).offsetLeft);
		this.css=document.getElementById(obj).style;
		this.ref=eval('document');		
		this.height=document.getElementById(obj).offsetHeight;
		this.x=document.getElementById(obj).offsetLeft;
		this.y=document.getElementById(obj).offsetTop;							
		this.hideIt=b_hideIt;	
		this.showIt=b_showIt; 
		this.vis=b_vis; 
		this.moveIt=b_moveIt											
		return this
		
	}
	else{
		nest=(!nest) ? '':'document.'+nest+'.'										
		this.css=(n) ? eval(nest+'document.'+obj):eval('document.all.'+obj+'.style')					
		this.ref=(n) ? eval(nest+'document.'+obj+'.document'):eval('document');		
		this.height=n?this.ref.height:eval(obj+'.offsetHeight')
		this.x=(n)? this.css.left:this.css.pixelLeft;this.y=(n)? this.css.top:this.css.pixelTop;							
		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}

function init(){
	oTop=new Array()
	oTop[0]=new makeMenu('divazienda','divMenu')
	oTop[1]=new makeMenu('divnews','divMenu')
	oTop[2]=new makeMenu('divfocus','divMenu')
	oTop[3]=new makeMenu('diveventi','divMenu')
	oTop[4]=new makeMenu('divprodotti','divMenu')
	//oTop[4]=new makeMenu('divVirtualDealer','divMenu')
	oTop[5]=new makeMenu('divbrevetti','divMenu')
	oTop[6]=new makeMenu('divcommerciale','divMenu')
	oTop[7]=new makeMenu('divlistini','divMenu')
	//oTop[8]=new makeMenu('divcontattaci','divMenu')

	oSub=new Array()
	oSub[0]=new makeMenu('divSubazienda','divMenu.document.divazienda')
	oSub[1]=new makeMenu('divSubnews','divMenu.document.divnews')
	oSub[2]=new makeMenu('divSubfocus','divMenu.document.divfocus')	
	oSub[3]=new makeMenu('divSubeventi','divMenu.document.diveventi')
	oSub[4]=new makeMenu('divSubprodotti','divMenu.document.divprodotti')

	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) }
}


function menu(num){
	if(browser){
		if(!stayFolded){
			for(i=0;i<oSub.length;i++){
				if(i!=num){
					oSub[i].hideIt()
					//oTop[i].ref["imgA"+i].src=unImg.src
				}
			}
			for(i=1;i<oTop.length;i++){
				oTop[i].moveIt(0,oTop[i-1].y+oTop[i-1].height)
			}
		}
		if(oSub[num].vis()){
			oSub[num].showIt()
			//oTop[num].ref["imgA"+num].src=exImg.src
		}else{
			oSub[num].hideIt()
			//oTop[num].ref["imgA"+num].src=unImg.src
		}
		for(i=1;i<oTop.length;i++){
			if ((i-1)<oSub.length){
				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)
			}
			else{	
				oTop[i].moveIt(0,oTop[i-1].y+oTop[i-1].height)
			}
		}
	}
}
//if(browser) onload=init;
var name1='';
var sezione='';
var vecchioMenu='';

function setOnName(name,strmenu,nMenu,language){
	name1=name;
	//eval("menu("+nMenu+")");
	eval("setMenu('"+strmenu+"','"+nMenu+"','"+language+"')");
	if (document.getElementById){eval("document."+name+".src='widgets/menu_punto_1.gif'");}
	else{
		if (document.all){eval("document."+name+".src='widgets/menu_punto_1.gif'");}
		if (document.layers){eval("document.layers['divMenu'].document.layers['div"+strmenu+"'].document.layers['divSub"+strmenu+"'].document.images['"+name+"'].src='widgets/menu_punto_1.gif'");}
	}
	
}

function OnMenu(name,nMenu){
	if (document.getElementById){eval("document."+name+".src='widgets/menu_punto_1.gif'");}
	else{
		if (document.all){eval("document."+name+".src='widgets/menu_punto_1.gif'");}
		if (document.layers){eval("document.layers['divMenu'].document.layers['div"+nMenu+"'].document.layers['divSub"+nMenu+"'].document.images['"+name+"'].src='widgets/menu_punto_1.gif'");}
	}
}

function OffMenu(name,nMenu){
  if(name1!=name){
	if (document.getElementById){eval("document."+name+".src='widgets/menu_punto.gif'");}
	else{
		if (document.all){eval("document."+name+".src='widgets/menu_punto.gif'");}
		if (document.layers){eval("document.layers['divMenu'].document.layers['div"+nMenu+"'].document.layers['divSub"+nMenu+"'].document.images['"+name+"'].src='widgets/menu_punto.gif'");}
		}
  }
}

function setMenu(name,nMenu,language){
	if (vecchioMenu!=''){
		eval("menu("+vecchioMenu+")");
	}
	if (sezione!=''){	
		if (document.getElementById){eval("document."+sezione+".src='widgets/"+language+"/int_"+sezione+".gif'");}
		else{
			if (document.all){eval("document."+sezione+".src='widgets/"+language+"/int_"+sezione+"_1.gif'");}
			if (document.layers){eval("document.layers['divMenu'].document.layers['div"+sezione+"'].document.images['"+sezione+"'].src='widgets/"+language+"/int_"+sezione+".gif'");}
		}
	}
	if (vecchioMenu!=nMenu){
		eval("menu("+nMenu+")");
	}
	vecchioMenu=nMenu;
	if (sezione!=name){
		if (document.getElementById){eval("document."+name+".src='widgets/"+language+"/int_"+name+"_1.gif'");}
		else{
			if (document.all){eval("document."+name+".src='widgets/"+language+"/int_"+name+"_1.gif'");}
			if (document.layers){eval("document.layers['divMenu'].document.layers['div"+name+"'].document.images['"+name+"'].src='widgets/"+language+"/int_"+name+"_1.gif'");}
		}
	}
	sezione=name;
}

function setMenuNoSub(name, language){
	init();
	if ( sezione != ""){
		if (sezione!=name){
			if (document.getElementById){eval("document."+sezione+".src='widgets/"+language+"/int_"+sezione+".gif'");}
			else{
				if (document.all){eval("document."+sezione+".src='widgets/"+language+"/int_"+sezione+"_1.gif'");}
				if (document.layers){eval("document.layers['divMenu'].document.layers['div"+sezione+"'].document.images['"+sezione+"'].src='widgets/"+language+"/int_"+sezione+".gif'");}
			}
		}
	}
	
	if (document.getElementById){eval("document."+name+".src='widgets/"+language+"/int_"+name+"_1.gif'");}
	else{
		if (document.all){eval("document."+name+".src='widgets/"+language+"/int_"+name+"_1.gif'");}
		if (document.layers){eval("document.layers['divMenu'].document.layers['div"+name+"'].document.images['"+name+"'].src='widgets/"+language+"/int_"+name+"_1.gif'");}
	}
	sezione=name;
}
