// Preload roll-over images
startNewStory = new Image;
startNewStory.src = "/siteflow/images/buttons/startNewStory_on.gif";
createNewStory = new Image;
createNewStory.src = "/siteflow/images/buttons/createNewStory_on.gif";
activateYourAccount = new Image;
activateYourAccount.src = "/siteflow/images/buttons/activateYourAccount_on.gif";
viewFinalStory = new Image;
viewFinalStory.src = "/siteflow/images/buttons/viewFinalStory_on.gif";
accountLogout = new Image;
accountLogout.src = "/siteflow/images/buttons/accountLogout_on.gif";
updateProfile = new Image;
updateProfile.src = "/siteflow/images/buttons/updateProfile_on.gif";
accountLogin = new Image;
accountLogin.src = "/siteflow/images/buttons/accountLogin_on.gif";
clickHereToBegin = new Image;
clickHereToBegin.src = "/siteflow/images/buttons/clickHereToBegin_on.gif";
mainMenu = new Image;
mainMenu.src = "/siteflow/images/buttons/mainMenu_on.gif";
toggleShow = new Image;
toggleShow.src = "/siteflow/images/buttons/contributorInfo-Show-On.gif";
toggleHide = new Image;
toggleHide.src = "/siteflow/images/buttons/contributorInfo-Hide-On.gif";
openInvitations = new Image;
openInvitations.src = "/siteflow/images/buttons/openInvitations_on.gif";

/*
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);

