var currentMenu = null;
var menu = null;
var intMenuTimer;
var intTimeoutID;

if (!document.getElementById)
    document.getElementById = function() { return null; }

function initializeMenu(menuId, actuatorId) {
    
    var menu = document.getElementById(menuId);
    var actuator = document.getElementById(actuatorId);
    
    if (menu == null || actuator == null) return;
	
	menu.onmouseout = function() {
		if (currentMenu == null) {
			intTimeoutID = window.setTimeout("destroyMenu()",500);
		}
    }
    
    menu.onmouseover = function() {
		window.clearTimeout(intTimeoutID);
    }
    
    menu.onmousemove = function() {
		window.clearTimeout(intTimeoutID);
    }
	
    actuator.onmouseover = function() {
	
		window.clearTimeout(intTimeoutID);
		
		//Check to see if no menu has been selected, if not - display the current one selected
		if (currentMenu == null) {
			this.showMenu();
        }
		
		//If a menu is already active and a new one is selected, hide the old display the new
        if (currentMenu) {
            currentMenu.style.visibility = "hidden";
            this.showMenu();
        }
    }
    
    //This function will destroy the current menu with the menubar loses focus
    actuator.onmouseout = function() {
   		intTimeoutID = window.setTimeout("destroyMenu()",500);
    }
	
	actuator.onmousemove = function() {
		window.clearTimeout(intTimeoutID);
    }
	
    actuator.onclick = function() {
        
        if (currentMenu == null) {
			this.showMenu();
        }
        else {
			currentMenu.style.visibility = "hidden";
            currentMenu = null;
        }
    }
	
    actuator.showMenu = function() {
		
		menu.style.left = "32px";
		menu.style.top = "35px";
        menu.style.visibility = "visible";
        currentMenu = menu;
    }
}

var intOpacity = 50
var objImage, objBrowser, hightlighting;

function destroyMenu() {
	
	if (currentMenu != null) {
		
		if (document.all) { 
			//Internet Explorer Section
			//Get the element that was click to call this function. 
			var strCurrentElement;
			strCurrentElement = document.activeElement.name;
			
			if (strCurrentElement == null) {
				//Kill the menu...
				currentMenu.style.visibility = "hidden";
				currentMenu = null;
			}
			else if (strCurrentElement.substring(0,3) != "btn") {
				//Kill the menu...
				currentMenu.style.visibility = "hidden";
				currentMenu = null;
			}		
		}
		else if (document.layers) {
			//Netscape 4+
			currentMenu.style.visibility = "hidden";
			currentMenu = null;
		}
		else if (document.getElementById) {
			//Netscape 6+
			currentMenu.style.visibility = "hidden";
			currentMenu = null;
		} 
	}
}

function resetTimer() {
	if (window.highlighting) {
		clearInterval(highlighting)
	}
}

function loadIFrame(strFrameName, strURL) {
	if ( window.frames[strFrameName] ) {
		window.frames[strFrameName].location = strURL;
		if (currentMenu != null) {
			currentMenu.style.visibility = "hidden";
			currentMenu = null;
		}
		return false;
	}
	else {
		return true;
	}
}

