
$( document ).ready(
	function( )
	{
		$( "#header ").bind( "click", menuClick );
		createMenu( );
		loadPage( );
	}
);

function createMenu( )
{
	$( "img.menu" ).bind( "mouseover", menuMouseOver );
	$( "img.menu" ).bind( "mouseout", menuMouseOut );	
	$( "img.menu" ).bind( "click", menuClick );
}

function menuClick( )
{
	//$("#content").slideUp( "slow" );
	//$("#wlayer").fadeIn( "slow" );
}

function menuMouseOver( )
{
	$( "#puce_" + this.name ).css( "visibility", "visible" );
}

function menuMouseOut( )
{
	var id = getID( );
	
	if ( this.name != id || id == 0 )
	{
		$( "#puce_" + this.name ).css( "visibility", "hidden" );
	}
}

function getID( )
{
	var id = 500;
	
	searchTerm = "page=";
	searchTermIndex = window.location.href.indexOf( searchTerm );
	
	if ( searchTermIndex != -1 )
	{
		id = parseInt( window.location.href.substr( searchTermIndex + searchTerm.length ) ) || 0;
	}
	
	return id;
}

function loadPage( )
{
		var id = getID( );

		if ( id != 0 )
		{
			$( "#puce_" + id ).css( "visibility", "visible" );
		}
		
		$( "body" ).css( "backgroundImage", "url('themes/default/images/" + id + ".png')" );
		
		if ( id == 7 )
		{
			$( "body" ).css( "backgroundColor", "#EE4623" );
		}
		else if ( ( id == 0 ) || ( id == 1 ) || ( id == 2 ) || ( id == 101 ) || ( id == 129 ) || ( id == 127 ) ||
			( id == 501 ) || ( id == 503 ) || ( id == 505 ) || ( id == 506 ) || ( id == 509 ) || ( id == 511 ) || ( id == 513 ) || ( id == 515 ) )
		{
			$( "body" ).css( "backgroundColor", "#000000" );
		}
		else
		{
			$( "body" ).css( "backgroundColor", "#FFFFFF" );
		}
		
		changeContainerBackground( id );
		
		if ( id == 2 )
		{
			initSlideshow( );
		}
		
		if ( id == 4 )
		{
			initSlideshow2( );
		}
		
		$( "#content" ).show( );//slideDown( "slow" );
		$( "#wlayer" ).hide( );//fadeOut( "slow" );	
}

function changeContainerBackground( id )
{
	if( id == 500 )
	{
		$( "#container" ).css( "height", 730 );
		$( "#container" ).css( "backgroundImage", "url(themes/default/images/background5.jpg)" );

		if ( !( $.browser.msie && $.browser.version < 7 ) )
		{
			$( '<img src="themes/default/images/background5extension.png" style="position:absolute; z-index:100; right:0; top:-120px;" />').appendTo( '#container' );
		}
	}
	else if( id == 101 )
	{
		$( "#container" ).css( "backgroundImage", "url(themes/default/images/bg_1.png)" );
	}
	else
	{
		$( "#container" ).css( "backgroundImage", "none" );
	}
}