// http://www.sitepoint.com/blogs/2004/05/26/closures-and-executing-javascript-on-page-load/
function addLoadEvent(func)
{ 
	var oldonload = window.onload; 
	if (typeof window.onload != 'function')
		window.onload = func; 
	else
	{
		window.onload = function()
		{ 
			oldonload(); 
			func(); 
		}
	}
}

function imageRollover(e)
{
	if(!e)
		var e = window.event;
		
	if(e.type == "mouseover")
		this.src = this.src.replace("-off.", "-on.");
		
	else if(e.type == "mouseout")
		this.src = this.src.replace("-on.", "-off.");
}

function registerRollovers()
{
	/* Kentico can't do hovers on a CSS menu and I don't like the workaround (http://devnet.kentico.com/Knowledge-Base/Design-and-css/OnMouseOver-design-in-CSS-List-Menu-web-part--CSS-.aspx) so just leaving them off for now. Would need to have an ID assigned to the image to use the method used for headerLogo and signUpNow. */
	
	var headerLogo	= document.getElementById("header-logo");
	var signUpNow	= document.getElementById("sign-up-now");	
	
	headerLogo.onmouseover	= imageRollover;
	headerLogo.onmouseout	= imageRollover;
	signUpNow.onmouseover	= imageRollover;
	signUpNow.onmouseout	= imageRollover;
}

// http://fightingforalostcause.net/techblog/preloading-images/
function preloadImages()
{
	document.getElementById("header-logo").style.background	= "url(images/header/mpango-cms-on.png) no-repeat -500px -500px";
	document.getElementById("sign-up-now").style.background	= "url(images/header/sign-up-now-on.png) no-repeat -500px -500px";
}

addLoadEvent(function()	{ 
	registerRollovers();
	preloadImages();
} );