/* GLOBAL VARIABLES */
var popactivein = null;
var popactiveout = null;
var flaglink = false;
if (net4){document.captureEvents(Event.MOUSEDOWN)}
document.onmousedown = mouseverifydown;	

/* CONSTRUCTOR */

 function constlayer() {
 this.menustart = menustart;
 this.additem = additem;
 this.menuend = menuend;
 this.addspacer = addspacer;
 this.visualizza = visualizza;
 this.nascondi = nascondi;
}

/* FUNCTIONS */

function additem(name1, name2, linkto, col) {
 
 if (net4){
 htmlcenter = "<tr><td><ilayer><layer width=160 onmouseover='setflag(); colortab(this)' onmouseout='setflag(); colortabrestore(this)'><img src='images/px1tras.gif' width=1 height=1>";
 htmlcenter += "&nbsp;<a href='"+linkto+"' class=all>"+name1+"</a>&nbsp;</layer></ilayer></td></tr>";
 }else{
 htmlcenter = "<tr>";
 htmlcenter += "<td bgcolor='#7C7B73' width='1'><img src='images/px1tras.gif' width='1' height='1' border='0'></td>";
 htmlcenter += "<td bgcolor='#C8C6C6' width='7'><img src='images/menu_arrow.gif' width='7' height='17' border='0'></td>";
 htmlcenter += "<td bgcolor='#C8C6C6' width='154' class='footer' style='padding-left:2px;'>"
 htmlcenter += "<a href="+ linkto+ " onmouseover='setflag();' onmouseout='setflag();' class='menu'>"
 	if (name1 != null) {
	 htmlcenter += name1+"&nbsp;<b style='color:#000000;'>"+name2+"</b></a></td>";
	 }
	else {
	htmlcenter += "<b style='color:#000000;'>"+name2+"</b></a></td>";
	}
 htmlcenter += "<td bgcolor="+ col +" width='17'><img src='images/px1tras.gif' width='17' height='17' border='0'></td>";
 htmlcenter += "<td bgcolor='#7C7B73' width='1'><img src='images/px1tras.gif' width='1' height='1' border='0'></td>";
 htmlcenter += "</tr>";
 }
 document.writeln(htmlcenter);
}


function menustart(popoutid, popinid, classpopin, classpopout) {

 if (net4){
 htmlstart = "<span id="+popoutid+" class="+classpopout+"><span id="+popinid+" class="+classpopin+">";
 htmlstart += "<table cellspacing=0 cellpadding=0 width=150><tr><td bgcolor=#666666><table cellspacing=0 cellpadding=0 width=140>";
 }else{
 htmlstart = "<span id="+popoutid+" class="+classpopout+"><span id="+popinid+" class="+classpopin+">";
  htmlstart +="<table cellpadding='0' cellspacing='0' border='0' width='180'>"
 htmlstart +="<tr>"
 htmlstart +="<td bgcolor='#7C7B73' colspan='5' width='170'><img src='images/px1tras.gif' width='1' height='1' border='0'></td>"
 htmlstart +="</tr>"
 }document.writeln(htmlstart);  
} 

function addspacer() {
  if (net4){
  htmlspacer = "";
  }else{
  htmlspacer = "<tr>"
  htmlspacer += "<td bgcolor='#7C7B73' width='1'><img src='images/px1tras.gif' width='1' height='1' border='0'></td>"
  htmlspacer += "<td bgcolor='#C8C6C6' width='178' colspan='3'><img src='images/menu_spacer.gif' width='178' height='2' border='0'></td>"
  htmlspacer += "<td bgcolor='#7C7B73' width='1'><img src='images/px1tras.gif' width='1' height='1' border='0'></td>"
  htmlspacer += "</tr>"
  }document.writeln(htmlspacer); 
}

function menuend() {
  
  if (net4){
  htmlend = "</table></td></tr></table>";
  htmlend += "</span></span>";
  }else{
  htmlend = "<tr>"
  htmlend += "<td bgcolor='#7C7B73' colspan='5' width='162'><img src='images/px1tras.gif' width='1' height='1' border='0'></td>"
  htmlend += "</tr>"
  htmlend += "</table>"
  htmlend += "</span></span>";
  }document.writeln(htmlend); 
}
 
function setflag(){
  flaglink = !flaglink
}

function visualizza(popoutid, popinid, it) {

	if ((popactivein != null)) {
	nascondi();    
	
	}
	if (net4) {
	document.layers[popoutid].document.layers[popinid].visibility = "show";
	} else {
	document.getElementById(popinid).style.visibility = "visible";
	setonprev(it);
	}
  popactiveout = popoutid
  popactivein = popinid;
} 

