<!-- ----------- START OF proScootMenu.js ------- -->
/*********************************************************************************************
 * DOCUMENTATION FOR proScootMenu.JS v 1.1
 *********************************************************************************************
 *                     JAVASCRIPT Requirements:
 *********************************************************************************************
 *
 * INCLUDE:
 * <script language="JavaScript" src="proScootMenu.js"></script>
 *
 *********************************************************************************************/

function MenuHider()
{
	this.mostCurrentId = 0;
	this.timerIsOn = true;
	this.elementIdsOn
	this.activeMenuId;
	this.menuIdsCurrentlyActive = new Array();
	this.menuIdsCurrentlyInactive = new Array();
    this.cancelFlashTab = false;

	this.mousedOver_ShowThisElement = function(elementIdToShow)
	{
		this.stopTimer();
		this.refreshMenuLists(elementIdToShow);

		this.hideAllElementsInInactiveList();
	}

	this.mousedOut = function()
	{
        window.setTimeout('scootsTimer.startTimer(300)', 500);        
	}

	//  ==============================
	// |  ==========================  |
	// | |      PRIVATE FUNCTIONS   | |
	// |  ==========================  |
	//  ==============================

	//  -----------------------------------------------
	// | START TIMER
	// | - call on all "mouseout"s
	//  -----------------------------------------------
	this.startTimer = function(miliseconds)
	{
		//if was already started.. then reset
		this.mostCurrentId++		//makes all old events invalid
		this.timerIsOn = true;

		delayedExecuteString = "scootsTimer.hideAllMenus('" + this.mostCurrentId + "')";

		//if stopped, then start
        if (!this.cancelFlashTab)        
            window.setTimeout(delayedExecuteString, miliseconds);
	}

	//  -----------------------------------------------
	// | STOP TIMER
	// | - call on all "mouseover"s
	//  -----------------------------------------------
	this.stopTimer = function()
	{
		//stop all timers
		this.mostCurrentId++;		//makes all old events invalid
		this.timerIsOn = false;
	}

	//  -----------------------------------------------
	// | HIDE ALL MENUS
	//  -----------------------------------------------
	this.hideAllMenus = function(eventId)
	{

		//if the eventId is the most current.. then hide the list
		if (eventId == this.mostCurrentId)
		{
			//alert("hiding all menus:: stored[" + eventId + "] = actual[" + this.mostCurrentId + "]");
			this.timerIsOn = false;

			//add the active list to the inactive list
			this.moveAllElementsFromActiveToInactiveList();
			this.hideAllElementsInInactiveList();
		}

		//alert("active: \n" + this.menuIdsCurrentlyActive.length + "\n\n" + "inactive: \n" + this.menuIdsCurrentlyInactive.length);
	}

	//compare the active list to the new active list..
	//if the id isnt in the new list, move it to the "inactive" list.
	//finally, set the "new list" as the "Active list"
	this.refreshMenuLists = function(elementIdToShow)
	{
		//if the id was "".. then set active menus list to empty array
		newestActiveMenus = this.getListOfParentIdsIncludingSelf(elementIdToShow);

		while ((this.menuIdsCurrentlyActive).length > 0)
		{
			elementIdInLimbo = this.menuIdsCurrentlyActive.pop()

			//if not in newest active List.. add it inactive List
			if (this.indexOfItemInList(newestActiveMenus, elementIdInLimbo) == -1)
			{
				this.menuIdsCurrentlyInactive.push(elementIdInLimbo);
			}
		}

		this.menuIdsCurrentlyActive = newestActiveMenus;
	}

	this.indexOfItemInList = function(theList, item)
	{
		for (i = 0; i < theList.length; i++)
		{
			if (item == theList[i])
				return i;
		}

		return -1;
	}

	this.getListOfParentIdsIncludingSelf = function(elementIdToShow)
	{
		idList = new Array();
		parentOffset = 0;

		lengthOfPrefix = 7;
		indexDigits = 4 + 1;

		var splitString = elementIdToShow.split("_");
		//alert(splitString);

		while (splitString.length > 1)
		{
			idList.push("sublist" + elementIdToShow.substring(lengthOfPrefix, elementIdToShow.length - parentOffset));

			lastChild = splitString.pop();		//take off child

			parentOffset += (lastChild.length + 1);		//"_####"
		}

		return idList;
	}

	this.moveAllElementsFromActiveToInactiveList = function()
	{
		while (this.menuIdsCurrentlyActive.length > 0)
		{
			tempElement = this.menuIdsCurrentlyActive.pop();
			this.menuIdsCurrentlyInactive.push(tempElement);
		}
	}

	this.hideAllElementsInInactiveList = function()
	{
		while (this.menuIdsCurrentlyInactive.length > 0)
		{
			elementIdInLimbo = this.menuIdsCurrentlyInactive.pop()

			// hide element
			var childElement 			= getChildElement(elementIdInLimbo);

			if (childElement != null) {
				childElement.style.visibility = "hidden";
			}
		}
	}
}
//////////////////////////////////////////////////////////////////////////////////////////


function PositionObject(top, left)
{
	this.top 	= top;
	this.left	= left;
}

