/*LIBRERIA CREAZIONE MENU' MEDIA WWW.WIND.IT*/

var blBrowser=false;

/*Riconoscimento Browser + Reference del Layer in base al Browser
Opera è identificato come isIE5 oppure isNS6*/
isNS4=false;isIE5=false;isIE4=false;isNS6=false;
if(document.layers){								//Netscape 4.x
	isNS4=true;
	blBrowser=true;
	LayerRef	= "document.layers[";
	LayerStyle	= "]";
	LayerTop	= ".top";
	LayerLeft	= ".left";
}else if(document.all && !document.getElementById){	//Explorer 4.x
	isIE4=true;
	blBrowser=true;
	LayerRef	= "document.all[";
	LayerStyle	= "]";
	LayerTop	= ".pixelTop";
	LayerLeft	= ".pixelLeft";
}else if(document.all && document.getElementById){	//Explorer 5.x
	isIE5=true;
	blBrowser=true;
	LayerRef	= "document.getElementById(";
	LayerStyle	= ").style";
	LayerTop	= ".pixelTop";
	LayerLeft	= ".pixelLeft";
}else if(!document.all && document.getElementById){	//Netscape 6.x
	isNS6=true;
	blBrowser=true;
	LayerRef	= "document.getElementById(";
	LayerStyle	= ").style";
	LayerTop	= ".top";
	LayerLeft	= ".left";
}

/*Set Tipo apertura-chiusura delle cartelle
false=Apro una chiudo le altre
true =Apro una e le altre rimangono aperte*/
var stayFolded=false;

/*Numero Totale Layer-Menu nella sezione*/
var nTotLayerMenu = 6;

/*Altezza complessiva del Menù*/
var nTotLayerHeight=0;

/*Crea gli oggetti TopMenu e SubMenu*/
function init(){
	oTop=new Array();	//Intestazioni Menù
	oSub=new Array();	//Contenuti Menù
	for(x=0;x<nTotLayerMenu;x++){
		eval("oTop["+x+"]=new makeMenu('divTop"+Number(x+1)+"','divCont')");
		eval("oSub["+x+"]=new makeMenu('divSub"+Number(x+1)+"','divCont.document.divTop"+Number(x+1)+"')");
	}
	for(i=0;i<oSub.length;i++){oSub[i].hideIt();}
	nTotLayerHeight=0;
	for(i=1;i<oTop.length;i++){
		oTop[i].moveIt(0,Number(oTop[i-1].y+oTop[i-1].height));
		nTotLayerHeight=nTotLayerHeight+Number(oTop[i-1].y+oTop[i-1].height);
	}
	if(menuInd>-1){MakeActive(menuInd,voceInd);}
}


/*Apre il menu relativo all'area selezionata*/
function MakeActive(num,ind){
	menu(num);
}

/*Crea la classe, le proprietà e le funzioni
del layer relative ad ogni browser*/
function makeMenu(obj,nest){;
	nest=(!nest) ? '':'document.'+nest+'.'
	if(isNS4){
		this.css	= eval(nest+'document.'+obj);
		this.ref	= eval(nest+'document.'+obj+'.document');
		this.height	= this.ref.height;
	}

	if(isIE5||isIE4){
		this.css	= eval('document.all.'+obj+'.style');
		this.ref	= eval('document');
		this.height	= eval(obj+'.offsetHeight');
	}

	if(isNS6){
		this.css	= eval('document.getElementById("'+obj+'").style');
		this.ref	= eval('document');
		this.height	= eval('document.getElementById("'+obj+'").offsetHeight');
	}
	this.x		=	eval("this.css"+LayerLeft);
	this.y		=	eval("this.css"+LayerTop);
	this.hideIt	=	b_hideIt;	
	this.showIt	=	b_showIt; 
	this.vis	=	b_vis;
	this.moveIt	=	b_moveIt
	this.css.visibility="visible";
	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;}


/*Espande e Collassa il menu*/
function menu(num){
	if(blBrowser){
		if(!stayFolded){
			for(i=0;i<oSub.length;i++){
				if(i!=num){oSub[i].hideIt()}
			}
			for(i=1;i<oTop.length;i++){
				oTop[i].moveIt(0,Number(oTop[i-1].y+oTop[i-1].height));
			}
		}
		if(oSub[num].vis()){oSub[num].showIt()}
		else{oSub[num].hideIt()}

		nTotLayerHeight=0;
		for(i=1;i<oTop.length;i++){ 
			if(!oSub[i-1].vis()){
				nTotLayerHeight=nTotLayerHeight+Number(Number(oTop[i-1].y+oTop[i-1].height)+oSub[i-1].height);
				oTop[i].moveIt(0,Number(Number(oTop[i-1].y+oTop[i-1].height)+oSub[i-1].height));
			}else{
				nTotLayerHeight=nTotLayerHeight+Number(oTop[i-1].y+oTop[i-1].height);
				oTop[i].moveIt(0,Number(oTop[i-1].y+oTop[i-1].height));
			}			
		}
	}
}

/*Esegue Init dello script se il tipo di browser è supportato*/
if(blBrowser){onload=init;}

var lastHelp=0;
/*Mostra il box di HELP relativo al selezionato*/
function showLayerNumber(number){

	if(lastHelp!=0){
		eval(LayerRef+'"'+eval('"HELPMENU' + lastHelp+'"')+'"'+LayerStyle+'.visibility="hidden"');
	}
	eval(LayerRef+'"'+eval('"HELPMENU' + number+'"')+'"'+LayerStyle+'.visibility="visible"');
	lastHelp=number;
}

/*Nasconde il box di HELP relativo al selezionato*/
function hideLayerNumber(number){
	for(nk=1;nk<nTotLayerMenu;nk++){
		eval(LayerRef+'"'+eval('"HELPMENU' + nk+'"')+'"'+LayerStyle+'.visibility="hidden"');
	}
}

