var user_agent=navigator.userAgent.toLowerCase();
var nav_win = ( (user_agent.indexOf("win")!=-1) || (user_agent.indexOf("16bit")!=-1) );
var nav_mac = (user_agent.indexOf("mac")!=-1);
var nav_linux = (user_agent.indexOf("inux")!=-1);

window.onerror = null;
var bName = navigator.appName;
var NS4 = (document.layers) ? true : false;
var IE3 = (document.all && !document.getElementById) ? true : false;
var IE4 = (document.all && document.getElementById) ? true : false;
var IE6 = (document.all && document.getElementById) ? true : false;
var NS6 = (!document.all && document.getElementById) ? true : false;
var menuActive = 0
var menuOn = 0
var onLayer = ""
var timeOn = null 

// SHOW MENU
function showLayer(layerName, callingObj, objName){		
	if(NS4 || IE4 || NS6) {
		if(timeOn != null){
			clearTimeout(timeOn);
			hideLayer(onLayer);
		}				
		iLeft = getObjPageLeft(callingObj, objName);
		if(NS6){
			iTop  = getObjPageTop(callingObj, objName) + 10;
		}
		else{
			iTop  = getObjPageTop(callingObj, objName)+21;	
		}
		if(IE4){
			if(nav_mac){iTop += 15;}
			document.all[layerName].style.visibility = "visible";
			document.all[layerName].style.top = iTop;
			document.all[layerName].style.left = iLeft;
		}
		if(NS4){		
			document.layers[layerName].visibility = "show";
			document.layers[layerName].top = iTop;
			document.layers[layerName].left = iLeft;
		}
		if(NS6){			
			obj = document.getElementById(layerName);
			obj.style.visibility = "visible";
			obj.style.left = iLeft;
			obj.style.top = iTop;			
		}
		onLayer = layerName
	}
}

function hideLayer(layerName){
	if(layerName.length == 0){return;}
	if (menuActive == 0) {
		if (NS4) {
			document.layers[layerName].visibility = "hide";
		} 
		if(IE4){
			document.all[layerName].style.visibility = "hidden";
		}			
		if(NS6){
			obj = document.getElementById(layerName);
			obj.style.visibility = "hidden";
		}
	}
}
 
function btnTimer() {
	timeOn = setTimeout("btnOut()",1000)
}

function btnOut(layerName){
	if (menuActive == 0){
		hideLayer(onLayer)
	}
}

 
function menuOver(){
	clearTimeout(timeOn)
	menuActive = 1
}
 
function menuOut(){
	menuActive = 0 
	timeOn = setTimeout("hideLayer(onLayer)", 400)
}
 
function setBgColor(layer, color, menu){
	if(menu == "in"){menuOver();}
	if(menu == "out"){menuOut();}
	
	if(NS4){
		document.layers[layer].document.bgColor = color;
		document.layers[layer].saveColor = color;
	}
	if(NS6){
		obj = document.getElementById(layer);
		obj.style.backgroundColor = color;
	}		
	if(IE4){
		document.all[layer].style.backgroundColor = color;
	}
}


function getObjPageLeft(callingObj, objName) {
  	var x = 0, obj;
  	if(NS4){
    	if(callingObj.container != null)
      		return callingObj.container.pageX + callingObj.x;
    	else
      		return callingObj.x;
  	}	
  	if(IE4 || NS6){
		obj = document.getElementById(objName);
    	while(obj.offsetParent != null){
      		x += obj.offsetLeft;
      		obj = obj.offsetParent;
    	}
    	x += obj.offsetLeft;
    	return x;
  	}
  	return -1;
}

function getObjPageTop(callingObj, objName) {
  	var y = 0, obj;
	if(NS4){
		if(callingObj.container != null)
	      	return callingObj.container.pageY + callingObj.y;
	    else
	      	return callingObj.y;
	}
  	if(IE4 || NS6){
		obj = document.getElementById(objName);
    	while(obj.offsetParent != null){
      		y += obj.offsetTop;
      		obj = obj.offsetParent;
    	}
    	y += obj.offsetTop;
    	return y;
  	}
  	return -1;
}

