$(function(){function h(a,c){function h(){clearInterval(l);l=setInterval(function(){idSlide=b==f?-1:b;k=b==f?!1:0==b?!0:k;e.move(k?1:-1)},c.interval)}var e=this;$(this);var f=a.children().length/c.display,m=a.children().outerWidth(!0),b=0,d=0,k=!0,l=!0;this.move=function(g,e){0>=b?b=1:b>f&&(b=f);b=e?g:b+g;0= 1.4")}function pInt(integrer){return parseInt(integrer,10)}$facebox=null;$.facebox=function(settings){new Facebox(settings)};$.fn.facebox=function(settings){settings=typeof settings=="undefined"?{}:settings;$(this).live("click",function(){settings.context=this;new Facebox(settings);return false})};$.facebox.alert=function(settings,timer,callback){if(typeof settings=="string"){settings={alert:timer>=0?timer:4,titre:"Alerte !",url:settings,afterClose:function(){if(typeof callback=="function"){callback()}else{return false}}};$.facebox(settings)}else{return false}};$.facebox.call=function(){if(Facebox.instance){return Facebox.instance.call()}};$.facebox.position=function(speed,type){if(Facebox.instance){return Facebox.instance.__position(speed,type)}};$.facebox.startLoading=function(){if(Facebox.instance){return Facebox.instance.loading(1)}};$.facebox.stopLoading=function(){if(Facebox.instance){return Facebox.instance.loading(0)}};$.facebox.parent=function(){if(Facebox.instance){return Facebox.stack[1]}};$.facebox.close=function(){if(Facebox.instance){return Facebox.instance.close("method.close")}};$.facebox.prevStep=function(){if(Facebox.instance){return Facebox.instance.__prevStep()}};$.facebox.nextStep=function(){if(Facebox.instance){return Facebox.instance.__nextStep()}};Facebox=function(settings){Facebox.push(this);this.__construct(settings);if(typeof settings.callbacks=="object"){for(var i in settings.callbacks){if(typeof this.settings.context[i]=="undefined"){this.settings.context[i]=settings.callbacks[i]}}}};Facebox.stack=[];Facebox.instance=[];Facebox.defaultSettings={url:false,content:"",overlay:.5,overlayColor:null,speed:200,loading:"/api/js/faceboxV2/loadingHeader.gif",post:false,iframe:false,draggable:false,resizable:false,titre:"",skin:"facebook",width:480,minWidth:320,maxWidth:"auto",height:"auto",minHeight:"auto",maxHeight:"auto",marginBorder:30,closeOverlay:true,button:null,zoom:true,appendContainer:"body",id:null,steps:null,stepTabs:true,currentStep:null,close:true,callbacks:{},afterAppear:function(){return false},beforeLoad:function(){return false},afterLoad:function(){return false},beforeClose:function(){return false},afterClose:function(){return false},beforePos:function(){return false},afterPos:function(){return false},beforeNextStep:function(currentStep){return true},beforePrevStep:function(currentStep){return true},afterStepLoad:function(currentStep){return false},html:''};Facebox.push=function(instance){Facebox.stack.unshift(instance);Facebox.instance=instance};Facebox.pop=function(instance){Facebox.stack.shift(instance);Facebox.instance=Facebox.stack[0]||null;$facebox=Facebox.instance==null?null:Facebox.instance.$content.find(".fb-content")};Facebox.prototype={__construct:function(settings){var othis=this,nbInstance=0;if(typeof faceboxSettings!="undefined"){Facebox.defaultSettings=$.extend({},Facebox.defaultSettings,faceboxSettings)}if(settings){this.settings=$.extend({context:$("body")},Facebox.defaultSettings,settings)}if(Facebox.stack.length>1){for(var i in Facebox.stack){if(typeof Facebox.stack[i].settings!="undefined"){if(this.settings.url&&this.settings.url===Facebox.stack[i].settings.url||!this.settings.url&&this.settings.content===Facebox.stack[i].settings.content){nbInstance++}}}if(nbInstance>1){Facebox.pop(this);return false}}this.$content=$(this.settings.html).appendTo(this.settings.appendContainer).addClass(this.settings.skin);$facebox=this.$content.find(".fb-content");this.settings.windowMaxHeight=$(window).height()-pInt(this.settings.marginBorder*2)-20;this.settings.windowMaxWidth=$(window).width()-pInt(this.settings.marginBorder*2)-20;if(this.settings.close===false){this.$content.find(".fb-close").remove()}if(this.settings.id){this.$content.find(".fb-content").attr("id",this.settings.id)}if(this.settings.overlayColor){this.$content.find(".fb-overlay").css("background-color",this.settings.overlayColor)}this.$content.find(".fb-loading").html('
').end().find(".fb-overlay").css("z-index",1e5+Facebox.stack.length*1e3).fadeTo(0,this.settings.overlay).end().find(".fb-box").css("z-index",100010+Facebox.stack.length*1e3).end().fadeTo(0,0,function(){othis.__position(0,"loading");$(this).show().fadeTo(othis.settings.fade,1,function(){if(othis.settings.steps!==null){othis.settings.button=$.extend({},{button_prev_step:{text:"Etape pr�c�dente",call:function(){$.facebox.prevStep()}},button_next_step:{text:"Etape suivante",call:function(){$.facebox.nextStep()}}},othis.settings.button)}if(othis.settings.button!==null){$.each(othis.settings.button,function(index,value){if(othis.settings.skin==="bootstrap"){var input=$("").attr({id:value.id,href:"javascript:;","class":"btn "+(value.className||"")});input.text(value.text)}else{var input=$("").attr({type:"button",name:index,id:value.id,"class":value.className,value:value.text})}value.$=input;othis.$content.find(".fb-footer div").append(input);input.click(function(){othis.settings.button[index].call()})})}othis.__loadContent()})}).find(".fb-close").click(function(){othis.__destruct()}).end().find(".fb-overlay").click(function(){othis.__destruct("overlay")})},call:function(){return this.settings.context},close:function(type){this.__destruct(type)},loading:function(integrer){if(pInt(integrer)>0){this.$content.find(".fb-loading").show().end().find(".fb-close").hide()}else{this.$content.find(".fb-loading").hide().end().find(".fb-close").show()}},previous:function(){if(this.$content.find(".fb-gallery").length){this.$content.find(".fb-previous").trigger("click")}},next:function(){if(this.$content.find(".fb-gallery").length){this.$content.find(".fb-next").trigger("click")}},zoom:function(){if(this.$content.find(".fb-gallery").length&&this.settings.zoom){this.$content.find(".fb-content").find("p.zoom img").css("cursor","default").width("auto").height("auto");var imageWidth=this.$content.find(".fb-content").find("p.zoom img").width(),imageHeight=this.$content.find(".fb-content").find("p.zoom img").height();this.$content.find(".fb-content").find("p.zoom").width(imageWidth+18>=this.settings.windowMaxWidth?this.settings.windowMaxWidth:imageWidth+18).height(imageHeight+18>=this.settings.windowMaxHeight?this.settings.windowMaxHeight:imageHeight+18);this.__position(this.settings.speed,"gallery")}},__destruct:function(type){var othis=this;if(type!="method.close"&&(type=="overlay"&&this.settings.closeOverlay===false||this.settings.closeOverlay===false&&this.settings.close===false)){return false}this.settings.beforeClose();this.$content.find(".fb-box").animate({"margin-top":"-2000"},this.settings.speed,function(){othis.$content.fadeOut(othis.settings.speed,function(){$(this).remove();othis.settings.afterClose();if(typeof othis.settings.callbacks=="object"){for(var i in othis.settings.callbacks){if(typeof othis.settings.context[i]!=="undefined"){$(othis.settings.context).removeData(othis.settings.callbacks[i])}}}})});Facebox.pop()},__error:function(message,timeout){var othis=this,timeToClose=pInt(this.settings.alert)||pInt(timeout)||0;var content="
"+message;if(timeout>0){content+="
Fermeture automatique dans "+Math.max(1,timeout-1)+" secondes."}this.$content.find(".fb-content").html(content+"
");if(timeout>0){var toChange=this.$content.find(".fb-content").find("div span span");var timer=setInterval(function(){var num=pInt(toChange.text())-1;toChange.text(num+" seconde"+(num>1?"s":""))},1e3);setTimeout(function(){clearInterval(timer);othis.__destruct()},(timeout-1)*1e3)}},__prevStep:function(){var othis=this;if(othis.settings.steps!=null){var tmpContinue=othis.settings.beforePrevStep(othis.settings.currentStep);if(tmpContinue!==false){var tmpStep=null;for(var i in othis.settings.steps){if(i==othis.settings.currentStep){success=true;break}tmpStep=i}othis.settings.currentStep=tmpStep;if(success){othis.$content.find(".fb-steps").animate({"margin-left":"+="+othis.settings.width},othis.settings.speed);othis.__checkSteps();othis.settings.afterStepLoad(othis.settings.currentStep);var first=false;for(var i in othis.settings.steps){if(i==othis.settings.currentStep){first=true}break}setTimeout(function(){othis.$content.find(".fb-footer input[type=button][name=button_next_step]").val(othis.settings.button.button_next_step.text)},othis.settings.speed)}else{$.facebox.close()}return true}}return false},__nextStep:function(){var othis=this;if(othis.settings.steps!=null){var tmpContinue=othis.settings.beforeNextStep(othis.settings.currentStep);if(tmpContinue!==false){var saveNext=false;var success=false;for(var i in othis.settings.steps){if(i==othis.settings.currentStep){saveNext=true}else if(saveNext==true){othis.settings.currentStep=i;success=true;break}}if(success){othis.$content.find(".fb-steps").animate({"margin-left":"-="+othis.settings.width},othis.settings.speed);othis.__checkSteps();othis.settings.afterStepLoad(othis.settings.currentStep)}else{$.facebox.close()}return true}}return false},__checkSteps:function(){var othis=this;var firstStep=false;for(var i in othis.settings.steps){if(i==othis.settings.currentStep){firstStep=true}break}var last=false;for(var i in othis.settings.steps){last=false;if(i==othis.settings.currentStep){last=true}}if(firstStep==true){othis.$content.find(".fb-footer input[type=button][name=button_prev_step]").hide()}else{othis.$content.find(".fb-footer input[type=button][name=button_prev_step]").show()}if(last==true){setTimeout(function(){othis.$content.find(".fb-footer input[type=button][name=button_next_step]").val("Terminer")},othis.settings.speed)}if(othis.settings.stepTabs){othis.$content.find(".fb-tab-steps li.active").removeClass("active");othis.$content.find(".fb-tab-steps li."+othis.settings.currentStep).addClass("active")}else{othis.$content.find(".fb-header .fb-title").html(othis.settings.steps[othis.settings.currentStep].titre)}},__loadContent:function(){var othis=this;this.settings.beforeLoad();if(this.settings.gallery){this.__reveal("gallery",this.settings.gallery[this.settings.index])}else if(this.settings.image){this.__reveal("image",this.settings.image)}else if(this.settings.alert>=0){this.__error(this.settings.url,this.settings.alert)}else if(this.settings.steps!=null){if(this.settings.currentStep==null){for(var i in this.settings.steps){this.settings.currentStep=i;break}}var step=this.settings.steps[this.settings.currentStep];$.ajax({url:this.settings.url,type:this.settings.post!==false?"POST":"GET",data:this.settings.post?this.settings.post:null,error:function(err){if(err.status=="404"){othis.__error("Page introuvable : 404",4)}},success:function(data){othis.__reveal("step",data);othis.__checkSteps();othis.settings.afterStepLoad(othis.settings.currentStep)}})}else if(this.settings.url.length||this.settings.content.length){if(this.settings.content.length){this.__reveal("content",this.settings.content)}else if(this.settings.url[0]=="#"){if($(this.settings.url).length){this.__reveal("content",$(this.settings.url).html())}else{this.__error("Element introuvable : 404",4)}}else if(othis.settings.url.match(/^(http|https):\/\//i)||this.settings.iframe===true){this.__reveal("iframe",this.settings.url)}else{$.ajax({url:this.settings.url,type:this.settings.post?"POST":"GET",data:this.settings.post?this.settings.post:null,error:function(err){if(err.status=="404"){othis.__error("Page introuvable : 404",4)}},success:function(data){othis.__reveal("ajax",data)}})}}else{this.__error("$.facebox - Aucun contenu à charger",4)}},__reveal:function(type,data){var othis=this;this.settings.afterLoad();var zIndexStack=100010+Facebox.stack.length*1e3;if(data){switch(type){case"step":othis.settings.height=Math.max(othis.settings.height!="auto"?pInt(othis.settings.height):250,250);othis.settings.width=Math.max(othis.settings.width!="auto"?pInt(othis.settings.width):320,320);var data=$("").addClass("fb-steps").html(data);if(othis.settings.stepTabs){var tabSteps=$("").addClass("fb-tab-steps").append("");var tmpFirst=true;for(var i in othis.settings.steps){var tmpLi=$("").addClass(i).append(othis.settings.steps[i].titre);if(tmpFirst){tmpFirst=false;$(tmpLi).addClass("active")}tmpLi.appendTo($(tabSteps).find("ul"))}}othis.$content.find(".fb-content").css("overflow","hidden");var cpt=0;for(var i in othis.settings.steps){stepContent=othis.settings.steps[i].content;$(data).find(stepContent).addClass("fb-tab").width(othis.settings.width).find("textarea, select, input, a").filter(":last").keypress(function(event){if(event.keyCode==9){event.preventDefault()}});cpt++}$(data).width(cpt*othis.settings.width);case"content":case"ajax":this.$content.find(".fb-box").fadeOut(this.settings.speed,function(){othis.$content.find(".fb-header .fb-title").html(othis.settings.titre).parent().show();othis.$content.find(".fb-content").html(data);if($(tabSteps).length>0){$(data).before($(tabSteps))}if(othis.$content.find(".fb-footer "+(othis.settings.skin=="bootstrap"?"button":"input")).length){othis.$content.find(".fb-footer").show()}othis.$content.find(".fb-box").fadeIn(0).removeAttr("style").css("z-index",zIndexStack);if(othis.settings.draggable){othis.__draggable(".fb-header")}if(othis.settings.resizable){othis.__resizable()}othis.__position(othis.settings.speed);othis.settings.afterAppear()});break;case"iframe":this.$content.find(".fb-box").fadeOut(this.settings.speed,function(){var iframe=$("").attr({frameborder:0,hspace:0,src:data,id:"surveyFrame",name:"surveyFrame",width:"100%",height:"100%"});othis.$content.find(".fb-content").html(iframe);othis.$content.find(".fb-header .fb-title").html(othis.settings.titre).parent().show();othis.$content.find(".fb-box").fadeIn(0).removeAttr("style").css("z-index",zIndexStack);if(othis.settings.draggable){othis.__draggable(".fb-header")}othis.__position(othis.settings.speed);othis.settings.afterAppear()});break;case"gallery":case"image":this.$content.find(".fb-header").remove();var image=new Image;image.src=(type=="gallery"?data.image:data)+($.browser.msie?((type=="gallery"?data.image:data).split("?")[1]?"&":"?")+"_="+(new Date).getTime():"");$(image).load(function(){othis.$content.find(".fb-box").fadeOut(othis.settings.speed,function(){var imageWidth=$(image)[0].width,imageHeight=$(image)[0].height;othis.$content.find(".fb-content").addClass("fb-gallery").css("overflow","hidden").html('
');othis.$content.find(".fb-box").fadeIn(0).removeAttr("style").css("z-index",zIndexStack);var thisImage=othis.$content.find(".fb-content").find("img");var ratio=parseFloat((imageWidth>othis.settings.windowMaxWidth||imageHeight>othis.settings.windowMaxHeight?Math.max(imageWidth/othis.settings.windowMaxWidth,imageHeight/othis.settings.windowMaxHeight):1).toFixed(1));var imageWidth=Math.min(othis.settings.windowMaxWidth,Math.floor(imageWidth/ratio)),imageHeight=Math.min(othis.settings.windowMaxHeight,Math.floor(imageHeight/ratio));thisImage.width(imageWidth);thisImage.height(imageHeight);if(type=="gallery"){if(othis.settings.gallery[othis.settings.index-1]){othis.$content.find(".fb-content").append('«image
précédente').find(".fb-previous").click(function(){othis.settings.index--;othis.__loadContent()})}if(othis.settings.gallery[othis.settings.index+1]){othis.$content.find(".fb-content").append('»image
suivante').find(".fb-next").click(function(){othis.settings.index++;othis.__loadContent()})}othis.$content.find(".fb-content").find("a").width(Math.max(320,imageWidth)/(othis.$content.find(".fb-content").find(".fb-previous").length&&othis.$content.find(".fb-content").find(".fb-next").length?2:1)).height(imageHeight).hover(function(){$(this).find("span").css("display","inline-block")},function(){$(this).find("span").hide()}).end().find("a span").css("margin-top","-"+Math.round(imageHeight/2)).end().append('Image '+(othis.settings.index+1)+"/"+othis.settings.total+'Fermer '+data.titre+""+(data.description?data.description:"")+"
")}else{if(othis.settings.zoom&&(imageWidth>=othis.settings.windowMaxWidth||imageHeight>=othis.settings.windowMaxHeight)){othis.$content.find(".fb-content").find("p.zoom").width("100%").height(imageHeight).find("img").css("cursor","pointer").click(function(){othis.zoom()})}}othis.__position(othis.settings.speed,"gallery",imageWidth,imageHeight)});if(type=="gallery"){othis.$content.find(".fb-content").find("a.fb-previous").live("click",function(){othis.settings.index--;othis.__loadContent()})}}).error(function(){othis.__error("Image introuvable : 404",4)});othis.settings.afterAppear();break}}if(othis.$content.find(".fb-header").length){othis.$content.find(".fb-header").dblclick(function(){othis.__position(othis.settings.speed,"height")})}},__position:function(speed,type,width,height){if(type=="height"){this.settings.height=this.settings.maxHeight=this.settings.minHeight="auto"}if(type=="loading"){this.$content.find(".fb-content").width(300)}else if(type=="gallery"){this.$content.find(".fb-content").removeAttr("style").css("min-width",320)}else{this.settings.beforePos();this.settings.windowMaxHeight=$(window).height()-pInt(this.settings.marginBorder*2)-20-this.$content.find(".fb-header").height()-this.$content.find(".fb-tab-steps").height()-this.$content.find(".fb-footer").height();if(this.settings.minWidth!="auto"){this.settings.minWidth=pInt(this.settings.minWidth)>this.settings.windowMaxWidth?this.settings.windowMaxWidth:pInt(this.settings.minWidth)}if(this.settings.minHeight!="auto"){this.settings.minHeight=pInt(this.settings.minHeight)>this.settings.windowMaxHeight?this.settings.windowMaxHeight:pInt(this.settings.minHeight)}if(this.settings.width!="auto"){this.settings.width=pInt(this.settings.width)>this.settings.windowMaxWidth?this.settings.windowMaxWidth:pInt(this.settings.width)}if(this.settings.height!="auto"){this.settings.height=pInt(this.settings.height)>this.settings.windowMaxHeight?this.settings.windowMaxHeight:pInt(this.settings.height)}this.settings.maxWidth=this.settings.maxWidth!="auto"?pInt(this.settings.maxWidth)>this.settings.windowMaxWidth?this.settings.windowMaxWidth:pInt(this.settings.maxWidth):this.settings.windowMaxWidth;this.settings.maxHeight=this.settings.maxHeight!="auto"?pInt(this.settings.maxHeight)>this.settings.windowMaxHeight?this.settings.windowMaxHeight:pInt(this.settings.maxHeight):this.settings.windowMaxHeight;this.$content.find(".fb-content").css({"min-width":this.settings.minWidth,"max-width":this.settings.maxWidth,"min-height":this.settings.minHeight,"max-height":this.settings.maxHeight,width:this.settings.width,height:this.settings.height});if(this.settings.stepTabs){this.$content.find(".fb-content").find(".fb-tab").height(this.$content.find(".fb-content").height()-this.$content.find(".fb-content").find(".fb-tab-steps").outerHeight())}this.settings.afterPos()}this.$content.find(".fb-box").css("margin-left","-"+Math.round((width?width:this.$content.find(".fb-box").width())/2)-10);if($.browser.msie===true){if(type=="gallery"){this.$content.find(".fb-content").width(this.$content.find(".fb-content").find("img").width())}this.$content.find(".fb-header").width(this.$content.find(".fb-content").innerWidth());this.$content.find(".fb-footer").width(this.$content.find(".fb-content").innerWidth())}this.$content.find(".fb-box").animate({"margin-top":"-"+Math.round((height?height:this.$content.find(".fb-box").height())/2)-10},this.settings.speed)},__draggable:function(element){var othis=this,box=this.$content.find(".fb-box"),height=box.outerHeight()/2-box.find(".fb-header").height();this.$content.find(element).css("cursor","move");var move=function(event){if($(document).data("mouseMove")){box.css({left:event.clientX,top:event.pageY+height})}};this.$content.find(element).mousedown(function(){$(document).data("mouseMove",true).mousemove(move)}).mouseup(function(){$(document).removeData("mouseMove")})},__resizable:function(){var othis=this,box=othis.$content.find(".fb-content");this.$content.find(".fb-resize").show();var resize=function(event){if($(document).data("resize")){var position=box.offset();box.width(event.clientX-position.left).height(event.clientY-position.top)}};this.$content.find(".fb-resize").mousedown(function(event){event.preventDefault();$(document).data("resize",true).mousemove(resize)}).mouseup(function(){$(document).data("resize",false)})}};$(document).ready(function(){$("*[rel^=facebox]").live("click",function(event){event.preventDefault();if($(this).attr("rel")=="facebox-gallery"){var gallery={},total=0;$("*[rel^=facebox-gallery]").each(function(index){gallery[index]={titre:$(this).attr("title"),description:$(this).attr("rev"),image:$(this).attr($(this)[0].tagName.toLowerCase()=="img"?$(this).attr("zoom").length?"zoom":"src":"href")};total++});$.facebox({gallery:gallery,index:$(this).index("*[rel^=facebox-gallery]"),total:total})}else if($(this).attr("rel")=="facebox-image"){$.facebox({image:$(this).attr($(this)[0].tagName.toLowerCase()=="img"?"src":"href"),content:$(this).attr($(this)[0].tagName.toLowerCase()=="img"?"src":"href")})}else{var $params=$(this).attr("rel").match(/\{(.*?)\}/i);if($params){$params=$params[1]}$.facebox($.parseJSON('{"url":"'+$(this).attr("href")+'","titre":"'+$(this).attr("title")+'"'+($params?","+$params.replace(/\'/gi,'"'):"")+"}"))}});$(document).keypress(function(event){if($(".facebox").length){if(event.keyCode==37&&Facebox.instance){Facebox.instance.previous()}else if(event.keyCode==39&&Facebox.instance){Facebox.instance.next()}else if(event.keyCode==27){$.facebox.close()}}})})})(jQuery);