/*!
	W3build Frontpage javascript.
	Maakt gebruik van jQuery
	Copyright 2010 W3build
*/
jQuery.fn.contactform=function(){return $(this).validate({rules:{"data[Contact][bericht]":{required:true,minlength:10},"data[Contact][naam]":{required:true,minlength:2},"data[Contact][email]":{required:true,email:true}},messages:{"data[Contact][bericht]":"Voer een bericht in","data[Contact][naam]":"Geef alstublieft een naam op (minimaal 2 tekens)","data[Contact][email]":{required:"We hebben uw emailadres nodig om contact met u op te kunnen nemen",email:"Geef een email adres in het formaat: name@domain.com"}}})}; pageSwitcher=new function(c){this.pages={"portfolio/index*":["#portfolio_content","carrousel"],"portfolio/fotos/*":["#portfolio_content","fotostrip"],"portfolio/product/*":["#portfolio_content","fixvierding"],"portfolio/*":["#portfolio_content",null],"pages/overons":["#wij_content",null],"contact/*":["#contact_content","contactformulier"],"":["#home_content",null],home:["#home_content",null]};this.easing=c?c:"easeInOutSine";this.ignoreNextHashChange=false;this.setLastContent=function(d){var b=this.pageSearch(d); if(!this.pages[b])return false;this.lastPage=d;this.lastContent=this.pages[b][0]};this.pageSearch=function(d){var b=false,a;for(a in this.pages){var f="^"+a.replace(/([/\\.\[\]\(\)])/g,"\\$1").replace(/\*/g,".*")+"$";if(d.match(RegExp(f,""))){b=a;break}}return b};this.go=function(d){var b=this.pageSearch(d);if(!b||!this.pages[b])return false;var a=this.pages[b];if(this.lastPage&&this.lastPage==d)return true;if(!this.lastContent||this.lastContent!=a[0]){for(var f in this.pages)f!=d&&$(this.pages[f][0]).slideUp(500, c,function(){$(this).children().remove()});$(a[0]).html('<p class="laadbericht"><img src="/img/showcase/loader.gif" alt="laden" />Aan het Laden</p>');$(a[0]).css({height:"0px",overflow:"hidden"}).show();$(a[0]).animate({height:100},500,c)}else{$(this.lastContent).height($(this.lastContent).height());$(this.lastContent).children("div").fadeOut(500,function(){this.parentNode.removeChild(this)},c);$(this.lastContent).children(".laadbericht").fadeIn(500,c,function(){})}this.lastPage=d;this.lastContent= a[0];this.ignoreNextHashChange="#"+d.toString();location.hash="#"+d.toString();$.ajax({async:true,url:"/"+d,type:"GET",success:function(e){$(a[0]).append("<div>"+e+"</div>");$(a[0]).find(".laadbericht").hide();switch(a[1]){case "carrousel":carousselize();$(a[0]).animate({height:396},1500,c,function(){this.style.height="auto"});break;case "fotostrip":e=545;$(a[0]).animate({height:e},1500,c,function(){this.style.height="auto"});fotoInit();break;case "contactformulier":$(".contactformulier").contactform(); e=$(a[0]).children("div").height();$(a[0]).animate({height:e},1500,c,function(){this.style.height="auto"});break;case "fixvierding":fixvierding();e=$(a[0]).children("div").last().height();$(a[0]).animate({height:e},1500,c,function(){this.style.height="auto"});break;default:e=$(a[0]).children("div").last().height();$(a[0]).animate({height:e},1500,c,function(){this.style.height="auto"})}ajaxLinkY()},error:function(){$(a[0]).html("Er is een fout opgetreden...")}});try{pageTracker._trackPageview(d)}catch(g){}$(window).hashchange(function(){var e= pageSwitcher.ignoreNextHashChange;if(e===true)pageSwitcher.ignoreNextHashChange=false;else if(!e||e.replace&&location.hash.replace(/^#/,"")!=e.replace(/^#/,"")){pageSwitcher.ignoreNextHashChange=false;pageSwitcher.go(location.hash.replace(/^#/,""))}});return true}}; function ajaxLinkY(){for(var c=document.getElementsByTagName("a"),d=[],b=0;b<c.length;b++)if(!c[b]._isAjax&&c[b].className.match(/\ajaxload\b/)){c[b]._isAjax=true;d.push(c[b])}$(d).click(function(a){a.preventDefault();if(pageSwitcher.go(this.href.replace(/^http:\/\/[^\/]+\//,""))){a.preventDefault();this.blur()}})} function carousselize(c){c||(c="easeOutSine");var d=$("#portfolio_carrousel");d.length>0&&d.jCarouselLite({btnNext:".pijl_rechts",btnPrev:".pijl_links",visible:$("#portfolio_carrousel").width()/210,auto:0,speed:500,easing:c})} function fixvierding(){var c=0;$("#pr_afbeelding").innerWidth();$("#pr_afbeelding > .pr-subfoto").each(function(){var d=$(this),b=parseInt(d.css("marginLeft").replace("px","")),a=parseInt(d.css("marginTop").replace("px",""))+4;a-=c;c+=d.outerHeight();d.css({display:"block",position:"relative",left:b+"px",top:a+"px",margin:"0 0 0 0",width:d.width(),height:d.height()-3})});$(".editit").click(function(){var d=$(this.parentNode).children("p"),b=document.createElement("textarea");b.value=d.html();b=this.parentNode.appendChild(b); b.focus();$(this.parentNode).children("a, p").hide();$(b).blur(function(){var a=location.hash.indexOf("/product/")!=-1?"/"+location.hash.replace(/^\#/,"").replace("/product/","/editProduct/"):"/"+location.pathname.replace(/^\//,"").replace("/product/","/editProduct/");$.ajax({type:"POST",url:a,data:{text:this.value},success:function(f){d.html(f);$(b.parentNode).children("a, p").show();b.parentNode.removeChild(b)}})})})} function fotoInit(){var c=[],d=$("#prfoto_strip .fotoload").each(function(){c.push("/"+this.href.replace(/^http:\/\/[^\/]+\//,""))});$(".fotoload").click(function(b){b.stopPropagation();b.preventDefault();b="/"+this.href.replace(/^http:\/\/[^\/]+\//,"");for(var a=0;a<c.length;a++)if(b==c[a])break;d.removeClass("current");$(d[a]).addClass("current");if(c.length!=1){$(".pijl_links > a").attr("href",a==0?c[c.length-1]:c[a-1]);$(".pijl_rechts > a").attr("href",a==c.length-1?c[0]:c[a+1])}document.getElementById("prfoto_curfoto").src= b.replace("portfolio/fotos","img/portfolio");$.ajax({type:"GET",cache:true,url:b.replace("/fotos/","/fototekst/"),success:function(f){$("#prfoto_tekst > p").html(f)}});pageSwitcher.ignoreNextHashChange=b.replace(/^\//,"#");location.hash=b.replace(/^\//,"#")});$(".editit").click(function(){var b=$(this.parentNode).children("p"),a=document.createElement("textarea");a.value=b.html();a=this.parentNode.appendChild(a);a.focus();$(this.parentNode).children("a, p").hide();$(a).blur(function(){var f=location.hash.indexOf("/fotos/")!= -1?"/"+location.hash.replace(/^\#/,"").replace("/fotos/","/ajaxAanpassen/"):"/"+location.pathname.replace(/^\//,"").replace("/fotos/","/ajaxAanpassen/");$.ajax({type:"POST",url:f,data:{text:this.value},success:function(g){b.html(g);$(a.parentNode).children("a, p").show();a.parentNode.removeChild(a)}})})})};
