/* 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(item, linkto, which, num) {
 if (net4){
 htmlcenter = "<tr><td background='/root/img/sfondolay.gif'><ilayer><layer width=150 onmouseover='setflag(); colortab(this)' onmouseout='setflag(); colortabrestore(this)'><img src='/root/img/px1tras.gif' width=1 height=1>";
 htmlcenter += "&nbsp;<a href='"+linkto+"' class=all>"+item+"</a>&nbsp;</layer></ilayer></td></tr>";
 }else{
 htmlcenter = "<tr><td valign='middle' onmouseover='setflag();colortab(this);' onmouseout='setflag();colortabrestore(this);' bgcolor='#E3500E' class='mtext' style='padding:2px 2px 2px 2px;'>&nbsp;<a href="+ linkto +" class='menudrop' onmouseover='if(myv){ParlaTesto("+which+"["+num+"])};' OnMouseOut='if(myv){Stop()};'>"+ item +"</a>&nbsp;</td></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=140><tr><td bgcolor=#E3500E><table cellspacing=0 cellpadding=0 width=160>";
 }else{
 htmlstart = "<span id="+popoutid+" class="+classpopout+"><span id="+popinid+" class="+classpopin+">";
 htmlstart += "<table cellspacing=0 cellpadding=0 bgcolor=#E3500E width='160'>"
 }document.writeln(htmlstart);  
} 

function addspacer() {
  if (net4){
  htmlspacer = "<tr><td valign='top' bgcolor='#7A854F'><img src='img/px1tras.gif' width='1' height='1' border='0'></td></tr>";
  htmlspacer += "<tr><td valign='top' bgcolor='#FFFFFF'><img src='img/px1tras.gif' width='1' height='1' border='0'></td></tr>";
  }else{
  htmlspacer = "<tr><td valign='top' bgcolor='#7A854F'><img src='img/px1tras.gif' width='1' height='1' border='0'></td></tr>";
  htmlspacer += "<tr><td valign='top' bgcolor='#FFFFFF'><img src='img/px1tras.gif' width='1' height='1' border='0'></td></tr>";   
  }document.writeln(htmlspacer); 
}

function menuend() {
  
  if (net4){
  htmlend = "</table></td></tr></table>";
  htmlend += "</span></span>";
  }else{
//  <tr><td colspan=3 bgcolor=#666666 height=1><img src='/root/img/px1tras.gif' width=1 height=1></td></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<6;i++){
					if (arraynoroll[i])	setoffprev(i)
				}
		}
	}
}



function mouseverifydown(e){

		nascondi();
		
}

function colortab(which){
	
	if (net4){
	which.bgColor = "#ffffff";
	}else{
	which.style.backgroundColor = '#8EB027';
	}
}
function colortabrestore(which){
	if (net4){
	which.bgColor = null;
	}else{
	which.style.backgroundColor = '';
	}
}
