function doSomething(x) {
	if (x=="nav_contact") c="current_contact"; 
	else if (x=="nav_home") c="current_home";
	else c="current";
	var y=document.getElementById('nav').className;
	if (y)	document.getElementById(y).className="nav";
	document.getElementById(x).className=c;
	document.getElementById('nav').className=x;
}

function gotoSermon() {
  var x=document.getElementById("sermonLists")
  if(x.selectedIndex==0) y=1;
  if(x.selectedIndex==1) window.location="/resources/sermons/sermon-series/";
  if(x.selectedIndex==2) window.location="/resources/sermons/sermon-category/";
  if(x.selectedIndex==3) window.location="/resources/sermons/sermon-months/";
  if(x.selectedIndex==4) window.location="/resources/sermons/sermon-preachers/";
}

addEvent(window, 'load', navHover);
function navHover(){
	var lis = document.getElementById('nav').getElementsByTagName('LI');
	var active = getElementsByClassName(document.getElementById('nav'), 'li', 'current')[0];

	for(var i=0; i<lis.length; i++){
		lis[i].onmouseover = function(){						
			var self = this;
			for(var a=0; a<lis.length; a++){			
				
				if(self == lis[a] || self == lis[a].parentNode.parentNode){				
					
					// keep the current item in view
					if(self.getElementsByTagName('UL')[0]) self.getElementsByTagName('UL')[0].style.left = '0px';
					if(lis[a].parentNode == 'ul') { 
						lis[a].parentNode.style.left = '0px';
						lis[a].parentNode.style.top = '32px';
					}
					
					// remove all other "current" classes from other lis
					for(var b=0; b<lis.length; b++){
						if(lis[b] != self) lis[b].className = '';
					}
					
				} else if(self != lis[a]) {				
					if(lis[a].getElementsByTagName('UL')[0]) lis[a].getElementsByTagName('UL')[0].style.left = '-5000px';				
				
					if(lis[a].className == 'active'){
						if(lis[a].getElementsByTagName('UL')[0]) lis[a].getElementsByTagName('UL')[0].style.left = '-5000px';
					}
				}																
			}						
		}
		
		lis[i].onmouseout = function(){			
			var self = this;
			if(this != active){
				if(self.getElementsByTagName('UL')[0]) self.getElementsByTagName('UL')[0].style.left = '-5000px';				
			} 
			if(active) {
				active.className = 'current'; 
				if(active.getElementsByTagName('UL')[0]) active.getElementsByTagName('UL')[0].style.left = '0px';
			}
			/*
			if(active.length > 0){
				if(active[0].getElementsByTagName('UL')[0]) active[0].getElementsByTagName('UL')[0].style.left = '18px';
				active[0].className = 'current';
			}
			*/
		}		
	}
}


function addEvent(obj, evType, fn){
    if (obj.addEventListener) {
        obj.addEventListener(evType, fn, true);
        return true;
    } else if (obj.attachEvent) {
        var r = obj.attachEvent("on"+evType, fn);
        return r;
    } else {
	    return false;
    }
}

/*
    Written by Jonathan Snook, http://www.snook.ca/jonathan
    Add-ons by Robert Nyman, http://www.robertnyman.com
*/

function getElementsByClassName(oElm, strTagName, strClassName){
    var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for(var i=0; i<arrElements.length; i++){
        oElement = arrElements[i];      
        if(oRegExp.test(oElement.className)){
            arrReturnElements.push(oElement);
        }   
    }
    return (arrReturnElements)
}