var NS = (navigator.appName == "Netscape");
mac = navigator.appVersion.indexOf("Mac");
if (mac>=0) {mac=1} else {mac=0}
IE4 = document.all; NS4 = document.layers; NS6a = document.getElementById
if(NS6a && NS) {NS6=1} else {NS6=0}
if ((IE4) || (NS6) && (mac != 1)) {dhtml=1;} // Taking out Netscape 4 for now(NS4) || 

if(NS4){ origWidth = innerWidth ; origHeight = innerHeight; pageurl = self.location;}

///////////////////
function re(){
	if(NS4){
		if (innerWidth != origWidth || innerHeight != origHeight){ 
			//top.location.replace(pageurl) 
			location.reload(true) 
		}
	}
}
window.onResize = re;

if(NS4){
	origWidth = innerWidth;origHeight = innerHeight;
}
	
px=""; menuOn=-1; menuht=92; menuwt=0; ext=0; layerLeftPos=0; flashPresent=0; gatewayLock=-1;
layerDims_y=new Array ; layerDims_x=new Array

function refConstructor(menuId){
	if (NS6) {var prefix = "document.getElementById('menu" + menuId + "')"}
	if (IE4) {var prefix = "document.all.menu" + menuId}
	if (NS4) {var prefix = "document.menu" + menuId}
	return prefix;
}

function refConstructorEventDD() {
	if (NS6) {var eventDropDown = "document.getElementById('eventDD')"}
	if (IE4) {var eventDropDown = "document.all.eventDD"}
	if (NS4) {var eventDropDown = "document.eventDD"}
	return eventDropDown;
}
	
function menuInit(){
	for (layerInit = 0;layerInit<3;layerInit++){
	var layerRef =  refConstructor(layerInit)
	layerDims_y[layerInit]  = (IE4 || NS6) ? eval(layerRef + ".offsetHeight + menuht") : eval(layerRef + ".clip.height + menuht")
	layerDims_x[layerInit]  = (IE4 || NS6) ? eval(layerRef + ".offsetWidth + 5") : eval(layerRef + ".clip.width + 5")
	}
}

function reportEvent(cc){ 
	layerLeftPos  =  (IE4) ? (event.x) - 50 : (cc.pageX) - 50
	var layerRef =  refConstructor(menuOn)
	mousePos_y  =  (IE4) ? event.y + menuht : cc.pageY + menuht
	mousePos_x  =  (IE4) ? event.x : cc.pageX
	yMinPos = (IE4) ? (menuht - document.body.scrollTop - 50) : (menuht- 50);
		
	if((mousePos_y >(layerDims_y[menuOn] + menuht + ext)) || ((mousePos_y - menuht) < yMinPos ) || (mousePos_x < (menuwx - 20)) || (mousePos_x > (layerDims_x[menuOn] + menuwx))){ 
		(IE4 || NS6) ? eval(layerRef + ".style.visibility = 'hidden'") : eval(layerRef + ".visibility = 'hidden'");
		el = refConstructorEventDD();
		if(eval(el)){
			(IE4 || NS6) ? eval(el + ".style.visibility = ''") : eval(el + ".visibility = ''");
		}
		v= menuOn+2;
		if (menuOn+1 != gatewayLock){}
		menuwt=0;
		menuOn=-1;
		if (IE4 || NS6){ 
			document.onmousemove = null;
		}
		else{	
		document.releaseEvents(Event.MOUSEMOVE);
		layerLeftPos=0;
		}
	}
}
/////////////////////////////////////
function move(){
	if (IE4) { document.onmouseover = null }
	else{ document.releaseEvents(Event.MOUSEOVER)};
	var layerRef =  refConstructor(menuOn);
	(IE4 || NS6) ? eval(layerRef + ".style.left =" + layerLeftPos) : eval(layerRef + ".left =" + layerLeftPos);
	(IE4 || NS6) ? eval(layerRef + ".style.visibility = 'visible'") : eval(layerRef + ".visibility = 'visible'");
}

function xx(){
	imgWidth = 0;
	for (imgX=0;imgX<=menuOn;imgX++){
		if(imgX == 1){
			imgWidth = imgWidth + 120;
		}else if(imgX == 2){
			imgWidth = imgWidth + 120;
		}
	}
	layerLeftPos = (126 + imgWidth);
	el = refConstructorEventDD();
	if(eval(el)){
		if(menuOn == 3 || menuOn == 4 || menuOn == 5 || menuOn == 6){
			alert(menuOn);
			(IE4 || NS6) ? eval(el + ".style.visibility = 'hidden'") : eval(el + ".visibility = 'hidden'");
		}else{
			(IE4 || NS6) ? eval(el + ".style.visibility = ''") : eval(el + ".visibility = ''");
		}
	}
	move();
	first=0; 
	menuwx = layerLeftPos;
	if(document.layers){
		document.captureEvents(Event.MOUSEMOVE)
	}
	document.onmousemove = reportEvent;
	ext = 10;
}

function menu(m){
	if (m != menuOn){
		if(dhtml){
			var layerRef =  refConstructor(menuOn)
			if (menuOn != m && menuOn!=-1){
				v2 = menuOn+2;
				if (menuOn+1 != (gatewayLock)) {};
				(IE4 || NS6) ? eval(layerRef + ".style.visibility = 'hidden'") : eval(layerRef + ".visibility = 'hidden'");
			}
		menuOn = m ;
		xx();
		}
	}
}
window.onload = menuInit;