
	//the below array corresponds to the first folder of the URL path - to add a new persistent nav page (where a 
	//top-level menu item remains highlighted), create the appropriate nav elements (in lttop.php), then add the
	//path name here. if nav elements are created without adding a path name to the array, the menu will fade out 
	//after the delay timer expires as opposed to snapping back to the persistent element
	
	var persistentMenuSelectionIDs = ["about", "samples", "pricing", "scheduling"];
	var killTimer, currentPersistentElementID, timedFunction = "";
	var selectedTextColor = "rgb(51, 51, 51)";
	var selectedTextColorIE = "#333"; //of course IE represents this differently
	var overlayFadeInTime = 0;
	var overlayFadeOutTime = 0;
	var subNavFadeInTime = 0;
	var subNavFadeOutTime = 0;


	function applyStyles(elementToStyle) {
	    elementToStyle.css({ background: 'url(./images/LinkGrayBackground.png)' });
	    elementToStyle.css({ color: '#333' });
	}
	
	function highlightPersistentElement() {
	    applyStyles($('#' + currentPersistentElementID + ' > a'));
	    $('#' + currentPersistentElementID + ' a').next().fadeIn(subNavFadeInTime);

	    //clear any residual timers that may try to deselect the persistent element
	    $('body').stopTime('hide');
	}
	function revertTopStyles(revertElementId) {
	    $('#' + revertElementId + ' > a').css({ background: 'url()' });
	    $('#' + revertElementId + ' > a').css({ color: '#444' });
	}

	function revertAllTopStyles() {
	    $('.SiteMenuTopButtonlink').css({ background: 'url()' });
	    $('.SiteMenuTopButtonlink').css({ color: '#444' });
	}


	function hideSubMenuAndRevertAllTopStyles() {
	    $('.SiteMenuSubListWrapper').fadeOut(subNavFadeOutTime);
	    revertAllTopStyles();
	}
	
	function hideAll() {
	    $('#PageGrayBackground').fadeOut(overlayFadeOutTime);
	    hideSubMenuAndRevertAllTopStyles();
	}

	function mouseOutDelayedExecute() {
	    $('body').oneTime(1000, 'hide', function() {
	        eval(timedFunction);
	    });
	}

	function hideAllButPersistentElement() {
	    for (var i in persistentMenuSelectionIDs) {
	        if (currentPersistentElementID == persistentMenuSelectionIDs[i]) {
	            continue; 
	        }

	        revertTopStyles(persistentMenuSelectionIDs[i]);
	    }

	    $('.SiteMenuSubListWrapper').fadeOut(subNavFadeOutTime);
	    highlightPersistentElement();
	}


	$(document).ready(function() {
	    //check the url for a persistent ID - the menu will behave differently if one is found
	    currentPersistentElementID = location.href.split("/")[3].replace("?", "").replace("=", "");

	    for (var i in persistentMenuSelectionIDs) {
	        if (currentPersistentElementID == persistentMenuSelectionIDs[i]) {
	            highlightPersistentElement();
	            break;
	        }
	    }

	    //determine the correct hide function to call based on menu type - add some additional handling 
	    //for mousing out of the persistent element (to stop it from reloading)
	    if (typeof (currentPersistentElementID) == "undefined" || currentPersistentElementID == "") {
	        timedFunction = "hideAll()";
	    }

	    else {
	        timedFunction = "hideAllButPersistentElement()";

	        $('#' + currentPersistentElementID).mouseout(function() {
	            $('body').oneTime(1, 'hide', function() {
	                $('body').stopTime('hide');

	                //if at this point the persistent element isn't highlighted, restart the timer to highlight it
	                //(addresses an obscure bug where if the user mouses out of a non-persistent element very quickly 
	                //into and out of a link in the submenu of the persistent element, the menu will not snap back)
	                if ($('#' + currentPersistentElementID + ' a').css("color") != selectedTextColor &&
					   $('#' + currentPersistentElementID + ' a').css("color") != selectedTextColorIE)
	                { mouseOutDelayedExecute(); }
	            });
	        });
	    }

	    //attach event to main top-level menu item elements
	    $('.SiteMenuTopButtonlink').mouseover(function() {
	        $('body').stopTime('hide');

	        //prevent a menu element from being refreshed if it is moused over, then off, then back over
	        if ($(this).css("color") == selectedTextColor || $(this).css("color") == selectedTextColorIE) {
	            return;
	        }

	        hideSubMenuAndRevertAllTopStyles();

	        //the overlay should only fade back in for the non-persistant menu as it is present all the time 
	        //in the persistent menu
	        if (typeof (currentPersistentElementID) == "undefined" || currentPersistentElementID == "") {
	            $('#PageGrayBackground').fadeIn(overlayFadeInTime); 
	        }

	        //fade in the submenu and apply styles to the currently selected top-level menu button element
	        $('#' + $(this).attr('id')).next().fadeIn(subNavFadeInTime);
	        applyStyles($('#' + $(this).attr('id')));
	    });

	    //attach appropriate events to menu elements - a timer runs for 1 second before closing the menu, 
	    //unless it it cancelled by a mouse action over another element
	    $('.mouseovertimerelement').mouseover(function() {
	        $('body').stopTime('hide');
	    });

	    $('.mouseouttimerelement').mouseout(function() {
	        mouseOutDelayedExecute();
	    });
	});
	
