//set up layer call
var isIE, isNS, isNS6, isDOM, lR, sR, vis, invis, myTimeOut, goName, TopRef, LeftRef;
	if (document.all) {isIE= true;lR="document.all.";sR=".style";vis="visible";invis="hidden";TopRef=".pixelTop"; LeftRef=".pixelLeft"}
	if (document.layers){isNS = true;lR="document.layers.";sR="";vis="show";invis="hide";TopRef=".top";LeftRef=".left"}
	if (document.getElementById &&!isIE) {isDOM=true;lR = "document.getElementById('";sR = "').style";invis ="hidden";vis = "visible"}
	if (isDOM == true && navigator.appName =="Netscape") isNS6 = true;
	
window.name="padre";

var oldwhich = 0;
var leaf = 0;
var x=1;
var layerTimer;
	
// image change
	function ChImage(which)
	{l = eval("menuimage"+which);
	m = eval("menuimga"+which);
	l.src = m.src;
	}

function RestoreImage(which)
	{l = eval("menuimage"+which);
	 m = eval("menuimg"+which);
	l.src = m.src;
	}

//turn on layer and rollover
function LayOver(which, posix, posiy)
{
x=1;
var ol; 
var l;
//arrow off
//	toggleArrow(oldwhich,"lN","off");

if (which == 0) // se apro il layer 0 in realta' voglio chiuderli tutti
	{
	if (oldwhich > 0)
		{
		ol = eval(lR + "layer" + oldwhich + sR);
		ol.visibility = invis;
		}
	oldwhich = 0;	
	if (leaf > 0)
		{
		ol = eval(lR + "layer" + leaf + sR);
		ol.visibility = invis;
		}
	leaf = 0;
	}
else
	{
	if (oldwhich != which)
		{
		if (which < 10) // sto aprendo un layer di menu primario - max 10 layer di menu primari
			{
			if (oldwhich)
				{
				ol = eval(lR + "layer" + oldwhich + sR);
				ol.visibility = invis;
				}
			oldwhich = which;
			if (leaf) 
				{ol = eval(lR + "layer" + leaf + sR);
				 ol.visibility = invis;
				}
			leaf = 0;	
			}
		else 	{ // sto aprendo un layer di menu secondario
			if (leaf) 
				{
				ol = eval(lR + "layer" + leaf + sR);
				ol.visibility = invis;
				}
			if (which != 100) {leaf = which;}
			else {leaf = 0;}
			}
		}
	
	if (which != 100) // se sto aprendo il layer 100 in realta' non voglio aprirne ma chiudere le foglie
		{
		l = eval(lR + "layer" + which + sR);
		l.visibility = vis;
		if (isIE)
			{
			l.pixelLeft = posix;
			l.pixelTop = posiy;
			}
		else
			{
			l.left = posix;
			l.top = posiy;
			}
		}
	}
	
clearTimeout(layerTimer);
return;
}
	
//turn off layer and rollover if user is completely off nav 
function StopOver()
	{
	if (x<5) x++;
	else
		{
		if (oldwhich > 0)
			{
			ol = eval(lR + "layer" + oldwhich + sR);
			ol.visibility = invis;
			}
		oldwhich = 0;	
		
		if (leaf)
			{
			ol = eval(lR + "layer" + leaf + sR);
			ol.visibility = invis;
			} 
			
		leaf = 0;	
		//arrow off
        	//toggleArrow(oldwhich,"lN","off");
		
		x=1;
		}
	layerTimer = setTimeout("StopOver()", 200)
	}
	
//reset the timer
	function StartOver()
	{
	x=1
	clearTimeout(layerTimer);
	}


function apri(url) {

		wndRef = window.open(url,"1","toolbar=no,location=no,directories=no,status=no,menubar=no,title=no,scrollbars=no,resizable=no,copyhistory=no,width=600,height=200,left=0,top=0");

		if(navigator.appName =="Netscape")

			wndRef.focus(1);

		return;

	}
	
	
function findPosX(cellId)
{
if (document.layers)
	return document.layers[cellId].pageX;
else 
	{
	var cell = document.all ? document.all[cellId] : document.getElementById(cellId);
	var x = 0;
	while (cell) 
		{
	        x += cell.offsetLeft;
		cell = cell.offsetParent;
		}
	return x;
	}
}


function findPosY(cellId)
{
if (document.layers)
	return document.layers[cellId].pageY;
else 
	{
	var cell = document.all ? document.all[cellId] : document.getElementById(cellId);
	var y = 0;
	while (cell) 
		{
	        y += cell.offsetTop;
		cell = cell.offsetParent;
		}
	return y;
	}
}

