function HideDropDowns() {
	for (var f=0; f<window.document.forms.length; f++) {
		var theForm = window.document.forms[f];
		for (var e=0; e<theForm.elements.length; e++) {
			var theElem = theForm.elements[e];
			if ((theElem.type.substr(0,6) == "select") && (theElem.className.search("pageoptions") != -1)) {
				theElem.style.visibility = 'hidden';
			}
		}
	}
}

function ShowDropDowns()
{
	for (var f=0; f<window.document.forms.length; f++) {
		var theForm = window.document.forms[f];
		for (var e=0; e<theForm.elements.length; e++) {
			var theElem = theForm.elements[e];
			if ((theElem.type.substr(0,6) == "select") && (theElem.className.search("pageoptions") != -1)) {
				theElem.style.visibility = 'visible';
			}
		}
	}
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function HeaderLoginKeyPress(e) {
    //alert(e);
    
    if ((e.which == 13) || (e.keyCode == 13)) {
        document.getElementById("globalheaderLoginForm").submit();
    }
    return true;
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function HeaderLoginSubmit()
{
    document.getElementById("globalheaderLoginForm").submit();
    return true;
}


//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function NavMenu(htmlID, navLinkID) {
    this.htmlID = htmlID;
    this.navLinkID = navLinkID
    this.items = new Array();
    this.AddNavMenuItem = AddNavMenuItem;
    
    if(!window.navMenus) {
        window.navMenus = new Array();
    }
    window.navMenus[window.navMenus.length] = this;
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function NavMenuItem(htmlID, label, href) {
    this.htmlID = htmlID;
    this.label = label;
    this.href = href;
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function AddNavMenuItem(htmlID, label, href) {
    this.items[this.items.length] = new NavMenuItem(htmlID, label, href); 
}


//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function WriteNavMenus() {
    if(window.navMenus) {
        for (var i = 0; i < window.navMenus.length; i++) {
            WriteNavMenu(window.navMenus[i]);
        }
    }
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function WriteNavMenu(menu) {
    if(menu.items.length > 0) {
        document.write("<div id=\"" + menu.htmlID + "\" class=\"navmenu\" onmouseover=\"ShowNavMenu('" + menu.htmlID + "', '" + menu.navLinkID + "')\" onmouseout=\"HideNavMenus()\" style=\"display:none;\">\n");
        for (var i = 0; i < menu.items.length; i++) {
            WriteNavMenuItem(menu.items[i]); 
        }
        document.write("<\/div>\n");
    }
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function WriteNavMenuItem(menuItem) {
    document.write("<div class=\"navmenuitem\" onmouseover=\"MenuItemMouseOver(this)\" onmouseout=\"MenuItemMouseOut(this)\" onclick=\"MenuItemClick('" + menuItem.href + "')\">");
    if (menuItem.htmlID) {
        document.write("id=\"" + menuItem.htmlID + "\" ");
    }
    document.write(menuItem.label + "<\/div>\n");
}

//-----------------------------------------------------------------------------
// used to display single menu items
//-----------------------------------------------------------------------------
function ShowNavItem(navLinkID) {
    if (navigator.appName.indexOf("Microsoft Internet Explorer") == 0)
		ShowDropDowns();
		
	// clear open drop down menus
    if(window.activeNavMenu) {
        HideActiveMenu();
    }
    
    // clear prior active menu item
    if(window.activeNavLink) {
        window.activeNavLink.className = "navlink";
    }

	// activate selected menu item    
    window.activeNavLink = document.getElementById(navLinkID);
    window.activeNavLink.className = "navlink_selected";
    
}

//-----------------------------------------------------------------------------
// used to hide single menu items
//-----------------------------------------------------------------------------
function HideNavItems() {
    SetNavItemTimeout();
    return true;
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function HideNavItem() {
    if (navHideFlag && window.activeNavLink) {
        HideActiveMenu();
        if (navigator.appName.indexOf("Microsoft Internet Explorer") == 0)
			ShowDropDowns();
   }
}

//-----------------------------------------------------------------------------
// used to display drop down menu lists
//-----------------------------------------------------------------------------
function ShowNavMenu(id, navLinkID) {
	if (navigator.appName.indexOf("Microsoft Internet Explorer") == 0)
		HideDropDowns()
    
    var menu;
    menu = document.getElementById(id);     
    
    if(window.activeNavMenu && (window.activeNavMenu.id != id)) {
        HideActiveMenu();
    }
    
    if(window.activeNavLink) {
        window.activeNavLink.className = "navlink";
    }
    
    window.activeNavLink = document.getElementById(navLinkID);
    window.activeNavLink.className = "navlink_selected";
    
    if(menu) {
        ClearNavMenuTimeout();
        window.activeNavMenu = menu;
        window.activeNavMenu.style.display = "block";
    }
}

//-----------------------------------------------------------------------------
// used to hide drop down menu lists
//-----------------------------------------------------------------------------
function HideNavMenus() {
    SetNavMenuTimeout();
    return true;
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function HideNavMenu() {
    if (navHideFlag && window.activeNavMenu) {
        HideActiveMenu();
        
        if (navigator.appName.indexOf("Microsoft Internet Explorer") == 0)
			ShowDropDowns();
    }
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function HideActiveMenu() {
    if (window.activeNavMenu) {
        window.activeNavMenu.style.display = "none";
    }
    window.activeNavMenu = null;

    if(window.activeNavLink) {
        window.activeNavLink.className = "navlink";
    }
    window.activeNavLink = null;
    
    navHideFlag = false;
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function ClearNavMenuTimeout() {
    navHideFlag = false;
    if (window.menuHideTimer) {
        window.clearTimeout(window.menuHideTimer);
    }
    window.menuHideTimer = null;
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function SetNavMenuTimeout() {
    navHideFlag = true;
    window.menuHideTimer = window.setTimeout("HideNavMenu()", 250);
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function SetNavItemTimeout() {
    navHideFlag = true;
    window.menuHideTimer = window.setTimeout("HideNavItem()", 250);
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function MenuItemMouseOver(item) {
    if(window.activeNavMenuItem) {
        window.activeNavMenuItem.className = "navmenuitem";
    }
    window.activeNavMenuItem = item;
    window.activeNavMenuItem.className = "navmenuitem_selected";
    return true;
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function MenuItemMouseOut(item) {
    if(window.activeNavMenuItem) {
        window.activeNavMenuItem.className = "navmenuitem";
    }
    return true;
}

function MenuItemClick(url) {
    window.location = url;
    return true;
}

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
var navHideFlag = false;

