var occupied_header = new Array();
var occupied_menu = new Array();
var occupied_sub = new Array();

occupied_menu_all=0;
num=0;
 
//for(i=1;i<=17;i++) {
// occupied_header[i] = 0;
// occupied_menu[i] = 0; 
// occupied_sub[i] = 0; 
//}

function CreateLayer(text, id, parent) {
 if(document.getElementById) {
    t=0;
    l=0;
    var str="<div id=smenu" + id + " style=\"position:absolute;top:" + t + ";left:" + l + ";visibility:hidden;filter:alpha(opacity=100);z-index: 100;\"  OnMouseOver=\"occupied_sub[" + parent + "]=1;occupied_menu[" + id + "]=1;\" onmouseout=\"occupied_sub[" + parent + "]=0; occupied_menu[" + id + "]=0; \">" + text + "</div>";
    document.write(str);
    num++;
 }
}


function relPosX(which) 
{
 if(document.getElementById) {
   var elem = document.getElementById(which); 
   var pos = elem.offsetLeft;
   while (elem.offsetParent != null) {
      elem = elem.offsetParent;
      pos += elem.offsetLeft;
//	window.alert(pos);
      if (elem.tagName == 'BODY') break;
   } 
 }
 return pos;
}


function relPosY(which) 
{
 if(document.getElementById) {
    var elem = document.getElementById(which);
    var pos = elem.offsetTop;
    while (elem.offsetParent != null) {
      elem = elem.offsetParent;
      pos += elem.offsetTop;
      if (elem.tagName == 'BODY') break;
    }
 }
    return pos;
}


function set_zero() {
 for(i=0;i<num;i++) {
	 occupied_header[i] = 0;
	 occupied_menu[i] = 0; 
	 occupied_sub[i] = 0; 

 }
}


function Turn_all() {
//window.alert('123');
 for(i=0;i<num;i++) {
//	window.alert(i);
   eval("setTimeout(\"Off(" + i + ", 7);\",5)");
 }
}

function TurnTop(id, mode,target) {
//    document.getElementById('img7').src='/img/spacer.gif';
//    document.getElementById('img31').src='/img/spacer.gif';
//    document.getElementById('img0').src='/img/spacer.gif';
//    document.getElementById('img23').src='/img/spacer.gif';
//    document.getElementById('img'+id).src='/img/arrow.gif';

    eval("setTimeout(\"Turn(" + id + ", " + mode + ", " + target+ " );\",1)");
}
 
function Turn(id, mode,target) {
 if(document.getElementById || document.all) {
  if(mode)
   eval("setTimeout(\"On(" + id + ", " + mode + ", " + target+ " );\",1)");
  else {
   eval("setTimeout(\"Off(" + id + ", " + mode + ");\",1)");
   }
 }
}

 function On(id, mode,target){
  if(occupied_header[id])
  if(document.getElementById) {
    left1=relPosX('amenu'+id);
    top1=relPosY('amenu'+id);
    width1=document.getElementById('amenu'+id).offsetWidth;
    width2=document.getElementById('smenu'+id).offsetWidth;

    height1=document.getElementById('amenu'+id).offsetHeight;
    if (target) {
	    left2=left1;
	    top2=top1;
    } else {
            if ((id==0||id==2||id==6||id==7||id==9||id==8)) {left2=left1;top2=top1+35;}  else  {left2=left1+width1;top2=top1-2;};	    
//		window.alert(id);
            if (id==10) {left2=left1-width2+3;top2=top1;};
    }
    document.getElementById('smenu' + id).style.top = top2;
    document.getElementById('smenu' + id).style.left = left2-3;
    document.getElementById('smenu' + id).style.visibility = "visible";
  }
 }
 

 function Off(id, mode){
  if(!occupied_menu[id] && !occupied_header[id] && !occupied_sub[id] && !occupied_menu_all) {
	  if(document.getElementById) {
	    document.getElementById("smenu" + id).style.visibility = "hidden";
	  }
  }
 }