var oldwhich="";
var waittime=300;
var layerTimer;
var position_top=30;
var position_left=160;


function showlayer(nam,val)
{
if (val>0) {document.getElementById(nam).style.visibility="visible";} else {document.getElementById(nam).style.visibility="hidden";}
return;
}

function getmenuheight (nam)
{
 return document.getElementById(nam).offsetHeight;
}

//turn on layer and rollover
	function layOver(nam,place)
	{
	obj=document.getElementById(nam);
	if (oldwhich!=nam&&oldwhich!="")
	{
		ol=document.getElementById(oldwhich).style;
		ol.visibility="hidden";
	}
	if (obj)
	{
	l = document.getElementById(nam).style;


	l.visibility = "visible";

	x=findPosX(place);
	y=findPosY(place);
	l.position='absolute';
	l.left=position_left+x+"px";
	if (position_top+y-getmenuheight(nam)/2>document.body.scrollTop) l.top=position_top+y-getmenuheight(nam)/2+"px"; else l.top=document.body.scrollTop+"px";

	oldwhich=nam;
	}
	clearTimeout(layerTimer);
		
	return;
	}
	
//turn off layer and rollover if user is completely off nav 
	function stopOver()
	{   
	layerTimer = setTimeout("layOut()",waittime);
	}

	function layOut()
	{   
	   if (oldwhich!="")
	    {
	ol = document.getElementById(oldwhich).style;
	ol.visibility = "hidden";	
	    }
	}
//reset the timer
	function startOver()
	{
	clearTimeout(layerTimer);
	}

function findPosX(id){
	var curleft = 0;
	obj=document.getElementById(id);
	obj = obj.offsetParent;
	while (obj.offsetParent){
		curleft += obj.offsetLeft
		obj = obj.offsetParent;		
	} 
	return curleft;
}

function findPosY(id){
	var curtop = 0;
	obj=document.getElementById(id);
obj = obj.offsetParent;
	while (obj.offsetParent){
		curtop += obj.offsetTop
		obj = obj.offsetParent;
	}
	return curtop;
}

function showImage(img, alt){
  foto1= new Image();
  foto1.src=(img);
  Controlla(img, alt);
}
function Controlla(img, alt){
  if((foto1.width!=0)&&(foto1.height!=0)){
    viewFoto(img ,alt);
  }
  else{
    funzione="Controlla('"+img+"', '"+alt+"')";
    intervallo=setTimeout(funzione,20);
  }
}
function viewFoto(img, alt){

  altez=foto1.height+60;
  if (altez>800)
  {
   altez=800;
   largh=foto1.width+60;
  stringa="width="+largh+",height="+altez+",scrollbars=yes";
  } else 
{
 largh=foto1.width+40;
  stringa="width="+largh+",height="+altez+",scrollbars=no";
}
 

  title=document.title; 

  finestra=window.open('about:blank',"",stringa);
  finestra.document.write("<html><head><title>"+title+"</title></head><body bgcolor=#ffffff TOPMARGIN=0 LEFTMARGIN=0 RIGHTMARGIN=0 BOTTOMMARGIN=0><table border=0 cellpadding=20 cellspacing=0><tr><td><img src="+img+" border=1 style='margin-bottom:10px;' alt=''><br /><center><b style='font-family:tahoma; font-size:12px; font-weight:bold; color: #333333;'>"+alt+"</b></center></td></tr></table></body></html>");
}
