﻿// Navigation Bar Javascript File
<!--

    var currentDropMenu = null;

    //occurs when they hover over an element
	function onMainSelectionHover( element )
	{
	    element.style.backgroundColor = "#a6b3a7";
	    element.style.cursor = "pointer";
	    
	    showSubMenu( element );
	}

    //occurs when they stop hovering over an element
	function onMainSelectionReset( element )
	{
	    element.style.backgroundColor = element.style.borderColor;
	    element.style.cursor = "auto";
	    
	    hideSubMenu( element );
	}

    //used when the user clicks on a navigation menu item that will change the navbar
    // ------------------------------------------------- DEPRECATED
    function onSelectionMade( keyValue )
    {
        hiddenField = document.getElementById("OperationMode");
        
        if ( hiddenField != null )
        {
            hiddenField.value = keyValue;
            document.getElementById("form1").submit();
        }
        else
            alert(hiddenField.value);
    }
    // ------------------------------------------------- DEPRECATED
    
    //used when the user clicks on a navigation menu item that opens a new location in the current browser window
	function onSelectionBrowse( urlStr )
	{
	    if ( urlStr.length > 0 )
	    {
	        window.location = urlStr;
	    }
	}
    //used when the user clicks on a navigation menu item that opens a new location in a new browser window
	function onSelectionPopup( urlStr )
	{
	    if ( urlStr.length > 0 )
	    {
	        window.open(urlStr);
	    }
	}
		
	//shows a popup menu for sub-elements
	function showSubMenu( element )
	{
	    //this offset is used because IE does not calculate the X,Y properly
	    var IEoffset = 0;
	    if (IsIE4Up())
	        IEoffset = 10;
	    
	    for(var i = 0; i  < element.childNodes.length; i++)
	    {
		    if(element.childNodes.item(i).nodeName == "DIV"
                && element.childNodes.item(i).className == "NavBar-PopupLevel")			
		    {
		        currentDropMenu = element.childNodes.item(i);
		        dropMenuParent = element;

                currentDropMenu.style.display = "block";
        		
		        currentDropMenu.style.top = GetElementYPos(dropMenuParent) + IEoffset + "px";
		        currentDropMenu.style.left = GetElementXPos(dropMenuParent) + GetElementWidth(dropMenuParent) + IEoffset + "px";        		
		    }		
	    }	
    }
    
    //hides the popup menu that occurs on sub-elements
    function hideSubMenu( element )
    {								
	    for(var i = 0; i  < element.childNodes.length; i++)
	    {
		    if(element.childNodes.item(i).nodeName == "DIV"
                && element.childNodes.item(i).className == "NavBar-PopupLevel")			
		    {			
			    element.childNodes.item(i).style.display = "none";			
			    return;
		    }			
	    }	
    }
    
    //check to see if the browser is IE 4 or above
    function IsIE4Up()
    {
        var userAgent=navigator.userAgent.toLowerCase();
        var major = parseInt(navigator.appVersion); 
        
        if (userAgent.indexOf("msie") != -1)
        {
            if (major >= 4)
                return true;
        }
        
        return false;
    }
    
	//retrieves the client width of the browser, works with IE5+, NS6+ and Firefox1+
	function GetClientWidth()
	{
	    if (window.innerWidth!=window.undefined) return window.innerWidth; 
	    if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth; 
	    if (document.body) return document.body.clientWidth; 
	    
		return screen.x;
	}		
	
	//retrieves the client height of the browser, works with IE5+, NS6+ and Firefox1+
	function GetClientHeight()
	{
	    if (window.innerHeight!=window.undefined) return window.innerHeight;
	    if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
	    if (document.body) return document.body.clientHeight; 
	    
		return screen.y;
	}	
	
	function GetMouseX(parentObj)
	{
	    // Detect if the browser is IE or not.
        // If it is not IE, we assume that the browser is NS.
        var IE = document.all?true:false
        // Temporary variable to hold mouse x pos.
        var tempX = 0

        if (IE)
        {   // grab the x pos if browser is IE
            tempX = event.clientX + document.body.scrollLeft;
        }
        else
        {   // grab the x pos.s if browser is NS
            tempX = GetElementXPos(parentObj) + 20;
        } 
        // catch possible negative values in NS4
        if (tempX < 0) tempX = 0
        
        return tempX
	}
	
	function GetMouseY(parentObj)
	{
		// Detect if the browser is IE or not.
        // If it is not IE, we assume that the browser is NS.
        var IE = document.all?true:false
        // Temporary variable to hold mouse y pos.
        var tempY = 0

        if (IE)
        {   // grab the y pos if browser is IE
            tempY = event.clientY + document.body.scrollTop;
        }
        else
        {   // grab the y pos.s if browser is NS
            tempY = GetElementYPos(parentObj);
        }  
        // catch possible negative values in NS4
        if (tempY < 0) tempY = 0
        
        return tempY
	}
	
	//retrieves the left position of the given element, works with IE5+, NS6+ and Firefox1+
	function GetElementXPos(obj)
	{
		var xPos = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
			    if (obj.tagName == 'BODY')
			        break;
			        
				xPos += obj.offsetLeft;
				obj = obj.offsetParent;
			}
		}
		else if (obj.x)
			xPos += obj.x;
		return xPos;
	}

	//retrieves the top position of the given element, works with IE5+, NS6+ and Firefox1+
	function GetElementYPos(obj)
	{
		var yPos = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
			    if (obj.tagName == 'BODY')
			        break;
			
				yPos += obj.offsetTop;
				obj = obj.offsetParent;
			}
		}
		else if (obj.y)
			yPos += obj.y;
		return yPos;
	}
	
	//retrieves the width of the given element, works with IE5+, NS6+ and Firefox1+
	//in NS and firefox, it may only return the visible width of the element
	function GetElementWidth(obj)
	{
	    var width = 0;

        if(obj.scrollWidth)
		    width =  obj.scrollWidth;
	    else if(obj.scrollOffsetWidth)
		    width =  obj.scrollOffsetWidth;
	    else if(obj.offsetWidth)
		    width =  obj.offsetWidth;
	    else if(obj.width)
		    width =  obj.width;

		return width;
	}
	
	//retrieves the height of the given element, works with IE5+, NS6+ and Firefox1+
	//in NS and firefox, it may only return the visible height of the element
	function GetElementHeight(obj)
	{
	    var height = 0;

	    if(obj.scrollHeight)
		    height = obj.scrollHeight;
	    else if(obj.scrollOffsetHeight)
		    height = obj.scrollOffsetHeight;
	    else if(obj.offsetHeight)
		    height = obj.offsetHeight;
	    else if(obj.height)
		    height = obj.height;

		return height;
	}
	
	//retrieves the verticle scrolling position, from the top of the document, works with IE5+, NS6+ and Firefox1+
	function GetScrollYOffset()
	{
	    if (document.compatMode=='CSS1Compat') return document.documentElement.scrollTop; 
		if(document.body.scrollTop) return document.body.scrollTop;
		if(window.pageYOffset) return window.pageYOffset;
		
		return 0;
	}
	
	//retrieves the horizontal scrolling position, from the left side of the document, works with IE5+, NS6+ and Firefox1+
	function GetScrollXOffset()
	{
	    if (document.compatMode=='CSS1Compat') return document.documentElement.scrollLeft; 
		if(document.body.scrollLeft) return document.body.scrollLeft;
		if(window.pageXOffset) return window.pageXOffset;
		
		return 0;
	}
-->