function toggleHeader (__toggle) {
	if (__toggle) {
		jQuery('#flashHeader').height(228);
	} else {
		jQuery('#flashHeader').height(296);
	}
	
	// Bug wtf ie7
	jQuery('#menu ul li a').trigger("mouseover");
	jQuery('#menu ul li a').trigger("mouseout");
}

/**********************************************************************
OVERLAY (Bloque l'écran)
**********************************************************************/
function afficherOverlay() {
	jQuery("#formPackages").prepend("<div id=\"overlay\"></div>");
	
	jQuery("#overlay").css("width",jQuery('#formPackages').width()+"px");
	jQuery("#overlay").css("height", jQuery('#main').height()-jQuery('#flashHeader').height()+"px");
	jQuery("#overlay").css("opacity", "0.5");
	jQuery("#overlay").css("display", "block");
	
	
	if((jQuery.browser.msie)&&(jQuery.browser.version < 7)) {
		visibilitySelects("hidden");
	}
}

function cacherOverlay() {
	jQuery("#overlay").remove();
	
	if((jQuery.browser.msie)&&(jQuery.browser.version < 7)) {
		visibilitySelects("visible");
	}
}

function visibilitySelects(visibility){
	jQuery('#resortDropDown').css("visibility",visibility);
	jQuery('#regionDropDown').css("visibility",visibility);
	/*alert(jQuery("select").length);
	jQuery("select").each(function(i){
		alert(visibility);
		jQuery(this).css("visibility", visibility);
		alert('BURNT');
	});*/
}

//***************************************************************************************************************//

function activerTopLayer() {
	//$("body").addClass("wait");
	jQuery("#formPackages").prepend("<div id=\"lightbox\"></div>");
	jQuery("#lightbox").load("package/formNewsletter", function(){
		jQuery("#lightbox").css('z-index',"10001");
		afficherTopLayer();
		
	});
	
	jQuery("#overlay").click(function(){
		cacherTopLayer();
		cacherOverlay();
		$(this).blur();
		return false;
	});
}

function afficherTopLayer() {
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	var largeurLightbox = jQuery("#lightbox").width();
	var hauteurLightbox = jQuery("#lightbox").height();
	var largeurOverlay = jQuery("#overlay").width();
	var hauteurOverlay = jQuery("#overlay").height();
	var marginTop = 100;
	
	var marginLeft = (largeurOverlay/2)-(largeurLightbox/2);
	
		jQuery("#newsLetter_cancel").click(function(){
			jQuery("#overlay").click();
			return false;
		});
	
	jQuery("#lightbox").css("margin-top", marginTop);
	jQuery("#lightbox").css("margin-left", marginLeft);
	jQuery("#lightbox").css("display", "block");
	jQuery("body").removeClass("wait");
	
	jQuery("#lightbox input").eq(0).focus();

}

function cacherTopLayer() {
	//$("body").removeClass("wait");
	jQuery("#lightbox").remove();
}


/**********************************************************************
DIMENSIONS DE L'ÉCRAN
**********************************************************************/
function getPageScroll(){
	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}