/* Permet d'afficher les flyovers */
function screenFlyover( popup, param, param2, param3 ) {

	/* On récupére en ajax les données et on les affiches dans la div contenuAjoutePopup */
	//$.scrollTo( "contenuPopup", {duration:10} );
	$(".loading").show();
	$("#background_Flyover").show();
	
		$(".bg_white").css({
			"left"				:	"50%",
			"margin-left"		:	"-"+(parseInt( $(".bg_white").width()/2 )+"px"),
			"top"				:	"50%",
			"margin-top" 		: 	"-"+(parseInt( $(".bg_white").height() / 2 )+"px")
		});

		$(".bg_white").css("margin-top", ( parseInt($(".bg_white").css("margin-top")) + ($(window).scrollTop()) )+"px");
				
	$(".bg_white").show();
	
if ( popup == "popup_be" ) {
	var res = "<div><a href='http://etoillespromo.canderel.be'><img src='/images/BE/popup/FR/2010-03-19_popup.jpg' /></a><a href='#' onclick='closeFlyover(); return false;'><img style='position:absolute; top:4px; right:3px;' src='/images/BE/home/close.png' /></a></div>";
} 	
else if ( popup == "popup_holland" ) {
	var res = "<div><a href='http://sterrenactie.canderel.nl'><img src='/images/NL/popup/2010-03-19_popup.jpg' /></a><a href='#' onclick='closeFlyover(); return false;'><img style='position:absolute; top:4px; right:3px;' src='/images/BE/home/close.png' /></a></div>";
}else {

	$.ajax({
		type: "post",
		async: true,
		url: "/popup/"+popup+".html",
		data:  param,
		success: function(res) {
			
			$("#background_Flyover .loading").hide();

			$("#content_Flyover").html(res);

			$("#content_Flyover").css({
				"left"				:	"50%",
				"margin-left"		:	"-"+(parseInt( $("#content_Flyover").width()/2 )+"px"),
				"top"				:	"50%",
				"margin-top" 		: 	"-"+(parseInt( $("#content_Flyover").height() / 2 )+"px")
			});

			/* Permet de mettre la popup au coin supèrieure si cette dernière est plus grande que la taille de l'écran */
			if ( $(window).height() <= $("#content_Flyover").height() ) {
				var diffSize = ( parseInt($("#content_Flyover").height() / 2) - parseInt($(window).height() / 2 ) );
				$("#content_Flyover").css("margin-top",parseInt($("#content_Flyover").css("margin-top")) + diffSize + 20);
				$("#content_Flyover").css("padding-bottom","20px");
			} 
			
			/* Permet de le centrer par rapport au scrool */
			$("#content_Flyover").css("margin-top", ( parseInt($("#content_Flyover").css("margin-top")) )+"px");
			
			/* Permet d'agrandir le background_Flyover */
				if ( $("body").height() > $(window).height() ) {
					sizeBackgroundFlyover = $("body").height();
				} else {
					sizeBackgroundFlyover = $(window).height();
				}
				
				$("#background_Flyover").height( sizeBackgroundFlyover );
			
			$("#background_Flyover .bg_white").hide();
			$("#background_Flyover .loading").hide();
			$(".flyover").show();
			
		}
	});
		
		
}
			
		$(".loading").hide();

			$("#content_Flyover").html(res);
			if( $.browser.msie && $.browser.version.search( /6/ ) != -1 ) {
				pngFix();
			}

		$("#content_Flyover").css({
			"left"				:	"50%",
			"margin-left"		:	"-451px",
			"top"				:	"50%",
			"margin-top" 		: 	"-251px"
		});

		/* Permet de mettre la popup au coin supèrieure si cette dernière est plus grande que la taille de l'écran */
		if ( $(window).height() <= $("#content_Flyover").height() ) {
			var diffSize = ( parseInt($("#content_Flyover").height() / 2) - parseInt($(window).height() / 2 ) );
			$("#content_Flyover").css("margin-top",parseInt($("#content_Flyover").css("margin-top")) + diffSize + 20);
			$("#content_Flyover").css("padding-bottom","20px");
		} 
		
		/* Permet de le centrer par rapport au scrool */
		$("#content_Flyover").css("margin-top", ( parseInt($("#content_Flyover").css("margin-top")) + ($(window).scrollTop()) )+"px");
		
		/* Permet d'agrandir le background_Flyover */
			$("#background_Flyover").height( $("body").height() );
		
		$(".bg_white").hide();
		$(".loading").hide();
		$(".flyover").show();

		$("#background_Flyover").click( function () {
			// closeFlyover();
		});
		
}

/* Permet de fermer un flyover */
	function closeFlyover() {
		$(".flyover").hide();
	}