/*
per i menu al contrario parametrizzare il valore 30 (spazio occupato dalla voce principale)
*/


a="'";
da='"';
browser = navigator.appName;
active=0;

j=1
if (browser == "Netscape")
	{
	for(;j<=N_Menu;j++)
		{
		y=parseInt(eval("Menu"+j+"[0]"))-8;
		eval("Menu"+j+"[0]=y");
		}		
	}

/*IEXPLORER     IEXPLORER     IEXPLORER     IEXPLORER     IEXPLORER     IEXPLORER*/

if (browser == "Microsoft Internet Explorer")
	{
	measure=new Array();
	j=1;
	k=0;
	}
	document.write("<style>");
document.write("BODY{margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;}");


if (browser == "Microsoft Internet Explorer"){
	for(;j<=N_Menu;j++)
		{
		str0=eval("Menu"+j+"[0]");
		str1=eval("Menu"+j+"[1]");
		str2=eval("Menu"+j+"[2]");
		str3=eval("Menu"+j+"[3]");
		str5=eval("Menu"+j+"[5]");
		str6=eval("Menu"+j+"[6]");
		i=7;
		width=0;
		//calculating menu width
		step=((HEIGHT/2)==8)?7:(HEIGHT/2);
		if(step>8) step=8;
		while (parseInt(eval("Menu"+j+"[i]"))!=0)
			{
			temp=(((eval("Menu"+j+"[i]")).length)*step)+10;
			if(temp>width)
				width=temp;
			i+=3;
			}
		//if less...
		if(width<str5)
			width=str5;
		//measure for the menu area
		measure[k]=width;
		height=((i-7)/3)*(HEIGHT+1)+1;
		measure[++k]=height;
		k++;
		//menu style (extern)
		str="#id"+j+"{visibility:hidden;position:absolute;width:"+width+";height:"+height+";left:"+str1+";top:"+str0+";overflow:hidden;}";
		document.write(str);
		str="#idmenu"+j+"{position:absolute;background-color:"+str2+";width:"+width+";height:"+height+";left:0;top:0;}";		
		document.write(str);
		i=7;
		counter=1;
		//menu styles (voices)
		while (parseInt(eval("Menu"+j+"[i]"))!=0)
			{
			str="#idmenu"+j+i+"{position:absolute;background-color:"+str3+";width:"+(width-2)+";height:"+HEIGHT+";left:1px;top:"+counter+"px;}";
			//width-2 because we need 2 px to underline....
			document.write(str);
			i+=3;
			counter+=(HEIGHT+1);//height of every voice (20+1 - small line under the voice -)
			}		
		}//end of for

	/*styles used for the main menu REMEMBER: delete with true main menu*/

	/* end styles used for the main menu*/
	}
	document.write(".car_fixed{font-family:verdana;font-size:"+((HEIGHT/2)+4)+"px;}");	
	document.write(".backtext{background-image:url(images/background.gif);background-repeat:repeat-y;padding-left:16;padding-right:10;padding-bottom:5;text-align:justify;font-family:verdana;font-size:12px;}");
	document.write(".backtext1{background-image:url(images/background.gif);background-repeat:repeat-y;padding-left:16;}");
	document.write(".title{background-image:url(images/title.gif);background-repeat:no-repeat;vertical-align:text-top;padding-left:30px;font-family:verdana;font-size:18px;}");
	document.write(".titlecontact{background-image:url(images/title.gif);background-repeat:no-repeat;vertical-align:text-top;padding-left:30px;font-family:verdana;}");
	document.write(".normal:link{font-family:verdana;font-size:10px;text-decoration:none;}");
	document.write(".normal:visited{font-family:verdana;font-size:10px;text-decoration:none;}");
	document.write(".normal:active{font-family:verdana;font-size:10px;text-decoration:none;}");
	document.write(".normal:hover{font-family:verdana;font-size:10px;text-decoration:none;}");
document.write("</style>");
	/*IEXPLORER     IEXPLORER     IEXPLORER     IEXPLORER     IEXPLORER     IEXPLORER*/

previous="";
outofscreen=0;
shown=false
idtime=0;


