// JavaScript Document

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

function addSearchTextToUrl (txt) 
{
	if(document.searchform.field.value == "" || document.searchform.field.value == "Search") return false;
	document.searchform.action = document.searchform.action + "?search=" + document.searchform.field.value;
	return true;
}

// Collapsable side nav
function collapse(sender)
{ 
    var subNav = document.getElementById('subNav');
    var navs = subNav.getElementsByTagName('ul');
    
    for(i = 0; i < navs.length; i++)
    {
        if((navs[i].style['display'] == 'block') && (navs[i].style['visibility'] == 'visible'))
        {
            navs[i].style['display'] = 'none';
            navs[i].style['visibility'] = 'hidden'
        }
        
        var expander = sender.parentNode.getElementsByTagName('ul');
        
        if(expander != 'undefined' || expander == null)
        {
            expander[0].style['display'] = 'block';
            expander[0].style['visibility'] = 'visible' 
        }
    }
   
    if(sender.stopPropagation)
    { 
        sender.stopPropagation();
    }
    else
    {
        sender.cancelBubble = true;
    }
    
    return false;
} 