function nascondi() {

	if ((popactivein != null) && !flaglink) {
		if (net4) {
		document.layers[popactiveout].document.layers[popactivein].visibility = "hide";
		} else {
		document.getElementById(popactivein).style.visibility = "hidden";
			//for (i=0;i<3;i++){
					//if (arraynoroll[i])	setoffprev(i)
				//}
		}
	}
}



function mouseverifydown(e){

		nascondi();
		
}

if (!net4){
    arrayimg = new Array();
    arrayimg[0] = new Image();
    arrayimg[0].src = "img/corporate_on.gif";
    arrayimg[1] = new Image();
    arrayimg[1].src = "img/news_on.gif";
    arrayimg[2] = new Image();
    arrayimg[2].src = "img/prodotti_on.gif";
    arrayimg[3] = new Image();
    arrayimg[3].src = "img/rivenditori_on.gif";
    arrayimg[4] = new Image();
    arrayimg[4].src = "img/assistenza_on.gif";
    arrayimg[5] = new Image();
    arrayimg[5].src = "img/tariffe_on.gif";
    arrayimg[6] = new Image();
    arrayimg[6].src = "img/fastmail_on.gif";
    arrayimg[7] = new Image();
    arrayimg[7].src = "img/home_on.gif";
    arrayimg[8] = new Image();
    arrayimg[8].src = "img/carrello_on.gif";
    arrayimg[9] = new Image();
    arrayimg[9].src = "img/gestione_on.gif";
    arrayimg[10] = new Image();
    arrayimg[10].src = "img/help_on.gif";
	
    arraynoroll = new Array();
    arraynoroll[0] = false;
    arraynoroll[1] = false;
    arraynoroll[2] = false;
    arraynoroll[3] = false;
    arraynoroll[4] = false;
    arraynoroll[5] = false;
    arraynoroll[6] = false;
    arraynoroll[7] = false;
    arraynoroll[8] = false;
    arraynoroll[9] = false;
    arraynoroll[10] = false;
}

function setnoroll(quale){
    if (!net4){
        for (i=0;i<arraynoroll.length;i++){
         if (arraynoroll[i]) setoffprev(i)
        }
    arraynoroll[i] = false;
    /*
	arraynoroll[1] = false;
    arraynoroll[2] = false;
    arraynoroll[3] = false;
    arraynoroll[4] = false;
    arraynoroll[5] = false;
    arraynoroll[6] = false;
	*/
    arraynoroll[quale] = true;
    }
}

function rollmenu(quale,nome) {
   if (!net4){
   document.images[nome].src = arrayimg[quale].src;
   }
}

function rolloutmenu(nome, come, quale){
  if (!net4){
    if (!arraynoroll[quale]){
  document.images[nome].src  = come
    }
  }
}

function setoffprev(quando){
if (quando == 0){
 document.images['corp'].src = "img/corporate_off.gif"
}
if (quando == 1){
 document.images['news'].src = "img/news_off.gif"
}
if (quando == 2){
 document.images['prodotti'].src = "img/prodotti_off.gif"
}
if (quando == 3){
 document.images['riv'].src = "img/rivenditori_off.gif"
}
if (quando == 4){
 document.images['assist'].src = "img/assistenza_off.gif"
}
if (quando == 5){
 document.images['tariffe'].src = "img/tariffe_off.gif"
}
if (quando == 6){
 document.images['fastmail'].src = "img/fastmail_off.gif"
}
if (quando == 7){
 document.images['home'].src = "img/home_off.gif"
}
if (quando == 8){
 document.images['carrello'].src = "img/carrello_off.gif"
}
if (quando == 9){
 document.images['ordini'].src = "img/gestione_off.gif"
}
if (quando == 10){
 document.images['help'].src = "img/help_off.gif"
}
arraynoroll[quando] = false;
}

function setonprev(allora){
if (allora == 0){
 document.images['corp'].src = "img/corporate_on.gif"
}
if (allora == 1){
 document.images['news'].src = "img/news_on.gif"
}
if (allora == 2){
 document.images['prodotti'].src = "img/prodotti_on.gif"
}
if (allora == 3){
 document.images['riv'].src = "img/rivenditori_on.gif"
}
if (allora == 4){
 document.images['assist'].src = "img/assistenza_on.gif"
}
if (allora == 5){
 document.images['tariffe'].src = "img/tariffe_on.gif"
}
if (allora == 6){
 document.images['fastmail'].src = "img/fastmail_on.gif"
}
if (allora == 7){
 document.images['home'].src = "img/home_on.gif"
}
if (allora == 8){
 document.images['carrello'].src = "img/carrello_on.gif"
}
if (allora == 9){
 document.images['ordini'].src = "img/gestione_on.gif"
}
if (allora == 10){
 document.images['help'].src = "img/help_on.gif"
}
}
