//free JavaScripts on http://www.ScriptBreaker.com

  var height = 18; // height of the menu headers
  var iheight = 18; // height of the menu_items
  
  var speed = 1;
  var incDown = 5
  var incUp = 5
  var inc2
  var timerIDUP = 0;
  var timerIDDOWN = 0;
  var timerIDREC = 0;
  var N = (document.all) ? 0 : 1;
  var width = 152
  var menuStatus = new Array();
  var menuDown
  var menuto = 0
  var menubegin = 0
  var menuval = 0
  var start = true

  var self_menu = new Array();
function write_menu()
{
  smc = 0; // count the position of the self_menu
  document.write("<div style='position:absolute;'>");
  mn = 0;
  mni = 1;
  start = -1;
  
  for(i=0;i<Link.length;i++)
  {
   la = Link[i].split("|");

   if (la[0] == "0" || la[0] == "-1")
   {
    if(start == 0) 
     {
      document.write("</div>");
      h =  csmc * iheight;
      tmn = mn; //-h
      self_menu[smc] = new Array(tmn,h,0,-2);
	  menuStatus[smc] = new Array(1,1,1,1,1);
	  menuStatus[smc][4] = 0;
      smc++;
      mn--;
     }
     csmc = 0;
     if (la[0] == "0")
    	document.write("<div class='menu' style='top:"+mn+";height:"+height+"' id='down"+smc+"' onclick='pull_down("+smc+","+mni+")'>"+ la[1] + "</div>");
	 else{
    	document.write("<div class='menu' style='top:"+mn+";height:"+height+"' id='down"+smc+"'>"+ la[1] + "</div>");
		mn--;
	 }
    self_menu[smc] = new Array(mn,height,0,mni);
    menuStatus[smc] = new Array(1,1,1,1,1);
	menuStatus[smc][4] = 0;
    smc++;
    mni++;
    mn+=height;
    start = 1;
   }
   else
   {
    if(start == 1) 
     {
      if(N)mn+=2;
       document.write("<div class='item_panel' id='down"+smc+"' style='top:"+mn+"'>");
       start = 0;
     }
    
    document.write("<span href='"+la[2]+"'");
//    if (la[3] != "") document.write(" target='" + la[3] + "' ");
    document.write("><div class='item' id='d"+i+"' style='height:"+iheight);
    if (N) document.write(";width:152");
    document.write("'>"+ la[1] + "</div></span>");
	menuStatus[smc-1][4]++;
	csmc++;
   }
  }
  if (start == 0) 
   {
     document.write("</div>");
     h =  csmc * iheight;
     tmn = mn + 5; //-h
     self_menu[smc] = new Array(tmn,h,0);
     menuStatus[smc] = new Array(1,1,1,1,1);
   }
  document.write("</div>");
}
  

function pull_down(nr,c)
{
 var to_=0, begin_=0, val_=0
 
 if(start == true) {
 	start = false
 	return;
 }

 if (timerIDUP == 0 && timerIDDOWN == 0)
 {
 to = self_menu[nr+1][1]
 begin = nr + 2;

 if (self_menu[nr+1][2] == 0)
 {
  self_menu[nr+1][2] = 1;
  if(nr == self_menu.length-2) {to++;}
  
  epull_down(begin,to,0);
  for (i=0; i < menuStatus.length; i++) {
 	if (menuStatus[i][0] == true && i != (nr + 1)) {
	   menuStatus[i][0] = false
  	   begin_ = menuStatus[i][1]	    
	   to_ = menuStatus[i][2]			
	   val_ = menuStatus[i][3] 		
	   epull_recolher(begin_,to_,val_)
	   i = menuStatus.length
	}
 }
  menuStatus[nr+1][0] = true		// menu = down
  menuStatus[nr+1][1] = begin		// posição inicial
  menuStatus[nr+1][2] = to			// pixeis a mover
  menuStatus[nr+1][3] = 0			// val
 }

 else
 {
  to = 0;
  self_menu[nr+1][2] = 0;
  name = "down"+(nr+2);
  open_item = 0;
  for(i=0;i<nr;i++)
  {
   if(self_menu[i][2] == 1) 
    {open_item += self_menu[i][1];
    }
  }
  if (N == false) {open_item-= (c*1)};
  if (nr== self_menu.length-2) {val = self_menu[self_menu.length-1][1];to=-1;}
  else  val = parseInt(document.getElementById(name).style.top) -(open_item)-(c*height);

  epull_up(begin,to,val);
  
  for (i=0; i < menuStatus.length; i++) {
 	if (menuStatus[i][0] == true && i != (nr + 1)) {
	   menuStatus[i][0] = false
  	   begin_ = menuStatus[i][1]	    
	   to_ = menuStatus[i][2]			
	   val_ = menuStatus[i][3] 		
	   epull_recolher(begin_,to_,val_)
	   i = menuStatus.length
	}
 }
  menuStatus[nr+1][0] = false		// menu = down
  menuStatus[nr+1][1] = begin		// posição inicial
  menuStatus[nr+1][2] = to			// pixeis a mover
  menuStatus[nr+1][3] = val			// val
 }
 }
}

