/************************************************************************************/
/*  Created by:  Richard R. Beavo, rrb@advancedprogramsolutions.com					*/
/*  Date:  December 12, 2001		Last Update:  October 7, 2004					*/
/*  Required File:  DOM.js															*/
/*  This script, along with the STYLES and event handlers will produce a series of	*/
/*  hidden Sub-Menus that appear and disappear with the use of the event handlers.	*/
/************************************************************************************/

var iMenuOpen = null;			// Menu number that is open (0-iNumberOfMenus | null)
var iHide = 0;					// The Hide function to perform
var iDelay = 2;					// Delay time in tenths of a second
var iCounter = 0;				// Counter of the delay cycles
var aSubMenus = new Array();

function initSubMenus() {
	for(i = 0; i < initSubMenus.arguments.length; i+=2) {
		aSubMenus[aSubMenus.length] = new addSubMenu(initSubMenus.arguments[i], initSubMenus.arguments[i+1]);  //if DIV tags are stacked, left value is outer Element ID; if not, leave undefined
	}
}

function addSubMenu(sElementID1, sElementID2) {
   	this.css = (sElementID1) ? oDOM.findDOM(sElementID1, sElementID2, 1) : oDOM.findDOM('', sElementID2, 1);
	this.hideIt = hideItFunction;
	this.showIt = showItFunction;
	return this;
}

function showItFunction(){this.css.display="block";}
function hideItFunction(){this.css.display="none";}

function showSubMenu(iMenuNum) {
	if(oDOM.bIsDHTML) {
		iHide = 2;
		if(iMenuOpen != null) {
			aSubMenus[iMenuOpen].hideIt();
			iHide = 2;
			iCounter = 0;
		}
		if(iMenuOpen != iMenuNum) {
			aSubMenus[iMenuNum].showIt();
			iMenuOpen = iMenuNum;
		} else {iMenuOpen = null;}
	} else {return null;}
}

function hideSubMenu(){
	if((iMenuOpen != null) && (iHide == 0)) {
		aSubMenus[iMenuOpen].hideIt();
		iMenuOpen = null;
		iCounter = 0;
		return false;
	}
	if(iHide == 2) {iCounter = 0; return false;}
	if(iHide == 1) {
		iCounter = iCounter + 1;
		if(iDelay <= iCounter) {iHide = 0;}
		if(iDelay >= iCounter) {setTimeout('hideSubMenu(' + iHide + ')', 100);}
	}
}

