//<![CDATA[
//classe per implementare meccanismo apertura graduale di un blocco in una lista al passaggio del mouse

// by M.Corbatto Dic.06



var sb;

function Sliding(id) 
{  this.apri=apri;
   this.chiudi=chiudi;
   this.slideIn=slideIn;
   this.slideOut=slideOut;

   this.id=document.getElementById(id);
   if (this.id==null) return;  //se il blocco ul non esiste evito errori
	 
	 this.dimChiuso=40;
   this.dimAperto=150;
   this.deltaT=30;
   this.deltaX=5;

   this.blocchi=new Array();
   this.aperto=new Array();
   this.dim=new Array();
   this.timer=new Array();
   this.n=0;
	 
   for (var i=0; i<this.id.childNodes.length; i++)
	   if (this.id.childNodes[i].nodeName=='LI')
	   { this.aperto[this.n]=false;
		   this.dim[this.n]=this.dimChiuso;
		   this.timer[this.n]=null;
		   this.blocchi[(this.n)++]=this.id.childNodes[i];
     }	
}


function apri(obj)
{ var x=0;
  for (var i=0; i<this.n; i++)
	if (this.blocchi[i]==obj)
		{if (!this.aperto[i] && !this.timer[i])
		  this.slideIn(i);
		}  
		else
		  if (this.aperto[i] && !this.timer[i])
		     this.slideOut(i);
}				

function chiudi()
{  for (var i=0; i<this.n; i++)
 	 	   if (this.aperto[i] && !this.timer[i])
		   	   this.slideOut(i);
}

function slideIn(i)
{ if (this.dim[i]<this.dimAperto)
  {	this.dim[i]+=this.deltaX;
 		this.blocchi[i].style.width=this.dim[i]+"px";
		this.timer[i]=setTimeout('sb.slideIn('+i+')',this.deltaT);
  }
  else
  {	this.aperto[i]=true;
		this.timer[i]=null;
  }
}

function slideOut(i)
{ if (this.dim[i]>this.dimChiuso)
  {	this.dim[i]-=this.deltaX;
		this.blocchi[i].style.width=this.dim[i]+"px";
		this.timer[i]=setTimeout('sb.slideOut('+i+')',this.deltaT);
  }
  else
  {	this.aperto[i]=false;
		this.timer[i]=null;
  }
}

    //]]>