// Initialize events that must load after page contents

var init = function ()
{
	$("#messageBox").each( function ()
	{
		var marginleft = (-1*($(this).width()/2))+"px";
		$(this).css({"margin-left" : marginleft, "left" : "50%", "top" : "0"});
	});
	setTimeout("$('#messageBox').fadeOut()", 4000);
	hoverInit();
	$("ul.topnav li").hover(function(event)
		{
			$(this).children("ul.subnav").each(function()
				{
					if (event.type == 'mouseout' || event.type == 'mouseleave')
					{
						$(this).slideUp('fast').hide();
					}
					else if (event.type == 'mouseover' || event.type == 'mouseenter')
					{
						$(this).slideDown('fast').show();	
					}
				});
		});
	$("ul.topnav ul.subnav").hover(function(event)
		{
			$(this).parent().children("li a").each(function()
				{
					if (event.type == 'mouseout' || event.type == 'mouseleave')
					{
						$(this).css("background-color", "");
						$(this).css("color", "");
					}
					else if (event.type == 'mouseover' || event.type == 'mouseenter')
					{
						$(this).css("background-color", "#356185");
						$(this).css("color", "#ffffff");
					}					
				});
		});
}

window.onload = init;