xmin=10000;
xmax=0;
ymin=10000;
ymax=0;

xt=0;
yt=0;

ind=1

while(ind<=N_Menu)
{
xt=eval("Menu"+ind+"[1]")

if(xt<xmin)
	xmin=xt

yt=eval("Menu"+ind+"[0]")-HEIGHT_MENU;

if(yt<ymin)
	ymin=yt

ind++;
}

x=0;
y=0;



function decide(evt)
		{

		if (browser == "Microsoft Internet Explorer")
			{
			x=event.clientX;
			y=event.clientY+idbody.scrollTop;			
			}	

		if(browser=="Netscape")
			{	
			x=evt.pageX;
			y=evt.pageY;
			}

		if(x<xmin ||x>xmax|| y<ymin||y>ymax)
			{
			ind=1;
			while(ind<N_Menu)
				{
				if (browser == "Microsoft Internet Explorer")
					eval("document.all.id"+ind+".style.visibility='hidden'");
				if(browser=="Netscape")
					eval("document."+"id"+ind+".visibility='hide'");	
				
				ind++;
				}
			outofscreen=0;
			outofscreenprev=0;
			hiddenprev=false;
			shown=false;
			previous="";
			trueprev="";
			heightprev=0;
			}
	
		}

outofscreenprev=0
trueprev="";
hiddenprev=false;
heightprev=0;

function show(j)
	{	
	if(idtime!=0)
		clearTimeout(idtime);		

if(previous!=j)
{
trueprev=previous;

if(trueprev!="")
{
	if(browser=="Netscape")
		heightprev=approx((eval("document.id"+trueprev+".document.idmenu"+trueprev+".clip.height")));

	if(browser=="Microsoft Internet Explorer")
		heightprev=approx((eval("measure["+((2*trueprev)-1)+"]")));
}

if(browser=="Netscape")
	{
	if(trueprev!="")
		{
		if(eval("Menu"+trueprev+"[6]"))
		outofscreenprev=0;
		else
		outofscreenprev=0;
		}
	if(eval("Menu"+j+"[6]"))
	outofscreen=-approx((eval("document.id"+j+".document.idmenu"+j+".clip.height")));
	else
	outofscreen=approx((eval("document.id"+j+".document.idmenu"+j+".clip.height")));
	}
if(browser=="Microsoft Internet Explorer")
	{
	if(trueprev!="")
		{
		if(eval("Menu"+trueprev+"[6]"))
		outofscreenprev=0;
		else
		outofscreenprev=0;
		}

	if(eval("Menu"+j+"[6]"))
	outofscreen=-approx((eval("measure["+((2*j)-1)+"]")));
	else
	outofscreen=approx((eval("measure["+((2*j)-1)+"]")));
	}
//temp=1

/*
for(;temp<=N_Menu;temp++)	
	{
	if(browser=="Microsoft Internet Explorer")
		eval("document.all.id"+temp+".style.visibility='hidden'");	

	if(browser=="Netscape")
		eval("document."+"id"+temp+".visibility='hide'");		
	}
*/

if(browser=="Microsoft Internet Explorer")
	eval("document.all.id"+j+".style.visibility='visible'");

if(browser=="Netscape")
	eval("document."+"id"+j+".visibility='show'");

shown=false;
hiddenprev=false;
//active=parseInt(j);
}
previous=j

if(trueprev!="" && trueprev!=previous)
	{
	if((!hiddenprev)&&(eval("Menu"+trueprev+"[6]")))
		outofscreenprev-=n_pixel
	else
		if(!hiddenprev)
		outofscreenprev+=n_pixel
	

	if(browser=="Microsoft Internet Explorer")
		eval("document.all.idmenu"+trueprev+".style.top="+outofscreenprev);

	if(browser=="Netscape")
		eval("document.id"+trueprev+".document.idmenu"+trueprev+".top="+outofscreenprev);
	}


if((!shown)&& (j!=""))
	{
	if(eval("Menu"+j+"[6]"))
		{
		outofscreen+=n_pixel
		if(outofscreen>0)
			outofscreen=0;
		}
	else
	if(!shown && (j!=""))
		{
		outofscreen-=n_pixel
		if(outofscreen<0)
			outofscreen=0;
		}
	}

if(browser=="Microsoft Internet Explorer")
	if(j!="")
	eval("document.all.idmenu"+j+".style.top="+outofscreen);

if(browser=="Netscape")
	if(j!="")
	eval("document.id"+j+".document.idmenu"+j+".top="+outofscreen);

ind=1;
while(ind<=N_Menu)
{
if(ind!=parseInt(previous) && ind!=parseInt(trueprev))
	{
	if(browser=="Microsoft Internet Explorer")
		eval("document.all.id"+ind+".style.visibility='hidden'");
	if(browser=="Netscape")
		eval("document."+"id"+ind+".visibility='hide'");
	}
ind++;
}

if(trueprev!="" && trueprev!=previous)
{

if(
(outofscreen<0)&&(eval("Menu"+j+"[6]"))||(
(outofscreenprev>(-heightprev))&&(eval("Menu"+trueprev+"[6]"))
)
)
	idtime=setTimeout("show(previous);",1);
else
	{
	if(
	(
	(outofscreen>0)&&(!(eval("Menu"+j+"[6]")))
	)||
	(
	(outofscreenprev<heightprev)&&(!(eval("Menu"+trueprev+"[6]")))
	)
	)
		idtime=setTimeout("show(previous);",1);
	else
		if(
		(
		(outofscreen<0)&&(eval("Menu"+j+"[6]"))
		)||
		(
		(outofscreen>0)&&(!(eval("Menu"+j+"[6]")))
		)
		)
		shown=true;
		else
			if(
			(
			(outofscreenprev>(-heightprev))&&(eval("Menu"+trueprev+"[6]"))
			)||
			(
			(outofscreenprev<heightprev)&&(!(eval("Menu"+trueprev+"[6]")))
			)
			)
			{
			hiddenprev=true;
			hide(trueprev);
			}
			else
				{
				hiddenprev=true;
				shown=true;
				hide(trueprev);
				}
	}


}


else
	{
	if((outofscreen<0)&&(eval("Menu"+j+"[6]")))
		idtime=setTimeout("show(previous);",1);
	else
		{
		if((outofscreen>0)&&(!(eval("Menu"+j+"[6]"))))
			idtime=setTimeout("show(previous);",1);
		else
			shown=true;
		}
	}
	
}

