cm=null;    //global varibale with visible layer; default = null;
hide_delay=100;  //delay for the menu in ms
tstat=0;  //timer activity
// detecting browser
cm_parent = null;

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 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 = "";
    	}
	}
	if ( (bolVisible==false) && (cm_parent!=null) ) {
		cm_parent.style.backgroundImage='url(/style/images/template_images/navigation_menu.gif)';
	}
	return 1;
}

//returning offSet
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) {
	if (cm!=null) {
		switchDiv(cm,false);
   	}
    if (m!=null) {
    	m=getelementbyid(m);
    	m.style.left = getPos(el,"Left")+el.offsetWidth-8+"px";
    	m.style.top =  getPos(el,"Top")+3+"px";
    	switchDiv(m,true);
    	cm=m;
    }
    if (el==null) { 
		cm_parent=null; 
	} else { 
		cm_parent=el; 
	}
    if (m==null) { 
		cm=null;
	}
}

function setBack(el,checker) {
	if ( (checker=='no') && (cm!=null) ) { 
		show(null,null); 
	}
 	el.style.backgroundImage='url(/style/images/template_images/navigation_menu_hover.gif)';
}

function changeBack(el) {
	if (cm==null) { 
		el.style.backgroundImage='url(/style/images/template_images/navigation_menu.gif)';
	}
}

function hidemenu() {
	timer1=setTimeout("show(null,null)",hide_delay);
  	tstat=1; return 1;
}

function cancelhide() {
	if (tstat==1) {
 		clearTimeout(timer1); tstat=0;
 	}
	return 1;
}

