// Menu class
function menu(MenuLeft,MenuTop,MenuWidth,MenuBackground,SelBackground,VoceHeight,voce,hlink) {
	this.MenuLeft = MenuLeft;
	this.MenuTop = MenuTop;
	this.MenuWidth = MenuWidth;
	this.MenuBackground = MenuBackground;
	this.SelBackground = SelBackground;
	this.VoceHeight = VoceHeight;
	this.voce = voce;
	this.hlink = hlink;
	this.cursorSupport = cursorSupport;
	this.mostravoce = mostravoce;
	this.mostrasottovoce = mostrasottovoce;
	this.selvoce = selvoce;
	this.crea = crea;
}

function cursorSupport() {
	var browser = navigator.userAgent.toLowerCase();
	var isMicrosoft;
	version = parseFloat(navigator.appVersion);
	
	if (browser.indexOf('msie')) {
		var tmp = navigator.appVersion.split('MSIE');
		version = parseFloat(tmp[1]);
		isMicrosoft = true;
	} else {
		isMicrosoft = false;
	}
	if (isMicrosoft && version >= 6) {
		return true;
	} 
	return false;
}

function crea() {
	var more,tmp,stringa,ref;
	// Menu principale
	document.writeln("<div class=\"boxtitle\" id=\"menutitle\"><img src=\"etnet/imgs/etnetmnu.jpg\" alt=\"etnet menu\"></div>");
	document.writeln("<div id=\"mnubox\" class=\"box\">");
	for (i = 0;i < this.voce.length;i++) {
		tmp = this.voce[i];
		more = (tmp.constructor == Array && tmp.length > 1)?'&raquo;':'';
		stringa = this.voce[i][0];
		ref = this.hlink[i][0];
		if(more) {
			document.writeln("<div id=\"voce"+i+"\" style=\"height:"+this.VoceHeight+"px\" onMouseOver=\"mostravoce("+i+",'visible')\" onMouseOut=\"mostravoce("+i+",'hidden')\">");
		} else {
			document.writeln("<div id=\"voce"+i+"\" class=\"boxitem\" style=\"height:"+this.VoceHeight+"px\" onMouseOver=\"mostravoce("+i+",'visible')\" onMouseOut=\"mostravoce("+i+",'hidden')\" onClick=\"window.location.href='"+ref+"'\">");
		}
		document.writeln("<table cellpadding='0' cellspacing='0' border='0'><tr><td width='98'>");
		document.writeln(""+stringa+"");
		document.writeln("</td><td width=\"2\" align='center'>"+more+"</td></tr></table>");
		document.writeln("</div>");
	}
	document.writeln("</div>");
	
	// Sottomenu
	for (i = 0;i < this.voce.length;i++) {
		var tmp_1 = this.voce[i];
		var TopSottomenu = this.MenuTop + (this.VoceHeight * (i+1.5)) // +this.VoceHeight;

		document.writeln("<div class=\"subbox\" id='voce"+i+"0' style='background:"+this.MenuBackground+";width:"+this.MenuWidth+"px;position:absolute;left:"+((this.MenuWidth + this.MenuLeft) - 2)+"px;top:"+TopSottomenu+";visibility:hidden' onMouseOver=\"mostravoce("+i+",'visible')\" onMouseOut=\"mostravoce("+i+",'hidden')\">");

		for (x = 1;x < tmp_1.length;x ++) {
			tmp = this.voce[i][x];
			if (tmp.constructor == Array && tmp.length > 1) {
				more = '&raquo;';
				stringa = this.voce[i][x][0];
			} else {
				more = '';
				stringa = this.voce[i][x];
				ref = this.hlink[i][x];
			}
			
			if(more) {
				document.writeln("<div id=\"voce"+i.toString()+x.toString()+"\" style=\"height:"+this.VoceHeight+"px\" onMouseOver=\"mostrasottovoce("+i+","+x+",'visible')\" onMouseOut=\"mostrasottovoce("+i+","+x+",'hidden')\">");
			} else {
				document.writeln("<div id=\"voce"+i.toString()+x.toString()+"\" class=\"boxitem\" style=\"height:"+this.VoceHeight+"px\" onMouseOver=\"mostrasottovoce("+i+","+x+",'visible')\" onMouseOut=\"mostrasottovoce("+i+","+x+",'hidden')\" onClick=\"window.location.href='"+ref+"'\">");
			}
			document.writeln("<table cellpadding='2' cellspacing='0' border='0'><tr><td width='98%'>");
			document.writeln(""+stringa+"");
			document.writeln("</td><td width='2%' align='center'><div id=\"fvoce"+i.toString()+x.toString()+"\">"+more+"</td></tr></table>");
			document.writeln("</div>");
		}
		document.writeln("</div>"); 
	} 
	
	// Sotto-sottomenu
	for (i = 0;i < this.voce.length;i++) {
		var tmp_1 = this.voce[i];
		for (x = 1;x < tmp_1.length;x ++) {
			var tmp_2 = this.voce[i][x];
			if (tmp_2.constructor == Array && tmp_2.length > 1) {
				var TopSottomenu = this.MenuTop + (this.VoceHeight * x);
				document.writeln("<div class=\"subbox\" id=\"voce"+i.toString()+x.toString()+"0\" style=\"background:"+this.MenuBackground+";width:"+(this.MenuWidth+50)+"px;position:absolute;left:"+((this.MenuWidth * 2) - 2)+"px;top:"+TopSottomenu+";visibility:hidden\" onMouseOver=\"javascript:mostravoce("+i+",'visible');mostrasottovoce("+i+","+x+",'visible');\" onMouseOut=\"javascript:mostravoce("+i+",'hidden');mostrasottovoce("+i+","+x+",'hidden');\">");
				for (y = 1;y < tmp_2.length;y++) {
					document.writeln("<div id=\"voce"+i.toString()+x.toString()+y.toString()+"\" class=\"menuitem\" style=\"height:"+this.VoceHeight+"px\" onMouseOver=\"selvoce("+i+","+x+","+y+",'visible')\" onMouseOut=\"selvoce("+i+","+x+","+y+",'hidden')\" onClick=\"window.location.href='"+this.hlink[i][x][y]+"'\">");
					document.writeln("<table cellpadding='2' cellspacing='0' border='0'><tr><td>");
					document.writeln(""+this.voce[i][x][y]+"");
					document.writeln("</td></tr></table>");
					document.writeln("</div>");
				}
				document.writeln("</div>"); 
			}
		}
	}
}

