//Config générale récurente
var greyBoxDefaultConfig = {
	/*--Valeurs ci-dessous requises--*/
	duration: 0.6,					//=> Durée totale de l'affichage
	opacity: 0.6					//=> Opacité du fond Overlay
	/*--Options supplémentaires--*/
	//height: 500,					//=> Fixer la hauteur
	//closeText: 'Retour',			//=> Ajouter un texte au bouton "fermer"
	//background: 'green',			//=> Modifier la couleur du fond de l'Overlay
	//style: 'background:red',		//=> Ajouter des styles CSS directement à la greyBox
	//className: 'customize',		//=> Ajouter une Classe CSS
	//data: {id: 12},				//=> Envoyer des données en POST
	/*customFunction: function(){	//=> Exécuter un fonction personnelle à l'affichage de la greyBox
		alert('test');
	}*/
};
//Variable définissant la durée de la transition
var greyBoxEffectDuration = Math.round((greyBoxDefaultConfig.duration*1000)/2);
//Fonctions GREYBOX
function greyBoxShow(b,c,d,a){if(!$("#overlay").length){$("body").append('<div id="overlay" onclick="greyBoxHide();"></div>');if(jQuery.browser.msie&&jQuery.browser.version=="6.0"){$(window).scroll(function(){$("#overlay").css("top",$(window).scrollTop()+"px")})}}if(!$("#greyBox").length){$("body").append('<div id="greyBox"><div class="content" id="greyBoxContent"></div><div onclick="greyBoxHide();" class="close"></div></div>')}if(typeof(a)!="undefined"){if(typeof(a.duration)=="undefined"){greyBoxEffectDuration=Math.round((greyBoxDefaultConfig.duration*1000)/2)}else{greyBoxEffectDuration=Math.round((a.duration*1000)/2)}if(typeof(a.opacity)=="undefined"){a.opacity=greyBoxDefaultConfig.opacity}if(typeof(a.height)=="undefined"&&typeof(greyBoxDefaultConfig.height)!="undefined"){a.height=greyBoxDefaultConfig.height}if(typeof(a.closeText)=="undefined"&&typeof(greyBoxDefaultConfig.closeText)!="undefined"){a.closeText=greyBoxDefaultConfig.closeText}if(typeof(a.background)=="undefined"&&typeof(greyBoxDefaultConfig.background)!="undefined"){a.background=greyBoxDefaultConfig.background}if(typeof(a.style)=="undefined"&&typeof(greyBoxDefaultConfig.style)!="undefined"){a.style=greyBoxDefaultConfig.style}if(typeof(a.className)=="undefined"&&typeof(greyBoxDefaultConfig.className)!="undefined"){a.className=greyBoxDefaultConfig.className}if(typeof(a.loading)=="undefined"&&typeof(greyBoxDefaultConfig.loading)!="undefined"){a.loading=greyBoxDefaultConfig.loading}if(typeof(a.data)=="undefined"&&typeof(greyBoxDefaultConfig.data)!="undefined"){a.data=greyBoxDefaultConfig.data}if(typeof(a.customFunction)=="undefined"&&typeof(greyBoxDefaultConfig.customFunction)!="undefined"){a.customFunction=greyBoxDefaultConfig.customFunction}}else{greyBoxEffectDuration=Math.round((greyBoxDefaultConfig.duration*1000)/2);a=greyBoxDefaultConfig}$("#overlay").removeAttr("style");$("#greyBox .close").html("");$("#greyBox").removeAttr("class");$("#greyBoxContent").removeAttr("style");if(typeof(a.height)!="undefined"&&d!="iframe"&&d!="youtube"&&d!="dailymotion"){$("#greyBoxContent").css("overflow","auto").css("height",a.height+"px")}if(typeof(a.closeText)!="undefined"){$("#greyBox .close").html(a.closeText)}if(typeof(a.background)!="undefined"){$("#overlay").css("background",a.background)}if(typeof(a.style)!="undefined"){$("#greyBoxContent").attr("style",a.style)}if(typeof(a.className)!="undefined"){$("#greyBox").addClass(a.className)}$("#greyBoxContent").html('<div id="greyBoxLoader"></div>');if(typeof(a.loading)!="undefined"){$("#greyBoxLoader").html(a.loading)}$("#greyBox").css("width",c+"px").css("left","-"+(Math.ceil(c/2))+"px");if(typeof(a.customFunction)=="undefined"){switch(d){case"html":var e=function(){$("#greyBoxContent").html(b)};greyBoxDisplay(e,a.opacity);break;case"get":var e=function(){$("#greyBoxContent").load(b)};greyBoxDisplay(e,a.opacity);break;case"post":var e=function(){$.ajax({type:"POST",url:b,data:a.data,success:function(f){$("#greyBoxContent").html(f)}})};greyBoxDisplay(e,a.opacity);break;case"iframe":var e=function(){var f=400;if(typeof(a.height)!="undefined"){f=a.height}$("#greyBoxContent").html('<iframe src="'+b+'" border="0" frameborder="0" width="100%" height="'+f+'" allowTransparency="true"></iframe>')};greyBoxDisplay(e,a.opacity);break;case"youtube":var e=function(){var f=400;if(typeof(a.height)!="undefined"){f=a.height}$("#greyBoxContent").html('<object width="100%" height="'+f+'"><param name="movie" value="http://www.youtube.com/v/'+b+'&hl=fr_FR&fs=1&rel=0&color1=0x006699&color2=0x54abd6"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/'+b+'&hl=fr_FR&fs=1&rel=0&color1=0x006699&color2=0x54abd6" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="100%" height="'+f+'"></embed></object>')};greyBoxDisplay(e,a.opacity);break;case"dailymotion":var e=function(){var f=400;if(typeof(a.height)!="undefined"){f=a.height}$("#greyBoxContent").html('<object width="100%" height="'+f+'"><param name="movie" value="http://www.dailymotion.com/swf/video/'+b+'"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed type="application/x-shockwave-flash" src="http://www.dailymotion.com/swf/video/'+b+'" width="100%" height="'+f+'" allowfullscreen="true" allowscriptaccess="always"></embed></object>')};greyBoxDisplay(e,a.opacity);break;case"image":var e=function(){$("#greyBoxContent").html($("#greyBoxContent").html()+'<img src="'+b+'" alt="" style="display:none;" id="greyBoxImage" />');$("#greyBoxImage").load(function(){$("#greyBoxImage").fadeOut(0);$("#greyBoxLoader").remove();$("#greyBoxImage").fadeIn("medium");$("#greyBox").css("width","auto").css("left","-"+(Math.ceil($("#greyBoxContent").outerWidth()/2))+"px")})};greyBoxDisplay(e,a.opacity);break;default:break}}else{greyBoxDisplay(a.customFunction,a.opacity)}return false}function greyBoxDisplay(b,a){if($("#greyBox").attr("status")!="running"){$("#greyBox").attr("status","running");$(document).scrollTop(0);if(jQuery.browser.msie&&jQuery.browser.version=="6.0"){$("#overlay").css("position","absolute").css("height",$(window).height()+"px");$("#greyBoxLoader").css("height","200px")}$("#overlay").fadeTo(greyBoxEffectDuration,a,function(){$("#greyBox").fadeIn(greyBoxEffectDuration,function(){$("#greyBox").attr("status","done");b()})})}}function greyBoxHide(){if($("#greyBox").attr("status")!="running"){$("#greyBox").attr("status","running");$("#greyBox").fadeOut(greyBoxEffectDuration,function(){$("#greyBox").hide();$("#overlay").fadeOut(greyBoxEffectDuration,function(){$("#greyBox").attr("status","done")})})}};
