function dummymenu()
{}
function Menu_LayerObject(lnome)
{
return (document.layers)? document.layers[lnome]:((document.all)? document.all[lnome]:((document.getElementById)?document.getElementById(lnome):null));
}
function Menu_DisplayBlock(lay,SiNo)
{
if(document.layers && document.layers[lay]!= undefined)
{
document.layers[lay].display = SiNo ? '':'none';
}
else if(document.all && document.all[lay]!= undefined)
{
document.all[lay].style.display = SiNo ? '':'none';
}
if(document.getElementById && document.getElementById(lay) !=null)
{
document.getElementById(lay).style.display = SiNo ? '':'none';
}
}
function   Menu_tic_espandi()
{
var height=1;
var width=1;
if(this.incrementoh>0)
{
height=  parseInt(this.LayerObject.style.height);
if(isNaN(height)) height=0;
height+=this.incrementoh;
if(this.height>0)
{
 if (height>=this.height)
    {
    this.LayerObject.style.height=this.height;
    height=1;
    }
else
    {
    this.LayerObject.style.height=height;
    height=0;
    }
}
}
if(this.incrementow>0)
{
width= parseInt(this.LayerObject.style.width);
if(isNaN(width)) width=0;
width+=this.incrementow;
if(this.width>0 )
{
	if(width>=this.width)
	{
    this.LayerObject.style.width=this.width;
    width=1;
    }
    else
    {
    this.LayerObject.style.width=width;
    width=0;
    }
}
}
if(height>0 && width>0)
	{
	clearInterval(this.fotointervid);
    this.fotointervid=-1;
    this.riduci=Menu_riduci;
	}
}

function   Menu_tic_riduci()
{
var height=0;
var width=0;
if(this.incrementoh>0)
{
height= parseInt(this.LayerObject.style.height);
if(isNaN(height)) height=0;
height-=this.incrementoh;
if(this.height>0)
this.LayerObject.style.height=height<=0?(height=0):height;
}
if(this.incrementow>0)
{
width=parseInt(this.LayerObject.style.width);
if(isNaN(width)) width=0;
width-=this.incrementow;
if(this.width>0)
this.LayerObject.style.width=width<=0?(width=0):width;
}
if(height<=0 && width<=0)
	{
	clearInterval(this.fotointervid);
     this.fotointervid=-1;
    this.LayerObject.style.visibility = 'hidden';
     this.espandi=Menu_espandi;
	}
}

function Menu_espandi()
 {
if(this.fotointervid>=0)
    {
    clearInterval(this.fotointervid);
     this.fotointervid=-1;
    }

if (this.browser==1)    //Netscape
 	{
 	this.LayerObject.display=''
    this.LayerObject.visibility ='show';
    //this.SetInt();
   	return;
}
if(this.height>0 && this.incrementoh>0)
	this.LayerObject.style.height=0;
if(this.width>0 && this.incrementow>0)
	this.LayerObject.style.width=0;
this.LayerObject.style.visibility = 'visible';
this.ClrInt();
this.fotointervid=setInterval(this.nome+".tic_espandi()",this.fotms);
this.espandi=Menu_ClrInt;
this.riduci=dummymenu;
}

function Menu_riduci()
  {
 if (this.browser==1)   //Netscape
 	{
 		this.ClrInt();
   		this.LayerObject.visibility = 'hide';
   		return;
   }
if(this.fotointervid>=0)
	{
    clearInterval(this.fotointervid);
     this.fotointervid=-1;
    }
 this.fotointervid=setInterval(this.nome+".tic_riduci()",this.fotms);
}

function Menu_SetInt(ev)
{
if(this.padre!=null) this.padre.SetInt(ev);
if (this.browser == 1)
		{
      if((ev == undefined || ev.target.id == undefined) &&_layer.length>0)
			{
			document.layers[_layer].captureEvents(Event.MOUSEOUT);
 			document.layers[_layer].onmouseover = this.SetInt;
			}
		}

if(this.intevalid>=0)
	clearInterval(this.intevalid);
this.intevalid= setInterval(this.nome+".riduci()",1000);
}

