var activeDebug=!0;jQuery(document).ready(function(){_2clics.init()}),jQuery(window).resize(function(){_2clics.resizePos()});var globalOptions={widthMain:358,timing:500,current:null,old:null,windowHeight:null,windowWidth:null,widthOriginal:null,heightOriginal:null,pathToPictures:"img/visuels/"},sizeOriginal=[[325,0,"profil"],[330,0,"realisations"],[460,820,"disponibilites"],[160,0,"contact"]],size=[[sizeOriginal[0][0],sizeOriginal[0][1],sizeOriginal[0][2]],[sizeOriginal[1][0],sizeOriginal[1][1],sizeOriginal[1][2]],[sizeOriginal[2][0],sizeOriginal[2][1],sizeOriginal[2][2]],[sizeOriginal[3][0],sizeOriginal[3][1],sizeOriginal[3][2]]];jQuery.ajaxSetup({type:"POST",dataType:"json"});var oldPosTop=null,oldPosLeft=null,oldNewHeight=null,oldNewWidth=null,oldHeight=null,oldWidth=null,directionTop="-=",directionLeft="-=",_2clics={init:function(){_2clics.fixPos(),_2clics.handleMenu()},fixPos:function(){jQuery.browser.msie&&jQuery.browser.version.indexOf("6.")>-1&&jQuery("#main").css({width:globalOptions.widthMain+"px"}),globalOptions.windowHeight=jQuery(window).height(),globalOptions.windowWidth=jQuery(window).width(),globalOptions.heightOriginal=jQuery("#main").outerHeight(),globalOptions.widthOriginal=jQuery("#main").outerWidth(),jQuery(".loading").size()==0&&_2clics.createLoading(),jQuery("#container").css({width:globalOptions.widthOriginal}),posTop=Math.round((globalOptions.windowHeight-globalOptions.heightOriginal)/2),posLeft=Math.round((globalOptions.windowWidth-globalOptions.widthOriginal)/2),jQuery("#main").css({left:posLeft+"px",top:posTop+"px"}),jQuery(".loading").is(":visible")&&_2clics.stopLoading()},resizePos:function(){globalOptions.windowHeight=jQuery(window).height(),globalOptions.windowWidth=jQuery(window).width(),currentHeightResize=jQuery("#main").outerHeight(),currentWidthResize=jQuery("#main").outerWidth(),posTop=Math.round((globalOptions.windowHeight-currentHeightResize)/2),posLeft=Math.round((globalOptions.windowWidth-currentWidthResize)/2),jQuery("#main").css({left:posLeft+"px",top:posTop+"px"})},createLoading:function(){var a=document.createElement("div");jQuery(a).addClass("loading").css({left:Math.round((globalOptions.windowWidth-66)/2)+"px",top:Math.round((globalOptions.windowHeight-66)/2)+"px"}),jQuery("body").append(a)},stopLoading:function(){setTimeout(function(){jQuery(".loading").fadeOut(700,function(){jQuery("#main").css({visibility:"visible"}).hide().fadeIn(700,function(){_2clics.loadDefault()})})},400)},loadDefault:function(){url=document.location.href,url.indexOf("#")>0?(toActive="#"+url.split("#")[1],toActive.length>1&&jQuery("#navigation a[href*='"+toActive+"']").click()):jQuery("#navigation a:eq(0)").click()},handleMenu:function(){jQuery("#navigation a").unbind().click(function(){jQuery("#navigation a").removeClass("on"),jQuery(this).addClass("on"),newIndex=jQuery("#navigation a").index(this),globalOptions.current!=newIndex?(globalOptions.current=newIndex,globalOptions.old!=null?jQuery("#content").fadeOut(globalOptions.timing,function(){_2clics.openCurrent()}):_2clics.openCurrent()):_2clics.closeAll()})},openCurrent:function(){globalOptions.current==1&&(size[globalOptions.current][1]=sizeOriginal[1][1]),globalOptions.current==3&&(size[globalOptions.current][0]=sizeOriginal[3][0]),globalOptions.current==3&&(size[globalOptions.current][1]=sizeOriginal[3][1]),size[globalOptions.current][0]==0&&(size[globalOptions.current][0]=globalOptions.heightOriginal),size[globalOptions.current][1]==0&&(size[globalOptions.current][1]=globalOptions.widthOriginal),posTop=Math.round(size[globalOptions.current][0]/2),posLeft=Math.round((size[globalOptions.current][1]-globalOptions.widthOriginal)/2),currentHeight=size[globalOptions.current][0],currentWidth=size[globalOptions.current][1],globalOptions.old!=null&&(oldHeight=size[globalOptions.old][0],oldWidth=size[globalOptions.old][1],currentHeight>=oldHeight?(directionTop="-=",posTop=Math.round((currentHeight-oldHeight)/2)):(directionTop="+=",posTop=Math.round((oldHeight-currentHeight)/2)),currentWidth>=oldWidth?(directionLeft="-=",posLeft=Math.round((currentWidth-oldWidth)/2)):(directionLeft="+=",posLeft=Math.round((oldWidth-currentWidth)/2))),oldPosTop=posTop,oldPosLeft=posLeft,oldNewHeight=currentHeight,oldNewWidth=currentWidth,jQuery("#main").animate({top:directionTop+posTop+"px",left:directionLeft+posLeft+"px"},globalOptions.timing),jQuery("#container").animate({height:currentHeight,width:currentWidth},globalOptions.timing,function(){jQuery("#content").empty().load(size[globalOptions.current][2],function(){jQuery(this).fadeIn(function(){_2clics.activeBind(globalOptions.current)})})}),globalOptions.old=globalOptions.current},closeCurrent:function(a){jQuery(a).empty().hide(),posTop=Math.round(size[globalOptions.old][0]/2),posLeft=Math.round((size[globalOptions.old][1]-globalOptions.widthOriginal)/2),jQuery("#main").animate({top:"+="+posTop+"px",left:"+="+posLeft+"px"},globalOptions.timing),jQuery("#container").animate({height:0,width:globalOptions.widthOriginal},globalOptions.timing,function(){oldPosTop=null,oldPosLeft=null,oldNewHeight=null,oldNewWidth=null,oldHeight=null,oldWidth=null,directionTop="-=",directionLeft="-=",jQuery("#navigation a").removeClass("on")})},closeAll:function(){jQuery("#content").fadeOut(globalOptions.timing,function(){_2clics.closeCurrent(this),globalOptions.current=globalOptions.old=null})},activeBind:function(a){switch(a){case 1:bindRealisations.init();break;case 3:bindContact.init()}},animateMain:function(a,b,c){jQuery("#main").animate(a,globalOptions.timing,function(){size[globalOptions.current][0]=jQuery("#container").outerHeight(),size[globalOptions.current][1]=jQuery("#container").outerWidth()}),jQuery("#container").animate(b,globalOptions.timing,c)}},bindRealisations={newId:0,currentId:1,currentPage:1,pictureToShow:null,height:0,init:function(){bindRealisations.newId=bindRealisations.currentId=0,bindRealisations.currentPage=1,bindRealisations.height=jQuery("#realisations .list").height(),jQuery("#realisations .details, #realisations .picture").css({height:bindRealisations.height+"px"}),jQuery("#realisations .list li a").unbind().click(function(){if(jQuery(this).attr("class")!="others"){bindRealisations.pictureToShow=null,id=jQuery(this).attr("href"),bindRealisations.newId=id.split("#")[1];if(bindRealisations.currentId==bindRealisations.newId)return!1;jQuery("#realisations .picture").is(":visible")&&bindRealisations.hidePicture(),jQuery("#realisations .details").is(":hidden")?_2clics.animateMain({left:"-=62px"},{width:"+=123px"},bindRealisations.details):jQuery("#realisations .picture").queue(function(){jQuery("#realisations .detailsContent").fadeOut(globalOptions.timing,function(){bindRealisations.details()}),jQuery(this).dequeue()})}else bindRealisations.showOthers();return!1}),jQuery("#realisations .list li a:eq(0)").click()},details:function(){jQuery.ajax({url:"/ajax/realisations",data:"id="+bindRealisations.newId,success:function(a){jQuery(".detailsContent h3").html(a.title),jQuery(".detailsContent .agency").empty(),a.agency_title&&(jQuery(".detailsContent .agency").html(a.agency_title+" - "),jQuery(".detailsContent .agency a").click(function(){return window.open(jQuery(this).attr("href")),!1})),jQuery(".detailsContent .agency").append(a.year),jQuery(".detailsContent .url a").attr("href",a.url).unbind("click").click(function(){return window.open(jQuery(this).attr("href")),!1});var b=a.task.split("|"),c="";for(var d=0;d<b.length;d++)c+=bindRealisations.handleTasks(b[d]),c+=d+1===b.length?"":"|";a.description=c,a.description?bindRealisations.description(a.description):jQuery(".description").remove(),bindRealisations.writeLinkPictures(a.pictures),bindRealisations.showDetails()}}),bindRealisations.currentId=bindRealisations.newId,size[globalOptions.current][1]=jQuery("#container").outerWidth()},description:function(a){jQuery(".description").remove(),tagUL=document.createElement("ul"),jQuery(tagUL).addClass("description");var b=a.split("|");for(i=0;i<b.length;i++)tagLI=document.createElement("li"),jQuery(tagLI).text(b[i]),jQuery(tagUL).append(tagLI);jQuery(".detailsContent .ahead").after(tagUL)},writeLinkPictures:function(a){noPictures=a!=""?!1:!0;if(!noPictures){jQuery(".shoots").show(),pictures=a.split("|"),jQuery(".shoots span").empty();for(i=0;i<pictures.length;i++)tagA=document.createElement("a"),jQuery(tagA).attr({href:globalOptions.pathToPictures+bindRealisations.newId+"/"+pictures[i]}).text(i+1+" "),jQuery(".shoots span").append(tagA);setTimeout(function(){jQuery("#realisations .details .shoots a:eq(0)").size()>0&&jQuery("#realisations .details .shoots a:eq(0)").click()},600)}else jQuery(".shoots").hide()},showDetails:function(){divToShow=jQuery("#realisations .details").is(":hidden")?jQuery("#realisations .details"):jQuery("#realisations .detailsContent"),divToShow.fadeIn(globalOptions.timing,function(){jQuery(".shoots a").unbind("click").click(function(){return bindRealisations.pictureToShow==jQuery(this).attr("href")?!1:(bindRealisations.pictureToShow=jQuery(this).attr("href"),bindRealisations.picture(),!1)})})},picture:function(){jQuery("#realisations .picture").is(":hidden")?_2clics.animateMain({left:"-=225px"},{width:"+=450px"},bindRealisations.showPicture):jQuery("#realisations .picture img").fadeOut(function(){bindRealisations.showPicture()})},showPicture:function(a){jQuery("#realisations .picture").show(),jQuery("#realisations .picture .close").unbind("click").click(function(){return bindRealisations.hidePicture(),!1}),picture=new Image,picture.src=bindRealisations.pictureToShow,picture.onload=function(){jQuery("#realisations .picture img:eq(1)").fadeIn(),jQuery("#realisations .picture img:eq(0)").attr({src:picture.src}).fadeIn(function(){bindRealisations.showMaxPicture()})},size[globalOptions.current][1]=jQuery("#container").outerWidth()},hidePicture:function(){jQuery("#realisations .picture").fadeOut(1e3,function(){_2clics.animateMain({left:"+=225px"},{width:"-=450px"},""),jQuery("#realisations .picture img:eq(0)").hide().unbind("click").attr({src:"img/pix.gif"}),bindRealisations.pictureToShow=null})},showMaxPicture:function(){pictureMax=bindRealisations.pictureToShow.split(".jpg")[0],pictureMax+="_max.jpg",jQuery("#realisations .picture a:eq(0)").attr({href:pictureMax}).unbind().fancybox()},showOthers:function(){jQuery("#realisations").css({height:jQuery("#realisations").height()+"px"}),heightOthers=jQuery("#others").outerHeight()+20,jQuery("#others").fadeIn(),jQuery("#others .close").unbind("click").click(function(){return jQuery("#others").fadeOut(),!1})},handleTasks:function(a){var b;switch(parseInt(a)){case 1:b="Intégration HTML";break;case 2:b="Javascript / AJAX";break;case 3:b="PHP";break;case 4:b="NodeJS"}return b}},bindContact={init:function(){jQuery("input[type='button']").unbind("click").click(function(){return bindContact.bindForm(),!1}),jQuery(".openForm a").click(function(){return _2clics.animateMain({top:"-=170px",left:"-=197px"},{width:"+=395px",height:"+=340px"},function(){jQuery(".contactArea").fadeIn(),size[globalOptions.current][0]=jQuery("#container").outerHeight(),size[globalOptions.current][1]=jQuery("#container").outerWidth(),temp=jQuery(".openForm strong a").html(),jQuery(".openForm strong a").remove(),jQuery(".openForm strong").html(temp)}),!1})},bindForm:function(){error=bindContact.errors(),error||jQuery.ajax({url:"/ajax/contact",data:jQuery("#contact form").serialize(),success:function(a){a.result==1?jQuery(".contactArea").fadeOut(1e3,function(){_2clics.animateMain({top:"+=150px",left:"+=197px"},{width:"-=395px",height:"-=300px"},function(){jQuery(".result").text(a.message).fadeIn(),size[globalOptions.current][0]=jQuery("#container").outerHeight(),size[globalOptions.current][1]=jQuery("#container").outerWidth()})}):debug("error contact")}})},errors:function(){var a=!1;return jQuery("#contact input:text, #contact #message").removeClass("error"),jQuery("#contact input:text, #contact #message").each(function(){jQuery(this).val()==""&&(a=!0,jQuery(this).addClass("error"))}),email=jQuery("#contact #email").val(),email!=""&&email.search(/^[\w\-+]+(\.[\w\-+]+)*@[\w\-]+(\.[\w\-]+)*\.[\w\-]{2,}$/)==-1&&(jQuery("#contact #email").addClass("error"),a=!0),a}},debug=function(a){activeDebug&&(window.console&&window.console.firebug?console.log(a):"")};if(typeof console!="object")var console={log:function(){}};
