/**
 * Shorthand for document.getElementById
 */
function $(elem) { return document.getElementById(elem); }

/**
 * This function creates a loading queue for the page and adds events to it. 
 * Using this function is a good idea when you need to load a lot of different
 * things along side the page.
 */
function addLoadEvent(func) {
	var oldonload = window.onload;

	if (typeof window.onload != 'function')
		window.onload = func;
	else
		window.onload = function() {
			oldonload();
			func();
		}
}

sfHover = function() {
	if(document.getElementById("nav")){
		var sfEls = document.getElementById("nav").getElementsByTagName("li");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
				//showHideForms('hidden');
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(/sfHover/gi, "");
				//showHideForms('visible');
			}
			t=sfEls[i].getElementsByTagName("ul");
			if(t.length&&!sfEls[i].id){
				sfEls[i].className+=" submenu";
				t[0].style.marginTop = "-"+(sfEls[i].offsetHeight)+"px";	
			}
		}
	}
}

addLoadEvent(sfHover);