function epull_down(nr,to,nowv)
{
 name = "down" + (nr-1);
 obj = document.getElementById(name).style.clip = "rect(0,"+width+","+(nowv+1)+",0)";

 for (i=nr;i<self_menu.length;i++)
 {
  name = "down" + i;
  obj = document.getElementById(name);
  if((nowv + incDown) > to)
    inc2 = 1;
  else
    inc2 = incDown;
  obj.style.top = parseInt(obj.style.top)+inc2;
 }

 nowv+=inc2;
 if(nowv < to) timerIDDOWN = setTimeout("epull_down("+nr+","+to+","+nowv+")",speed);
 else { clearTimeout(timerIDDOWN); timerIDDOWN = 0;}
}

function epull_up(nr,to,nowv)
{
 name = "down" + (nr-1);
 obj = document.getElementById(name).style.clip = "rect(0,"+width+","+nowv+",0)";

 for (i=nr;i<self_menu.length;i++)
 {
  name = "down" + i;
  obj = document.getElementById(name);
  if((nowv - incUp) < to)
    inc2 = 1;
  else
    inc2 = incUp;
  obj.style.top = parseInt(obj.style.top)-inc2;
 }

 nowv-=inc2;
 if(nowv > to) timerIDUP = setTimeout("epull_up("+nr+","+to+","+nowv+")",speed);
 else { clearTimeout(timerIDUP); timerIDUP = 0;}
}

function epull_recolher(nr,to,nowv)
{
 if (self_menu[nr-1][2] == 0)
	 self_menu[nr-1][2] = 1;
 else
	 self_menu[nr-1][2] = 0;
 name = "down" + (nr-1);
 obj = document.getElementById(name).style.clip = "rect(0,"+width+","+nowv+",0)";
 for (i=nr;i<self_menu.length;i++)
 {
  name = "down" + i;
  obj = document.getElementById(name);
  obj.style.top = parseInt(obj.style.top)-to;
 }
}

function put_down(nr,c)
{
 var to_=0, begin_=0, val_=0
 
 if(start == true) {
 	start = false
 	return;
 }

 if (timerIDUP == 0 && timerIDDOWN == 0)
 {
 to = self_menu[nr+1][1]
 begin = nr + 2;

 if (self_menu[nr+1][2] == 0)
 {
  self_menu[nr+1][2] = 1;
  if(nr == self_menu.length-2) {to++;}
  
  eput_down(begin,to,0);
  for (i=0; i < menuStatus.length; i++) {
 	if (menuStatus[i][0] == true && i != (nr + 1)) {
	   menuStatus[i][0] = false
  	   begin_ = menuStatus[i][1]	    
	   to_ = menuStatus[i][2]			
	   val_ = menuStatus[i][3] 		
	   //epull_recolher(begin_,to_,val_)
	   i = menuStatus.length
	}
  }
  menuStatus[nr+1][0] = true		// menu = down
  menuStatus[nr+1][1] = begin		// posição inicial
  menuStatus[nr+1][2] = to			// pixeis a mover
  menuStatus[nr+1][3] = 0			// val
 }

 }
}

function eput_down(nr,to,nowv)
{
 var incPutDown = to - 1
 name = "down" + (nr-1);
 obj = document.getElementById(name).style.clip = "rect(0,"+width+","+(nowv+1)+",0)";

 for (i=nr;i<self_menu.length;i++)
 {
  name = "down" + i;
  obj = document.getElementById(name);
  if((nowv + incPutDown) > to)
    inc2 = 1;
  else
    inc2 = incPutDown;
  obj.style.top = parseInt(obj.style.top)+incPutDown;
 }

 nowv+=incPutDown;
 
 if(nowv < to) timerIDDOWN = setTimeout("epull_down("+nr+","+to+","+nowv+")",speed);
 else { 
  clearTimeout(timerIDDOWN); timerIDDOWN = 0;
 }
}

function startup(nr)
{
 write_menu();

 for(i=0;i<self_menu.length;i++)
	menuStatus[i][0] = false
 
 start = false
 	
 if (nr != 0)
 {
 start = false
 for(i=0;i<self_menu.length;i++)
 {
  if(self_menu[i][3] == nr) put_down(i,nr)
  i==self_menu.length;
 }
 }
}  