var absolutePositions = new Array();
absolutePositions['49']		= new PositionObject(117,0);
absolutePositions['806'] 	= new PositionObject(117,93);
absolutePositions['173'] 	= new PositionObject(117,186);
//absolutePositions['183'] 	= new PositionObject(117,279);
//absolutePositions['182'] 	= new PositionObject(117,279);
//absolutePositions['racing'] = new PositionObject(117,465);
absolutePositions['182'] 	= new PositionObject(117,372);
absolutePositions['racing'] = new PositionObject(117,279);
absolutePositions['43'] 	= new PositionObject(20,400);		//??

function rootsShowChild(parentElementId)
{
	scootsTimer.mousedOver_ShowThisElement("subcell_" + parentElementId)

	var childElement 			= getChildElement("12345678" + parentElementId);

	//position this child absolutely based on config
	var left 					= absolutePositions[parentElementId]['left'];
	var top 					= absolutePositions[parentElementId]['top'];
	var width 					= 0;

	private_showElement(childElement, top, left);
}

function showChild(parentElementId)
{
	scootsTimer.mousedOver_ShowThisElement(parentElementId)

	////////////////////////////////////////////////////////
	// show element
	////////////////////////////////////////////////////////
	var parentElement 			= document.getElementById(parentElementId);
	var childElement 			= getChildElement(parentElementId);

	//position this child relative to the parent
	var width 					= parentElement.offsetWidth;
	var pageLeft				= getPageOffsetLeft(parentElement);
	var pageTop					= getPageOffsetTop(parentElement);

	var left					= pageLeft + width - 0;
	var top						= pageTop - 1;

	private_showElement(childElement, top, left);
}

function private_showElement(element, top, left)
{
	element.style.position = "absolute";
	element.style.left 	= left;
	element.style.top 		= top;
	element.style.visibility = "visible";
}

function showLeaf(parentElementId)
{
	scootsTimer.mousedOver_ShowThisElement(parentElementId)
}

function rootsHideChild()
{
	scootsTimer.mousedOut();
}

function hideChild()
{
    scootsTimer.cancelFlashTab = false;
	scootsTimer.mousedOut();
}

//////////////////////////////////////////////////////////////////////////
// the colors.. and style
//////////////////////////////////////////////////////////////////////////
var lastItemOn = "";

function scoot_turnItemOn(element)
{
	if (lastItemOn != element)
	{
		lastItemOn.className = "dd_list";
		element.className = "dd_list_over";
		lastItemOn = element;        
	}
    scootsTimer.cancelFlashTab = true;
}

//////////////////////////////////////////////////////////////////////////
// PRIVATE FUNCTIONS.. PURELY ALGORITHM/CALCULATION FUNCTIONS
//////////////////////////////////////////////////////////////////////////
//get the parent's sublist/submenu/child from its id
//- when you mouseover.. it will give you its own id..
//		ex: subcell_49_479"
//- you want to convert that id to the id you want to show..
//		ex: sublist_49_479"
function getChildElement(parentId)
{
	var parentIdLength 			= parentId.length;

	var childId 				= "sublist_" + parentId.substring(8, parentIdLength);
	var childElement			= document.getElementById(childId);

	//alert("parsed child id: " + childId + "\nelement's id: " + childElement.id);

	return childElement;
}

//////////////////////////////////////////////////////////////////////////
// PURELY HTML INFO FUNCTIONS.. GETTING INFO ON HTML ELEMENTS
//////////////////////////////////////////////////////////////////////////
function getPageOffsetLeft(el) {

	var x;

	// Return the x coordinate of an element relative to the page.

	x = el.offsetLeft;
	if (el.offsetParent != null)
	{
		x += getPageOffsetLeft(el.offsetParent);
	}
	return x;
}

function getPageOffsetTop(el) {

	var y;

	// Return the x coordinate of an element relative to the page.

	y = el.offsetTop;
	if (el.offsetParent != null)
	{
		y += getPageOffsetTop(el.offsetParent);
	}

	return y;
}

var scootsTimer = new MenuHider();

<!-- ----------- END OF proScootMenu.js ------- -->

<!-- helper functions for the top menu -->
function loadFlash()
{
	playmovie();
	window.setTimeout("force_playmovie()", 800);
}


function thisMovie(movieName) {
	// IE and Netscape refer to the movie object differently.
	// This function returns the appropriate syntax depending on the browser.
	if (navigator.appName.indexOf ("Microsoft") !=-1) {
		return window[movieName]
	}
	else {
		return document[movieName]
	}
}

// Checks if movie is completely loaded.
// Returns true if yes, false if no.
function movieIsLoaded (theMovie) {

	// First make sure the movie's defined.
	if (typeof(theMovie) != "undefined") {
		// If it is, check how much of it is loaded.
		return theMovie.PercentLoaded() == 100;
	}
	else {
		// If the movie isn't defined, it's not loaded.
		return false;
	}
}

function playmovie() {
	var movieName = "proarmor-topmenu";

	if (movieIsLoaded(thisMovie(movieName))) {
		thisMovie(movieName).Play();
	}
}
/*
function force_playmovie() {
	var movieName = "proarmor-topmenu";

	thisMovie(movieName).Play();
}
*/

<!-- END OF helper functions for the top menu -->