isNS4 = (document.layers) ? true : false;
isIE4 = (document.all && !document.getElementById) ? true : false;
isIE5 = (document.all && document.getElementById) ? true : false;
isNS6 = (!document.all && document.getElementById) ? true : false;

function initCat(menuID) {
	var mid = document.getElementById(menuID);
	var arr = mid.getElementsByTagName("div");
	for (var i=0;i<arr.length;i++) {
		if (arr[i].className=="submenu") arr[i].style.display = "none";
		if (arr[i].className=="submenu_chosen") arr[i].style.display = "block";
	}
}
function openCat(cat_id) {
	this.className = (this.className == "item") ? "item_chosen" : "item";
	var idcat = document.getElementById(cat_id);
	idcat.style.display = (idcat.style.display == "none") ? "block" : "none";
}

cm=null;
hide_delay=500;
tstat=1;

function switchDiv(objElement,bolVisible){
if(isNS4||isIE4){
     if(!bolVisible) {
       objElement.visibility ="hidden"
     } else {
       objElement.visibility ="visible"
     }     
 } else if (isIE5 || isNS6) {
      if(!bolVisible){
         objElement.style.display = "none";
         
      } else {
        objElement.style.display = "";
        }
      }
return 1;
}

function getPos(el,sProp) {
	var iPos = 0;
	while (el!=null) {
		iPos+=el["offset" + sProp]
		el = el.offsetParent
	}
	return iPos;

}

function getelementbyid(myid) {
   if (isNS4){
        objElement = document.layers[myid];
     }else if (isIE4) {
        objElement = document.all[myid];
     }else if (isIE5 || isNS6) {
             objElement = document.getElementById(myid);
     }
return(objElement);
}

function show(el,m) {
el.className="over";
if (tstat==0) return;
 if (cm!=null) {
 switchDiv(cm,false);
 }
 if (m!=null) {
 m=getelementbyid(m);
 m.style.left = getPos(el,"Left")-3+"px";
 m.style.top =  getPos(el,"Top")+2+el.offsetHeight+"px";
 switchDiv(m,true);
 cm=m;
 }
}

function hidemenu() {
timer1=setTimeout("show(this,null)",hide_delay);
tstat=1;
return 1;
}

function cancelhide() {
 if (tstat==1) {
 clearTimeout(timer1);
 tstat=0;
 }
return 1;
}
