/*
	Menu Controls v 1.0
	by Cary Clayton <cclayton@epierce.com>
	and Matt Cannon <mcannon@epierce.com>
*/

var DEBUG_MENU = false;
//=========================commented until pop up menu is done===================================
//var MENUS_ACTIVE = (is.version4);
var MENUS_ACTIVE = true;
//=========================commented until pop up menu is done===================================

var POPPED = false;
var ON_MENU = false;
var CURRENT_MENU = "";
var CURRENT_LEVEL1 = "";
var CURRENT_LEVEL2 = "";  
var CURRENT_TOP = ""; 
var thisagt=navigator.userAgent.toLowerCase();
	
setInterval("cleanUpMenus()",30000);
showGlobals();

function getMenuObject(id){
	var o = null;
	
		if (document.getElementById) { //W3C
			o = document.getElementById(id); 				
		}
		else if(document.all) { //IE4
			o = document.all[id];			
		}
		else if(document.layers) { //NN4
			o = document.layers[id];			
		}
	return o;
}

function showGlobals(){
	if (DEBUG_MENU) {
		var global_variables = "Global Variables:\n";
		global_variables += "\nMENUS_ACTIVE - "+MENUS_ACTIVE;
		global_variables += "\nPOPPED - "+POPPED;
		global_variables += "\nON_MENU - "+ON_MENU;
	}
}

function mouseOver(object,object1) {	

	if (MENUS_ACTIVE) {
   	ON_MENU = true;
	CURRENT_MENU = object;
		if (CURRENT_LEVEL1 != '' && CURRENT_LEVEL1 != CURRENT_MENU) {
			menuDown(CURRENT_LEVEL1);
		}	
		CURRENT_LEVEL1 = CURRENT_MENU;
		return popUp(object);
	}
	return false;
}
function mouseOut(object) {
	//if (DEBUG_MENU) {alert("mouseout()");}
	if (MENUS_ACTIVE) {
		ON_MENU = false;
		setTimeout('cleanUpMenus()',3500);
	}
	return false;
}

function popUp(object){
	if (MENUS_ACTIVE) {
//	if (DEBUG_MENU) {alert("popUp('"+object+"')");}
		return menuUp(object);
	}
	return false;
}

function popDown() {
	if (MENUS_ACTIVE) {
	if (CURRENT_LEVEL1 != '') {
			menuDown(CURRENT_LEVEL1);
			CURRENT_LEVEL1 = '';
		}	
	}
	return false;
}

function menuUp(object) {
	if (MENUS_ACTIVE) {
//		if (DEBUG_MENU) {alert("menuUp('"+object+"')");}
		var span = getMenuObject("span_"+object);
		var div = getMenuObject("div_"+object);
		var divUP = false;
		var spanUP = false;
		if (div != null) {show(div);divUP = true;}
		if (span != null) {show(span);spanUP = true;}
		
		POPPED = (spanUP && divUP);
		
	}
	return false;
}

function menuDown(object) {
	if (MENUS_ACTIVE) {
	//	if (DEBUG_MENU) {alert("menuDown('"+object+"')");}
		var span = getMenuObject("span_"+object);
		var div = getMenuObject("div_"+object);
		if (div != null) {hide(div);}
		if (span != null) {hide(span);}
	}
	return false;
}

function cleanUpMenus() {
	if (MENUS_ACTIVE) {
		if (!ON_MENU) {
			popDown();
			}
	}
	return true;
}

function show(o){
	if (document.layers) {
		o.visibility = 'show';
		o.zIndex = '100';	//need to set zIndex for NS 4.x			
	}
	else {
		o.style.visibility = 'visible';		
		if ((thisagt.indexOf("mac")!=-1) && (thisagt.indexOf("msie") != -1) && (thisagt.indexOf("opera") == -1)){
			o.style.zIndex = '100';		//need to set zIndex for MAC IE!!!	
		}
	}
}

function hide(o){
	var toClass = (o.id.indexOf("span") >= 0) ? "menulineoff" : "menupopupoff";
	if (document.layers) {
		o.visibility = "hide";		
	}
	else {
		o.style.visibility = "hidden";	
	}
}