function mostravoce(which,state) {
	var v = this.voce[which];
	var elmain,elsotto;

	if (document.all) {
		elmain = document.all['voce'+which+'0'];
		elsotto = document.all['voce'+which];
	} else {
		elmain = document.getElementById('voce'+which+'0');
		elsotto = document.getElementById('voce'+which);
	}
	if (v.constructor == Array && v.length > 1) {
		elmain.style.visibility = state;
		if (this.cursorSupport()) elsotto.style.cursor = 'arrow';
	} else {
		if (this.cursorSupport()) elsotto.style.cursor = 'hand';
	}
	if (state == 'visible') {
		elsotto.style.background = this.SelBackground;
	} else {
		elsotto.style.background = this.MenuBackground;
	}
	window.status = v[0];
}

function mostrasottovoce(whichi,whichx,state) {
	var v = this.voce[whichi][whichx];
	var elmain,elsotto;
	if (document.all) {
		elmain = document.all['voce'+whichi.toString()+whichx.toString()+'0'];
		elsotto = document.all['voce'+whichi.toString()+whichx.toString()];
	} else {
		elmain = document.getElementById('voce'+whichi.toString()+whichx.toString()+'0');
		elsotto = document.getElementById('voce'+whichi.toString()+whichx.toString());
	}
	
	if (v.constructor == Array && v.length > 1) {
		elmain.style.visibility = state;
		if (this.cursorSupport()) elsotto.style.cursor = 'arrow';
	} else {
		if (this.cursorSupport()) elsotto.style.cursor = 'hand';
	}
	if (state == 'visible') {
		elsotto.style.background = this.SelBackground;
	} else {
		elsotto.style.background = this.MenuBackground;
	}
	window.status = v[0];
}

function selvoce(whichi,whichx,whichy,state) {
	var v = this.voce[whichi][whichx][whichy];
	var elmain,elsotto;
	if (document.all) {
		elsotto = document.all['voce'+whichi.toString()+whichx.toString()+whichy.toString()];
	} else {
		elsotto = document.getElementById('voce'+whichi.toString()+whichx.toString()+whichy.toString());
	}
	if (this.cursorSupport()) elsotto.style.cursor = 'hand';
	if (state == 'visible') {
		elsotto.style.background = this.SelBackground;
	} else {
		elsotto.style.background = this.MenuBackground;
	}
	window.status = v[0];
}

// Menu array
var MenuLeft = 10;
var MenuTop = 80;
var MenuWidth = 110;
var MenuBackground = "#FFFFFF";
var SelBackground = "#DDDDDD";
var VoceHeight = 16;
var voce = new Array();
voce[0] = new Array('Home');
voce[1] = new Array('Etcommy','Che cos\'è','Area riservata','Listino prezzi','Ordina');
voce[2] = new Array('Servizi','Hosting','Internet Free');
voce[3] = new Array('Soluzioni ad hoc','Web-design','E-commerce','Restyling grafica');
voce[4] = new Array('Contatti');
var hlink = new Array();
hlink[0] = new Array('index.php?id=1');
hlink[1] = new Array('index.php?id=3','index.php?id=9','index.php?id=22','index.php?id=10','index.php?id=11');
hlink[2] = new Array('index.php?id=2','index.php?id=6','index.php?id=7');
hlink[3] = new Array('index.php?id=4','index.php?id=12','index.php?id=13','index.php?id=14');
hlink[4] = new Array('index.php?id=5');