function Menu_ClrInt(ev)
{
if(this.padre!=null) this.padre.ClrInt(ev);
if (this.browser == 1)
		{
      if(ev != undefined && ev.target.id != undefined && ev.target.id.indexOf('layer')>=0)
			{
			_layer = ev.target.id;
			document.layers[_layer].releaseEvents(Event.MOUSEOVER);
			}
		else if(_layer.length>0)
			document.layers[_layer].releaseEvents(Event.MOUSEOUT);
		}

if(this.intevalid>=0)
	{
clearInterval(this.intevalid);
this.intevalid= -1;
	}

}
function Menu_layer_left(left)
{
this.LayerObject.style.left=left;
}
function Menu_layer_top(top)
{
this.LayerObject.style.top=top;
}

function Menu_GetDimensions(Layer)
{
var l =Menu_LayerObject(Layer)
if(l==undefined) return;
var height=  parseInt(l.style.height);
var width=   parseInt(l.style.width);
if(!isNaN(height)) this.LayerObject.style.height=this.height=height+15;
if(!isNaN(width)) this.LayerObject.style.width=this.width=width+5;
}

function Menu_TopLeftImg(imgName)
    {
if(document.layers)
    {
	if(!(img =document[imgName]))
        {
        var n = 1;
        while(document.layers[n])
            if((img = document.layers[n++].document[imgName]))
                 return new Array(img.x,img.y);
         }

    }
else
{
 img=document.images[imgName];
 if(document.all)
	{
	var Left_,Top_;
	Top_ = img.offsetTop;
	Left_ =img.offsetLeft;
	while((img=img.offsetParent) != null)
		{
		Top_+=img.offsetTop;
		Left_ += ogg.offsetLeft;
  		}
	return new Array(Left_,Top_);
	}
else if(document.getElementById)
        return new Array(img.x,img.y);
 }
}
function Menu_findPosDim(obj)
{
	var top=0;
	var left=0;
	var height=obj.offsetHeight;
	var width=obj.offsetWidth;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			top += obj.offsetTop ;
			left += obj.offsetLeft
			//height += obj.offsetHeight
			//width += obj.offsetWidth
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		{
        top = obj.x ;
		left = obj.y;
		height = obj.height;
		width = obj.width;
        }

	return Array(top,left,height,width);
}
//----------
function MoveLayer(top,left)
{
this.LayerObject.style.left=left;
this.LayerObject.style.top=top;
}

var arrayGroup = new Array();

function menu_layer(nome,lnome)
{
this.browser = (document.layers)? 1:((document.all)? 2:((document.getElementById)?3:0));
this.LayerObject=Menu_LayerObject(lnome);
var temp = Menu_findPosDim(this.LayerObject);
this.left= temp[0];
this.top = temp[1];
this.width=temp[3];
this.height=temp[2];
this.intevalid=-1;
this.fotointervid=-1;
this.layername=lnome;
this.nome=nome;
this.incrementow=15;
this.incrementoh=5;
this.fotms=10;
this.espandi=Menu_espandi;
this.riduci=Menu_riduci;
this.tic_espandi=Menu_tic_espandi;
this.tic_riduci=Menu_tic_riduci;
this.SetInt=Menu_SetInt;
this.ClrInt=Menu_ClrInt;
this.GetDimensions= Menu_GetDimensions;
this.move=MoveLayer
this.padre=null;
this.flagCancella=true;
arrayGroup[arrayGroup.length]=this;
}

//************************

function ChiudiTutto(nomel)
{
var n=m=arrayGroup.length;
var padri = null;

while(m-->0)
	{
    var  l =arrayGroup[m];
    if(l.nome == nomel)
    {
	padri=l.padre;
	l.flagCancella=false;
	}
    else l.flagCancella=true;
    }
while(padri != null)
	{
    padri.flagCancella=false;
    padri=padri.padre;
    }
while(n-->0)
	{
    var  l =arrayGroup[n];
    if(l.flagCancella) l.riduci();
    }
}