// check browser version

NS4 = (document.layers) ? 1 : 0;

//// Don't change these parameters
var delay  = 500; /////
var active_layer_id = -1;  /////
var on_layer_id  = -1;  /////
var buff_id  = -1;  /////
/// ----------------------------

function calMenuPos(divId){
		var intOffsetX = 175
		var myWidth = 0, myHeight = 0;
		if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
			var menuXpos = (myWidth/2-intOffsetX);
			document.getElementById(divId).style.left = menuXpos
			} 
		else {
			if(document.documentElement &&	(document.documentElement.clientWidth || document.documentElement.clientHeight)){
				//IE 6+ in 'standards compliant mode'
				myWidth = document.documentElement.clientWidth;
				myHeight = document.documentElement.clientHeight;
				var menuXpos = (myWidth/2-intOffsetX);
				document.getElementById(divId).style.left = menuXpos
			} 
			else{
				if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
					//IE 4 compatible
					myWidth = document.body.clientWidth;
					myHeight = document.body.clientHeight;
					var menuXpos = (myWidth/2-intOffsetX);
					document.all[divId].style.left = menuXpos
					}
				}
			}		
		}



function layer_enter (id)

{

	on_layer_id = id;

}

function layer_exit (id)

{

	on_layer_id = - 1;

	setTimeout ('hide('+ id +')', delay/5);
	
}

function menu_enter (id)

{

	
	if (buff_id >= 0)

		hide (buff_id);

	// POSITION MENU
	calMenuPos('Menu'+id)

	show (id);

	active_layer_id = id;

}

function menu_exit (id)

{

		
	setTimeout ('hide('+ id +')', delay);

	buff_id = active_layer_id;

	active_layer_id = -1;

}

function show (id)

{

	if (!NS4)

		//document.all['Menu' + id].style.visibility = "visible";
		document.getElementById('Menu' + id).style.visibility = "visible";

	else

		document.layers[id].visibility = "visible";
}

function hide (id)

{

	if (active_layer_id != id && on_layer_id != id)

	{

		if (!NS4)

			//document.all['Menu' + id].style.visibility = "hidden";
			document.getElementById('Menu' + id).style.visibility = "hidden";

		else

			document.layers[id].visibility = "hide";

	}

}

var agent = navigator.userAgent.toLowerCase();
macs = (agent.indexOf("mac")!=-1) ? true : false

function changeClass(cellid,strNewClass){	
	alert(cellid)
	if(!macs){
		document.getElementById(cellid).className=strNewClass;
		}
	}