function hide(menu)
	{
	/*clearTimeout(idtime);
	shown=false;
	outofscreen=0;
	previous="";
	active=0;		*/
	if(browser=="Microsoft Internet Explorer")	
		eval("document.all."+"id"+menu+".style.visibility='hidden'");
	if(browser=="Netscape")
		eval("document.id"+menu+".visibility='hide'");
		
	}

function select(voce,j)
	{
	if(browser=="Microsoft Internet Explorer")
		{
		temp=eval("Menu"+j+"[2]");
		str="document.all."+voce+".style.background='#"+temp+"'";
		eval(str);
		}

	if(browser=="Netscape")
		{
		temp=eval("Menu"+j+"[2]");
		str="document.id"+j+".document."+"idmenu"+j+".document."+"id"+voce+".bgColor="+da+'#'+temp+da;
		eval(str);
		}
	}


function deselect(voce,j)
	{
	if(browser=="Microsoft Internet Explorer")
		{
		temp=eval("Menu"+j+"[3]");
		str="document.all."+voce+".style.background='#"+temp+"'";
		eval(str);
		}
	if(browser=="Netscape")
		{
		temp=eval("Menu"+j+"[3]");
		str="document.id"+j+".document."+"idmenu"+j+".document."+"id"+voce+".bgColor="+da+'#'+temp+da;
		eval(str);
		}
	}

/*NETSCAPE      NETSCAPE      NETSCAPE      NETSCAPE      NETSCAPE      NETSCAPE*/

if (browser == "Netscape")
	{
	
	function init()
		{
		document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove=decide
		}

	}

/*NETSCAPE      NETSCAPE      NETSCAPE      NETSCAPE      NETSCAPE      NETSCAPE*/


function approx(number)
{
x=parseInt(number)
while((x%n_pixel)!=0)
	x++;
return x;
}


