var atimer=null;

function HideSubMenu(MenuID){
  if(parent.timer&&FOB(MenuID)){ Style=FOB(MenuID); Style.style.visibility='hidden'; }
}

function StartTimer(MenuID,L){
  parent.MID=MenuID; parent.timer=parent.setTimeout("HideSubMenu(MID)",L);
}

function StopTimer(){
  if(parent.timer) { parent.clearTimeout(parent.timer); parent.timer=null; }
}

function AnimateMenu(Menu,Max,Curr,AMode){
  ie5=(document.all && document.getElementById);
  ns6=(!document.all && document.getElementById);
  MID=Menu; M=FOB(Menu); MX=Max; CR=Curr; AM=AMode; CR+=40;
  if(AM=='central') M.style.clip="rect("+((parseInt(M.style.width)/2)-CR)+","+((parseInt(M.style.width)/2)+CR)+","+((parseInt(M.style.height)/2)+CR)+","+((parseInt(M.style.height)/2)-CR)+")";
  else if(AMode=='both') M.style.clip="rect(0,"+CR+","+CR+",0)";
  else if(AMode=='topdown')  M.style.clip="rect(0,"+parseInt(M.style.width)+","+CR+",0)";
  else if(AMode=='leftright')  M.style.clip="rect(0,"+CR+","+parseInt(M.style.height)+",0)";
  else if(AMode=='alpha') { M.style.visibility='visible'; if(ie5) M.style.filter="alpha(opacity="+(CR/4)+")"; if(ns6) M.style.MozOpacity=(CR/400); }
  if(CR<=Max) atimer = setTimeout("AnimateMenu(MID,MX,CR,AM)", 10);
  else clearTimeout(atimer);
}

function HideMenus(){
  if(parent.menus) for(i=0;i<parent.menus.length;i++){Style=parent.menus[i]; Style.style.visibility='hidden';}
  clearTimeout(atimer);
}

function ShowSubMenu(MenuID,Left,Top,AMode){
  ie5=(document.all && document.getElementById);
  ns6=(!document.all && document.getElementById);
  if(FOB(MenuID))
  {
    StopTimer();
    if((p=MenuID.indexOf("?"))>0&&parent.frames.length) { fb=parent.frames[MenuID.substring(p+1)].document.body; dl=parseInt(fb.scrollLeft); dt=parseInt(fb.scrollTop);} else { fb=document.body; dl=0; dt=0;}
    exists=0;
    if(!parent.menus) parent.menus=new Array();
    for(i=0;i<parent.menus.length;i++){if(parent.menus[i]==FOB(MenuID)) exists=1; }
    if(!exists) parent.menus[parent.menus.length]=FOB(MenuID);
    if(FOB(MenuID).style.visibility=='hidden')
    {
      HideMenus(); Style=FOB(MenuID);
      Style.style.left=Left+dl; Style.style.top=Top+dt;
      if(AMode!='alpha')
      {      
       Style.style.clip="rect(0,0,0,0)"; Style.style.overflow='hidden'; Style.style.visibility= 'visible';
       if(parseInt(Style.style.width)>parseInt(Style.style.height)) Max=parseInt(Style.style.width); else Max=parseInt(Style.style.height);
      }
      else { Max=360; }
      AnimateMenu(MenuID,Max,0,AMode);
    }
  }
}

function FOB(n, d) { 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=FOB(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
