﻿/* =dropdowns/hover for ie - 
needs to be called with the root 
----------------- */

// IE only function
startList = function(elementId) {
	if (document.all && document.getElementById) {
	    navRoot = document.getElementById(elementId);
	    if (!navRoot) {
	        return(false);
	    }
		for (i=0; i<navRoot.childNodes.length; i++) {
		    node = navRoot.childNodes[i];
			if ( (node.nodeName=="LI") || (node.nodeName=="DL") || (node.nodeName=="DD") || (node.nodeName=="DT") ) {
				node.onmouseover = function() {
				    this.className+=" over";
				}
				node.onmouseout = function() {
				    this.className=this.className.replace(" over", "");
				}
			}
		}
	}
} 


function toggleSubMenu(id, allowCollapse)
{
	var submenuDiv = $('#submenu_'+id + 'N');
	var submenuArrow = $('#submenu_arrow_'+id + 'N');
	
	if(submenuDiv.css("display") == "block" && allowCollapse == true)
	{
		submenuArrow.attr("src", "/SiteCollectionImages/navigation/arrow_down.gif");
		submenuArrow.attr("alt", "Expand");
		submenuDiv.slideUp(function() { submenuDiv.css("display", "none"); });
	}
	else
	{
		submenuArrow.attr("src", "/SiteCollectionImages/navigation/arrow_up.gif");
		submenuArrow.attr("alt", "Collapse");
		submenuDiv.slideDown(function() { submenuDiv.css("display", "block"); });
	}
}


function menuExpand(id)
{
   	var submenuDiv = $('#submenu_'+id + 'N');
	var submenuArrow = $('#submenu_arrow_'+id + 'N');

    if (submenuDiv.css("display") != "block")
    {
        submenuArrow.attr("src", "/SiteCollectionImages/navigation/arrow_up.gif");
	    submenuArrow.attr("alt", "Collapse");
	    submenuDiv.slideDown(function() { submenuDiv.css("display", "block"); });
	}
}

function menuCollapse(id)
{
	var submenuDiv = $('#submenu_'+id + 'N');
	var submenuArrow = $('#submenu_arrow_'+id + 'N');

    if (submenuDiv.css("display") != "none")
    {
	    submenuArrow.attr("src", "/SiteCollectionImages/navigation/arrow_down.gif");
	    submenuArrow.attr("alt", "Expand");
	    submenuDiv.slideUp(function() { submenuDiv.css("display", "none"); });
	}
}


/*
    function toggleMenu(expand, id)

    Adds time delay to the calling of the menuExpand() and menuCollapse() functions
    as there are of a lot of unnecessary events triggered when the cursor is draged of the menu
*/
var _previousId = 0;
var _iTimer;

function toggleMenu(expand, id)
{
    clearTimeout(_iTimer);
    
    if (_previousId == 0)
    {
        _previousId = id;
    }
    
    // force collapse any previously opened menu 
    // as the event buffer may have cancelled the timeout
    // before the menuCollapse() has been called.		
    if (id != _previousId)
    {
        menuCollapse(_previousId);
    }		
    		
    _previousId = id;
        
    if(expand)
    {
	    _iTimer = setTimeout( "menuExpand('" + id + "')" , 200);
	}
	else
	{
	    _iTimer = setTimeout( "menuCollapse('" + id + "')", 200);
	}
}





