/*
 *
 *	@titre: layout.
 *	@description: javascript layout - Le Cidre.
 *	@auteur: neov - http://www.neov.net.
 *	@creation: 20100621.
 *	@modification: 20100621.
 *
*/

/* embed main flash */
var flashvars = {};
var params = {};
params.scale = 'noscale' ;
params.devicefont = false ;
params.allowScriptAccess = 'sameDomain' ;
params.quality = 'high' ;
params.allowFullScreen = true ;
params.wmode = 'transparent' ;
params.menu = false ;
params.movie = 'fond' ;

var attributes = {name: 'fond'};

if (FlashDetect.versionAtLeast(10, 1))
{
	swfobject.embedSWF('design/swf/fond.swf', 'mainFlash', '100%', '100%', '10.1', 'expressInstall.swf', flashvars, params, attributes);
}

/* set bloc size */
var initTopHeight = 80 ;
var bottomMinHeight = 83;

$.fn.setSize = function(time)
{
	var windowHeight = $(window).height() ;
	/*
	var bottomHeight = $('#page-bottom').hasClass('hidden')? 0 : $('#page-bottom').height() ;
	var pos = 0;
	
	if (windowHeight - bottomHeight > initTopHeight)
		pos = windowHeight - bottomHeight ;
	else
		pos = initTopHeight ;
	*/
	if($('#page-bottom').hasClass('hidden'))
	{
		pos = windowHeight ;
	} else if ($('#content-inner').hasClass('empty')) {
		pos = windowHeight - bottomMinHeight ;
	} else {
		pos = initTopHeight ;
	}
	$('#page-top').animate({height: pos}, time) ;
}

function toggleMenu(status)
{
	if(status==0)
	{
		$('#page-bottom')
			.addClass('hidden')
			.hide(0) ;
		$().setMenu (0) ;
	} else {
		
		$('#page-bottom')
			.removeClass('hidden')
			.show(0) ;

		// $('#compte-layer').show () ;

		var currWindowHeight = $(window).height() ;
		$('#page-top').css({height: currWindowHeight - bottomMinHeight}) ;

		var zLocation = document.location.href ;
		var oPageRegEx = /(html?([#][^#]+)?$)|(cidre[.]php(\/.+)?)/i ;
		if (oPageRegEx.test (zLocation))
		{
			$().loadAjaxContent(zLocation) ;
		}
		
	}
}

function checkNavigationView ()
{
	if ($('#content-inner').hasClass('empty'))
	{
		return 2;
	} else {
		return 1;
	}
}



// -- ALLER VERS UN ANCRE DANS LA PAGE
function scrollToAnchor (_zAnchorId)
{
    $('html,body').animate ({scrollTop: $("#" + _zAnchorId).offset ().top}, 'slow') ;
}


$(
	function()
	{
		
		$('#content-inner').addClass('empty');
		
		toggleMenu (0) ;
		
		var initWindowHeight = $(window).height() ;
		$('#page-top').css({height: initWindowHeight}) ;
		
		$(window).resize(
			function()
			{
				$().setSize(0) ;
			}
		);
	}
) ;

function clickFlash(){
	$('.backHome').eq(0).click();
}
