IE=document.all?1:0;
NN=document.layers?1:0;
mainitems=19
imgpath="images"
itemsheight=new Array(15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15)
subitems=new Array(0,0,0,0,0,0,0,7,0,5,0,0,0,0,0,0,0,0,0)
subitemsheight=new Array(0,0,0,0,0,0,0,105,0,75,0,0,0,0,0,0,0,0,0)
sub2itemsheight=new Array(mainitems)
sub2itemsheight[0]=new Array()
sub2itemsheight[1]=new Array()
sub2itemsheight[2]=new Array()
sub2itemsheight[3]=new Array()
sub2itemsheight[4]=new Array()
sub2itemsheight[5]=new Array()
sub2itemsheight[6]=new Array()
sub2itemsheight[7]=new Array(0,0,0,0,0,0,0)
sub2itemsheight[8]=new Array()
sub2itemsheight[9]=new Array(0,0,0,0,0)
sub2itemsheight[10]=new Array()
sub2itemsheight[11]=new Array()
sub2itemsheight[12]=new Array()
sub2itemsheight[13]=new Array()
sub2itemsheight[14]=new Array()
sub2itemsheight[15]=new Array()
sub2itemsheight[16]=new Array()
sub2itemsheight[17]=new Array()
sub2itemsheight[18]=new Array()
openeditem=0;openedsubitem=0;openedsub2item=0

function hideitem(n){
 if(IE){
  document.all(n).style.visibility="hidden"
 }else if(NN){
  document.layers[n].visibility="hide"
 }
}

function showitem(n){
 if(IE){
  document.all(n).style.visibility="visible"
 }else if(NN){
  document.layers[n].visibility="show"
 }
}

function changeitemimage(m,n,s){
 mname="mcont"+m+"-"+n;
 mimgname="menuimg"+m+"-"+n;
 if(s=="over"){
  if(IE){
   document.all(mimgname).src=(imgpath+"m"+m+"-"+n+"-ov.gif")
  }else if(NN){
   document.layers[mname].document.images[mimgname].src=(imgpath+"m"+m+"-"+n+"-ov.gif")
  }
 }else if(s=="out"){
  if(IE){
   document.all(mimgname).src=(imgpath+"m"+m+"-"+n+"-cl.gif")
  }else if(NN){
   document.layers[mname].document.images[mimgname].src=(imgpath+"m"+m+"-"+n+"-cl.gif")
  }
 }else if(s=="open"){
  if(IE){
   document.all(mimgname).src=(imgpath+"m"+m+"-"+n+"-op.gif")
  }else if(NN){
   document.layers[mname].document.images[mimgname].src=(imgpath+"m"+m+"-"+n+"-op.gif")
  }
 }
}

function mouseoutitem(n,m){
 if(n>=0&&n<=mainitems){
  if(n==0){
   if(openeditem==m){
    changeitemimage(0,m,"open")
   }else{
    changeitemimage(0,m,"out")
   }
  }else{
   if(openedsubitem==m){
    changeitemimage(n,m,"open")
   }else{
    changeitemimage(n,m,"out")
   }
  }
 }
}

function mouseoveritem(n,m){
 if(n>=0&&n<=mainitems){
  if(n==0){
   if(m!=openeditem){
    changeitemimage(n,m,"over")
   }
  }else if(m!=openedsubitem){
   changeitemimage(n,m,"over")
  }
 }
}

function moveitem(n,h){
 if(h!=0){
  if(IE){
   document.all(n).style.pixelTop-=h
  }else if(NN){
   document.layers[n].top-=h
  }
 }
}

function moveitems(n,m,h){
 if(n>=0&&n<=mainitems){
  if(n==0){
   for(var i=m;i<=mainitems;i++) moveitem("mcont0-"+i,h);
   moveitem("formcont",h)
  }else if(m>0&&m<=subitems[n-1]){
   for(var i=m;i<=subitems[n-1];i++){
    moveitem("mcont"+n+"-"+i,h)
   }
  }
 }
}

function openitem(n){
 if(n>0&&n<=mainitems&&subitems[n-1]>0&&openeditem!=n){
  openeditem=n;changeitemimage(0,n,"open")
  for(var i=1;i<=subitems[n-1];i++){
   showitem("mcont"+n+"-"+i)
  }
  moveitems(0,n+1,-subitemsheight[n-1])
 }
}

function closeitem(n){
 if(n>0&&n<=mainitems&&subitems[n-1]>0&&openeditem!=0){
  for(var i=1;i<=subitems[n-1];i++){
   hideitem("mcont"+n+"-"+i)
  }
  moveitems(0,n+1,subitemsheight[n-1]);
  changeitemimage(0,n,"out");
  openeditem=0
 }
}

function opensubitem(n){
 if(n>0&&openeditem!=0&&openedsubitem==0&&n<=subitems[openeditem-1]){
  if(IE){
   moveitems(0,openeditem+1,-sub2itemsheight[openeditem-1][n-1]);
   moveitems(openeditem,n+1,-sub2itemsheight[openeditem-1][n-1]);
  }else if(NN){
   moveitems(0,openeditem+1,-sub2itemsheight[openeditem-1][n-1]-(sub2itemsheight[openeditem-1][n-1]*2)/10);
   moveitems(openeditem,n+1,-sub2itemsheight[openeditem-1][n-1]-(sub2itemsheight[openeditem-1][n-1]*2)/10);  
  }
  showitem("mcont"+openeditem+"-"+n+"-1");
  openedsubitem=n;
  changeitemimage(openeditem,n,"open")
 }
}

function closesubitem(n){
 if(n>0&&openeditem!=0&&openedsubitem!=0&&n<=subitems[openeditem-1]){
  hideitem("mcont"+openeditem+"-"+n+"-1");
  if(IE){
   moveitems(0,openeditem+1,sub2itemsheight[openeditem-1][n-1])
   moveitems(openeditem,n+1,sub2itemsheight[openeditem-1][n-1]);
  }else if(NN){
   moveitems(0,openeditem+1,sub2itemsheight[openeditem-1][n-1]+(sub2itemsheight[openeditem-1][n-1]*2)/10)
   moveitems(openeditem,n+1,sub2itemsheight[openeditem-1][n-1]+(sub2itemsheight[openeditem-1][n-1]*2)/10);
  }
  openedsubitem=0;
  changeitemimage(openeditem,n,"out")
 }
}

function toggleitem(n){
 if(n>=0&&n<=mainitems&&subitems[n-1]>0){
  if(openeditem==0){
   if(openedsubitem!=0){
    closesubitem(openedsubitem)
   }
   openitem(n)
  }else{
   if(n==openeditem){
    if(openedsubitem!=0){
	 closesubitem(openedsubitem)
	}
	closeitem(openeditem)
   }else{
    if(openedsubitem!=0){
	 closesubitem(openedsubitem)
	}
	closeitem(openeditem)
	openitem(n)
   }
  }
 }
}

function togglesubitem(n){
 if(openeditem!=0&&sub2itemsheight[openeditem-1][n-1]!=0){
  if(openedsubitem==0){
   opensubitem(n)
  }else{
   if(n==openedsubitem){
    closesubitem(n)
   }else{
    closesubitem(openedsubitem);
	opensubitem(n)
   }
  }
 }
}

function menuinit(n,m){
 openitem(n);
 opensubitem(m)
}

