/* ---------------------------------------------------------------------------------------- *\
|*	menu.js																					*|
|*	Main menu routines																		*|
|*	© Copyright 2008, 2009 Mynor Ramos.  All rights reserved.								*|
\* ---------------------------------------------------------------------------------------- */

/*
	Control variables for drop down menu
*/
var beddingMenuActive= false;
var beddingMenuTimeOutId = 0;
var curtainsMenuActive= false;
var curtainsMenuTimeOutId = 0;
var kitchenMenuActive= false;
var kitchenMenuTimeOutId = 0;
var bathMenuActive= false;
var bathMenuTimeOutId = 0;
var carpetsMenuActive= false;
var carpetsMenuTimeOutId = 0;
var kidsMenuActive= false;
var kidsMenuTimeOutId = 0;
var clothingMenuActive= false;
var clothingMenuTimeOutId = 0;

/*
	Time out for each menu to disappear
*/
var menuTimeOut = 250;

/*
	shows each menu as requested by flash menu
*/
function showMenu(menu, show)
{
	var dropDownMenu = document.getElementById(menu);
	
	window.status = menu;
	
	if (show == "visible") { // the user hovers over the menu button
		switch (menu) {
			case "ddmBedding":
				if (!beddingMenuActive) { // if the menu isn't already showing
					dropDownMenu.style.visibility = "visible"; // show it
					dropDownMenu.focus();
					beddingMenuActive = true; // the menu is shown
				} else { // if the menu is shown, most likely it's entering back before the hide code runs
					window.clearTimeout(beddingMenuTimeOutId); // clear the timeout so the menu doesn't hide
				}
				break;
				
			case "ddmCurtains":
				if (!curtainsMenuActive) { // if the menu isn't already showing
					dropDownMenu.style.visibility = "visible"; // show it
					dropDownMenu.focus();
					curtainsMenuActive = true; // the menu is shown
				} else { // if the menu is shown, most likely it's entering back before the hide code runs
					window.clearTimeout(curtainsMenuTimeOutId); // clear the timeout so the menu doesn't hide
				}
				break;
				
			case "ddmKitchen":
				if (!kitchenMenuActive) { // if the menu isn't already showing
					dropDownMenu.style.visibility = "visible"; // show it
					dropDownMenu.focus();
					kitchenMenuActive = true; // the menu is shown
				} else { // if the menu is shown, most likely it's entering back before the hide code runs
					window.clearTimeout(kitchenMenuTimeOutId); // clear the timeout so the menu doesn't hide
				}
				break;
				
			case "ddmBath":
				if (!bathMenuActive) { // if the menu isn't already showing
					dropDownMenu.style.visibility = "visible"; // show it
					dropDownMenu.focus();
					bathMenuActive = true; // the menu is shown
				} else { // if the menu is shown, most likely it's entering back before the hide code runs
					window.clearTimeout(bathMenuTimeOutId); // clear the timeout so the menu doesn't hide
				}
				break;
				
			case "ddmCarpets":
				if (!carpetsMenuActive) { // if the menu isn't already showing
					dropDownMenu.style.visibility = "visible"; // show it
					dropDownMenu.focus();
					carpetsMenuActive = true; // the menu is shown
				} else { // if the menu is shown, most likely it's entering back before the hide code runs
					window.clearTimeout(carpetsMenuTimeOutId); // clear the timeout so the menu doesn't hide
				}
				break;
				
			case "ddmKids":
				if (!kidsMenuActive) { // if the menu isn't already showing
					dropDownMenu.style.visibility = "visible"; // show it
					dropDownMenu.focus();
					kidsMenuActive = true; // the menu is shown
				} else { // if the menu is shown, most likely it's entering back before the hide code runs
					window.clearTimeout(kidsMenuTimeOutId); // clear the timeout so the menu doesn't hide
				}
				break;
				
			case "ddmClothing":
				if (!clothingMenuActive) { // if the menu isn't already showing
					dropDownMenu.style.visibility = "visible"; // show it
					dropDownMenu.focus();
					clothingMenuActive = true; // the menu is shown
				} else { // if the menu is shown, most likely it's entering back before the hide code runs
					window.clearTimeout(clothingMenuTimeOutId); // clear the timeout so the menu doesn't hide
				}
				break;
				
		}
	} else {
		switch (menu) {
			case "ddmBedding":
				// hide the menu and deactivate it
				beddingMenuTimeOutId = window.setTimeout("document.getElementById('" + menu + "').style.visibility = 'hidden'; beddingMenuActive = false;", menuTimeOut);
				break;
				
			case "ddmCurtains":
				// hide the menu and deactivate it
				curtainsMenuTimeOutId = window.setTimeout("document.getElementById('" + menu + "').style.visibility = 'hidden'; curtainsMenuActive = false;", menuTimeOut);
				break;
				
			case "ddmKitchen":
				// hide the menu and deactivate it
				kitchenMenuTimeOutId = window.setTimeout("document.getElementById('" + menu + "').style.visibility = 'hidden'; kitchenMenuActive = false;", menuTimeOut);
				break;
				
			case "ddmBath":
				// hide the menu and deactivate it
				bathMenuTimeOutId = window.setTimeout("document.getElementById('" + menu + "').style.visibility = 'hidden'; bathMenuActive = false;", menuTimeOut);
				break;
				
			case "ddmCarpets":
				// hide the menu and deactivate it
				carpetsMenuTimeOutId = window.setTimeout("document.getElementById('" + menu + "').style.visibility = 'hidden'; carpetsMenuActive = false;", menuTimeOut);
				break;
				
			case "ddmKids":
				// hide the menu and deactivate it
				kidsMenuTimeOutId = window.setTimeout("document.getElementById('" + menu + "').style.visibility = 'hidden'; kidsMenuActive = false;", menuTimeOut);
				break;
				
			case "ddmClothing":
				// hide the menu and deactivate it
				clothingMenuTimeOutId = window.setTimeout("document.getElementById('" + menu + "').style.visibility = 'hidden'; clothingMenuActive = false;", menuTimeOut);
				break;
				
		}
	}
	
	return true;
}

/*
	Executes flash menu requests and calls function to show each menu
*/
function flashMenu_DoFSCommand(command, args)
{
	// if we are using IE, the object will be flashMenu itself, otherwise, use document
	flashMenuObj = (MSIE) ? flashMenu : document.flashMenu;
	
	showMenu(command, args);
}