// JavaScript Document
/*
	menu.js
	
	Javascript to enable the pop-up menus on PayrollExpressinc.com website.
	Both the main navigation menu and the contact menu will be enabled by
	this program.
	
	Created:	2009-08-28
	Author:		Weston Henry <wes.henry@ignus.com>
	Copyright:	2009 Ignus Technologies
	
*/

var delay = 300;
var overLeftMenu = false;
var overMenuList = false;
var overMenu = false;

function enableMenus() {
	// enable the mouseover events for our menus
	document.getElementById("leftMenu").onmouseover = function() {	overLeftMenu = true;
																	display('menu');
																	hide('contactOver'); }

	document.getElementById("menu").onmouseover = function() {		overMenu = true;
																	display('menu');
																	hide('contactOver'); }

	document.getElementById("menu-list").onmouseover = function() {	overMenuList = true;
																	display('menu');
																	hide('contactOver'); }

	document.getElementById("contact").onmouseover =  function() {	display('contactOver');
																	hide('menu'); }
	// mouseout events to close the menus	
	document.getElementById("leftMenu").onmouseout = function() {	overLeftMenu = false;
																	menuHideLater( ); }

	document.getElementById("menu").onmouseout = function() {		overMenu = false;
																	menuHideLater( ); }

	document.getElementById("menu-list").onmouseout = function() {	overMenuList = false;
																	menuHideLater( ); }
																
	document.getElementById("contactOver").onmouseout = function() { contactHideLater( ); }
}

function menuHideLater( ) {
	setTimeout( hideMenu, delay );
}

function contactHideLater( ) {
	setTimeout( hideContact, delay );
}

function hideMenu( ) {
	if ( overLeftMenu || overMenuList || overMenu ) {
		// don't hide if we're still over part of the menu
	} else {
		hide( 'menu' );
	}
}

function hideContact( ) {
	hide('contactOver');
}

function display( elementId ) {
	document.getElementById( elementId ).style.display = "block";
}

function hide( elementId ) {
	document.getElementById( elementId ).style.display = "none";
}