
jQuery.noConflict();


// Document loaded
jQuery(document).ready(function(){ 
	
	// IE 6 alert, upgrade browser !
	if (jQuery.browser.msie && jQuery.browser.version == '6.0')
	{
		alert("You are using a Microsoft Browsaurius, please upgrade your browser to improve your overall Web Experience.");		
	}
	
	// resolution check
	/*if (screen.width < 1152)
	{
		alert("MortalOnline.com is optimized for a screen resolution greater than  1024*768");				
	}*/
	
	// replace campaign swf
	/*jQuery('#campaign').flash(
		{
			swf: '/swf/campaign/StartCampaign.swf',
			width: 1140,
			height: 350,
			wmode:'transparent'
		}
	);*/
	
	// show subs func
	var showSubMenu = function()
	{
		// stop all animations on element
		jQuery('ul', this).stop();

		// position ul
		var new_pos = (jQuery(this).width() - jQuery('ul', this).width()) / 2;
		jQuery('ul', this).css('left', new_pos + "px");

		// no height saved
		if ( !jQuery('ul', this).data('height') )
		{
			// save original height
			var orgHeight = jQuery('ul', this).height();
			jQuery('ul', this).data('height', orgHeight );
			// set height to 0
			jQuery('ul', this).height( 0+'px');	
		}
		// animate to height
		var endHeight = jQuery('ul', this).data('height');
		jQuery('ul', this).animate( {height: endHeight+'px', opacity:1}, 300 );
	};

	// hide subs func
	var hideSubMenu = function()
	{
		// stop all animations on element
		jQuery('ul', this).stop();
		// animate height to 0
		jQuery('ul', this).animate( {height: 0+'px', opacity:0}, 200 );
	};


	var toggleCallback = function()
	{	
		// ready to animate
		jQuery(this).siblings("a").data('animating', false);
	};


	// show announcement func
	var toggleAnnouncement = function( event )
	{
		event.preventDefault();
		if ( !jQuery(this).data('animating')  )
		{
			
			jQuery(this).data('animating', true);
		
			if ( jQuery(this).data('showing') == true )
			{
				jQuery(this).html("Show");
				jQuery(this).data('showing', false);
				jQuery(this).siblings("div").slideUp(400, toggleCallback);			
			}
			else
			{
				jQuery(this).html("Hide");
				jQuery(this).data('showing', true);
				jQuery(this).siblings("div").slideDown(400, toggleCallback);
			}
		}
	};


	// register submenu handler
	jQuery('#menu td').mouseover( showSubMenu );

	// register submenu handler
	jQuery('#menu td').mouseout( hideSubMenu );
	
	// register announcements handler
	jQuery('.toggle-announcement').click( toggleAnnouncement );
	
	// open first announcement
	jQuery('.toggle-announcement').eq(0).click();
	
	// execute fancybox on fancybox class
	jQuery('a.fancybox').fancybox();
	
}); 

