pH8={};pH8.Version='2.0';pH8.CompatibleWithPrototype='1.6';if(Prototype.Version.indexOf(pH8.CompatibleWithPrototype)!==0&&console&&console.warn)
console.warn("This version of pH8 extensions is tested with Prototype "+pH8.CompatibleWithPrototype+" it may not work as expected with this version ("+Prototype.Version+")");pH8.SiteVersion=function(){var meta=Element.getElementsBySelector(document,"meta[name='site-version']");if(meta[0]){return meta[0].getAttribute('content');}else{return 0;}}();pH8.Mixin={};if(!window.console){window.console={log:function(message){}};}
Element.addMethods({getClassParameters:function(element,prefix){element=$(element);if(arguments.length<2){prefix='param';}
var regex=new RegExp(prefix+'-(\\w*)=(\\S*)','g');var params={};while((result=regex.exec(element.className))!=null){params[result[1]]=result[2];}
return params;},getClassParameter:function(element,param,prefix){if(arguments.length<3){prefix='param';}
var regex=new RegExp(prefix+'-'+param+'=(\\S*)');var parts=regex.exec(element.className);if(parts){return parts[1];}}});Object.extend(String.prototype,{isDigits:function(){return(this.match(/^\d+$/)!==null);},stripQuery:function(){return(this.split('?')[0]);},parseExtendedQuery:function(){var queryParams=this.parseQuery();var pos=this.indexOf('#')+1;if(pos){var hashParams=this.substr(pos).parseQuery();Object.extend(queryParams,hashParams);}
return queryParams;},addHashParam:function(key,value){var splitQuery=this.split('#');if(splitQuery.size()>1){var hashParams=$H(splitQuery[1].parseQuery());hashParams.set(key,value);return splitQuery[0]+'#'+hashParams.toQueryString();}else{return this+'#'+encodeURIComponent(key)+'='+encodeURIComponent(value);}}});Object.extend(Number.prototype,{isInteger:function(){return(Math.round(this)===this);}});Draggable.addMethods({draw:function(point){var pos=this.element.cumulativeOffset();if(this.options.ghosting){var r=Position.realOffset(this.element);pos[0]+=r[0]-Position.deltaX;pos[1]+=r[1]-Position.deltaY;}
var d=this.currentDelta();pos[0]-=d[0];pos[1]-=d[1];if(this.options.scroll&&(this.options.scroll!=window&&this._isScrollChild)){pos[0]-=this.options.scroll.scrollLeft-this.originalScrollLeft;pos[1]-=this.options.scroll.scrollTop-this.originalScrollTop;}
var p=[0,1].map(function(i){return(point[i]-pos[i]-this.offset[i])}.bind(this));if(this.options.snap){if(Object.isFunction(this.options.snap)){p=this.options.snap(p[0],p[1],this);}else{if(Object.isArray(this.options.snap)){p=p.map(function(v,i){return(v/this.options.snap[i]).round()*this.options.snap[i]}.bind(this));}else{p=p.map(function(v){return(v/this.options.snap).round()*this.options.snap}.bind(this));}}}
var style=this.element.style;if((!this.options.constraint)||(this.options.constraint=='horizontal')){if(p[0]>this.options.horizontalConstraint[0]){p[0]=this.options.horizontalConstraint[0];}
if(p[0]<this.options.horizontalConstraint[1]){p[0]=this.options.horizontalConstraint[1];}
style.left=p[0]+"px";}
if((!this.options.constraint)||(this.options.constraint=='vertical'))
style.top=p[1]+"px";if(style.visibility=="hidden")style.visibility="";}});;Object.extend(Number.prototype,{toRadians:function(){return this*Math.PI/180;},toDegrees:function(){return this*180/Math.PI;}});pH8.Geo={};pH8.Geo.Point=Class.create({initialize:function(latitude,longitude){this.lat=latitude;this.lon=longitude;},calculatePointAtBearingAndDistance:function(bearing,distance){var a=6378388,b=6356911.946,f=1/297;var s=distance;var alpha1=bearing.toRadians();var sinAlpha1=Math.sin(alpha1),cosAlpha1=Math.cos(alpha1);var tanU1=(1-f)*Math.tan(this.lat.toRadians());var cosU1=1/Math.sqrt((1+tanU1*tanU1)),sinU1=tanU1*cosU1;var sigma1=Math.atan2(tanU1,cosAlpha1);var sinAlpha=cosU1*sinAlpha1;var cosSqAlpha=1-sinAlpha*sinAlpha;var uSq=cosSqAlpha*(a*a-b*b)/(b*b);var A=1+uSq/16384*(4096+uSq*(-768+uSq*(320-175*uSq)));var B=uSq/1024*(256+uSq*(-128+uSq*(74-47*uSq)));var sigma=s/(b*A),sigmaP=2*Math.PI;while(Math.abs(sigma-sigmaP)>1e-12){var cos2SigmaM=Math.cos(2*sigma1+sigma);var sinSigma=Math.sin(sigma),cosSigma=Math.cos(sigma);var deltaSigma=B*sinSigma*(cos2SigmaM+B/4*(cosSigma*(-1+2*cos2SigmaM*cos2SigmaM)-
B/6*cos2SigmaM*(-3+4*sinSigma*sinSigma)*(-3+4*cos2SigmaM*cos2SigmaM)));sigmaP=sigma;sigma=s/(b*A)+deltaSigma;}
var tmp=sinU1*sinSigma-cosU1*cosSigma*cosAlpha1;var lat2=Math.atan2(sinU1*cosSigma+cosU1*sinSigma*cosAlpha1,(1-f)*Math.sqrt(sinAlpha*sinAlpha+tmp*tmp));var lambda=Math.atan2(sinSigma*sinAlpha1,cosU1*cosSigma-sinU1*sinSigma*cosAlpha1);var C=f/16*cosSqAlpha*(4+f*(4-3*cosSqAlpha));var L=lambda-(1-C)*f*sinAlpha*(sigma+C*sinSigma*(cos2SigmaM+C*cosSigma*(-1+2*cos2SigmaM*cos2SigmaM)));var revAz=Math.atan2(sinAlpha,-tmp);return new pH8.Geo.Point(lat2.toDegrees(),this.lon+L.toDegrees());},calculateBoundingBoxForDistance:function(distance){return this.calculateBoundingBoxForDistances(distance,distance);},calculateBoundingBoxForDistances:function(vertical,horizontal){var left=this.calculatePointAtBearingAndDistance(-90,horizontal).lon;return new pH8.Geo.Box(this.calculatePointAtBearingAndDistance(0,vertical).lat,this.calculatePointAtBearingAndDistance(180,vertical).lat,left,2*this.lon-left);},calculateDistanceToPoint:function(point){var a=6378388,b=6356911.946,f=1/297;var L=(point.lon-this.lon).toRadians();var U1=Math.atan((1-f)*Math.tan(this.lat.toRadians()));var U2=Math.atan((1-f)*Math.tan(point.lat.toRadians()));var sinU1=Math.sin(U1),cosU1=Math.cos(U1);var sinU2=Math.sin(U2),cosU2=Math.cos(U2);var lambda=L,lambdaP,iterLimit=100;do{var sinLambda=Math.sin(lambda),cosLambda=Math.cos(lambda);var sinSigma=Math.sqrt((cosU2*sinLambda)*(cosU2*sinLambda)+
(cosU1*sinU2-sinU1*cosU2*cosLambda)*(cosU1*sinU2-sinU1*cosU2*cosLambda));if(sinSigma==0)return 0;var cosSigma=sinU1*sinU2+cosU1*cosU2*cosLambda;var sigma=Math.atan2(sinSigma,cosSigma);var sinAlpha=cosU1*cosU2*sinLambda/sinSigma;var cosSqAlpha=1-sinAlpha*sinAlpha;var cos2SigmaM=cosSigma-2*sinU1*sinU2/cosSqAlpha;if(isNaN(cos2SigmaM))cos2SigmaM=0;var C=f/16*cosSqAlpha*(4+f*(4-3*cosSqAlpha));lambdaP=lambda;lambda=L+(1-C)*f*sinAlpha*(sigma+C*sinSigma*(cos2SigmaM+C*cosSigma*(-1+2*cos2SigmaM*cos2SigmaM)));}while(Math.abs(lambda-lambdaP)>1e-12&&--iterLimit>0);if(iterLimit==0)return NaN;var uSq=cosSqAlpha*(a*a-b*b)/(b*b);var A=1+uSq/16384*(4096+uSq*(-768+uSq*(320-175*uSq)));var B=uSq/1024*(256+uSq*(-128+uSq*(74-47*uSq)));var deltaSigma=B*sinSigma*(cos2SigmaM+B/4*(cosSigma*(-1+2*cos2SigmaM*cos2SigmaM)-
B/6*cos2SigmaM*(-3+4*sinSigma*sinSigma)*(-3+4*cos2SigmaM*cos2SigmaM)));var s=b*A*(sigma-deltaSigma);s=s.toFixed(3);return s;}});pH8.Geo.Box=Class.create({initialize:function(top,bottom,left,right){this.top=top;this.bottom=bottom;this.left=left;this.right=right;},size:function(){return{height:this.top-this.bottom,width:this.right-this.left};},position:function(){return new pH8.Geo.Point(this.top,this.left);},northWest:function(){return this.position();},southWest:function(){return new pH8.Geo.Point(this.bottom,this.left);},northEast:function(){return new pH8.Geo.Point(this.top,this.right);},southEast:function(){return new pH8.Geo.Point(this.bottom,this.right);}});pH8.Mixin.needsGoogleMaps={waitForGoogleMaps:function(callback){if(this.googleMapsLoaded){callback();}else{document.observe('googlemaps:loaded',callback);}},onGoogleMapsLoaded:function(){console.log('triggered');this.googleMapsLoaded=true;document.fire('googlemaps:loaded');return this.googleMapsLoaded;}};;pH8.Storage=(function(){var _instance=null;return function(type){if(_instance!==null){return _instance;}
_instance=this;this.set=function(name,value,ttl){var cookie=name+'='+escape(Object.toJSON(value));if(ttl){var time=new Date();time.setTime(time.getTime()+ttl);cookie=cookie+';expires='+time.toLocaleString();}
document.cookie=cookie;};this.get=function(name){var value=null;var cookie=document.cookie.match(name+'=([^;]+)');if(cookie){value=unescape(cookie[1].gsub('+','%20')).evalJSON(true);}
return value;};};})();;pH8.Dictionary=(function(){var _instance=null;var _list=null;return function(language){if(_instance!==null){return _instance;}
_instance=this;language=language||'';new Ajax.Request("/api/ajax.php?action=listDictionary&language="+language,{method:'get',onSuccess:function(transport){_list=transport.responseJSON;document.fire("dictionary:loaded");}});this.isLoaded=function(){return(null!==_list);};this.getText=function(key){if(_list[key]){return _list[key];}else{return key;}};};})();pH8.Mixin.needsDictionary={waitForDictionary:function(callback,language){var dictionary=new pH8.Dictionary(language);if(dictionary.isLoaded()){callback();}else{document.observe("dictionary:loaded",callback);}}};;pH8.Mixin.needsTemplates={waitForTemplates:function(templates,callback){this._templatesLoadedCallback=callback;this._templateUrlsByName=new Hash(templates);this._templateNamesByUrl=new Hash();this.templates={};this._templateUrlsByName.each(function(pair){this._templateNamesByUrl.set(pair.value,pair.key);new Ajax.Request(pair.value,{method:'get',parameters:{'v':pH8.SiteVersion},onSuccess:this.checkTemplates.bind(this)});}.bind(this));},checkTemplates:function(response){var name=this._templateNamesByUrl.get(response.request.url.stripQuery());if(name){var check=true;this.templates[name]=response.responseText;this._templateNamesByUrl.each(function(pair){if(!this.templates[pair.value]){check=false;}}.bind(this));if(check&&this._templatesLoadedCallback){this._templatesLoadedCallback();}}}};;pH8.Pages=(function(){var _instance=null;var _list=null;return function(language){if(_instance!==null){return _instance;}
_instance=this;new Ajax.Request("/api/ajax.php?action=listPages",{method:'get',onSuccess:function(transport){_list=transport.responseJSON;document.fire("pages:loaded");}});this.isLoaded=function(){return(null!==_list);};this.getList=function(){return _list;};this.getPage=function(key){if(_list[key]){return _list[key];}else{return key;}};};})();pH8.Mixin.needsPages={waitForPages:function(callback){var pages=new pH8.Pages();if(pages.isLoaded()){callback();}else{document.observe("pages:loaded",callback);}}};;pH8.Page=(function(){var _widgetList=[];var _readyList=[];var _instance=null;var _status=false;return function(){if(_instance!==null){return _instance;}
_instance=this;this.registerWidget=function(widget){_widgetList[_widgetList.size()]=widget;_readyList[_readyList.size()]=false;};this.widgetReady=function(widget){var index=_widgetList.indexOf(widget);if(index!==false){_readyList[index]=true;var status=true;_readyList.each(function(value,key){status=(status==true&&value==true);});if(status){_status=true;document.fire('page:ready',{widgets:_widgetList});}}};this.widgetsReady=function(){return _status;};this.setState=function(key,value){var storage=new pH8.Storage();var state=storage.get('state');state=state?state:{};state[key]=value;storage.set('state',state);};this.getState=function(key){var storage=new pH8.Storage();var state=storage.get('state');if(key){return state[key];}else{return state;}};};})();pH8.Mixin.needsSocialWidgets={waitForSocialWidgets:function(callback){var page=new pH8.Page();if(page.widgetsReady()){callback();}else{document.observe('page:ready',callback);}},registerWidget:function(widget){var page=new pH8.Page();page.registerWidget(widget);},widgetReady:function(widget){var page=new pH8.Page();page.widgetReady(widget);}};;pH8.Config=(function(){var _instance=null;var _list=null;return function(language){if(_instance!==null){return _instance;}
_instance=this;new Ajax.Request("/api/site?query=config",{method:'get',onSuccess:function(transport){_list=transport.responseJSON;document.fire("config:loaded");}});this.isLoaded=function(){return(null!==_list);};this.getList=function(){return _list;};this.getConfig=function(key){if(_list[key]){return _list[key];}else{return key;}};};})();pH8.Mixin.needsConfig={waitForConfig:function(callback){var config=new pH8.Config();if(config.isLoaded()){callback();}else{document.observe("config:loaded",callback);}}};;pH8.Menu=Class.create({initialize:function(element,options){this.element=$(element);this.position=this.element.cumulativeOffset();this.dimensions=this.element.getDimensions();options=options||{};this.options={};this.options.activeClassName=options.activeClassName||'active';this.state={activeElement:element.down('li.active'),hoveredElement:null};if(this.state.activeElement){this.showSubmenu(this.state.activeElement);}
this.element.observe('mouseover',this.onMouseOver.bindAsEventListener(this));this.element.observe('mouseout',this.onMouseOut.bindAsEventListener(this));this.element.observe('click',this.onClick.bindAsEventListener(this));},positionSubmenu:function(menuElement){menuElement.setStyle({position:'static'});var maxOffset=this.element.positionedOffset().left+this.element.getWidth();var submenuElement=menuElement.down('ul');var offsetLeft=menuElement.positionedOffset().left;var width=0;if(submenuElement){submenuItemElements=submenuElement.select('li');submenuItemElements.each(function(element){width+=element.getWidth();});submenuElement.setStyle({'width':width+'px'});if(offsetLeft<8){offsetLeft=8;}
if(offsetLeft+width>maxOffset){offsetLeft=maxOffset-width-10;}
submenuElement.setStyle({left:offsetLeft+'px',top:'50px'});}},contains:function(x,y){return(x>this.position.left&&x<(this.position.left+this.dimensions.width)&&y>this.position.top&&y<(this.position.top+this.dimensions.height));},showSubmenu:function(menuElement){menuElement.addClassName(this.options.activeClassName);menuElement.siblings().each(function(otherMenuElement){otherMenuElement.removeClassName(this.options.activeClassName);}.bind(this));this.state.hoveredElement=menuElement;if(window['Cufon']){Cufon.refresh('.menu li a');}
this.positionSubmenu(menuElement);},onMouseOver:function(event){me=event.findElement('li');if(me&&me.up('ul')==this.element){this.showSubmenu(me);}
if(this.timer){this.timer.stop();this.timer=null;}},onMouseOut:function(event){me=event.element();if(!this.contains(event.pointerX(),event.pointerY())){this.timer=new PeriodicalExecuter(function(pe){pe.stop();if(this.state.hoveredElement){this.state.hoveredElement.removeClassName(this.options.activeClassName);}
if(this.state.activeElement){this.showSubmenu(this.state.activeElement);}else{Cufon.refresh('.menu li a');}}.bind(this),0.5);}},onClick:function(event){me=event.findElement('li');if(me&&me.up('ul')==this.element){event.stop();}}});;pH8.Loader=Class.create({initialize:function(src,async,options){var s=new Element('script',{type:"text/javascript",src:src,async:async});this.options=Object.extend({containerSelector:'head'},options||{});var container=$$(this.options.containerSelector)[0];container.appendChild(s);}});;var TrackingCode=Class.create({initialize:function(element,options){this.element=$(element);this.options=Object.extend({placeHolder:$('analytics-placeholder')},options||{});var type=this.element.getClassParameter('trackType');var random=Math.round(Math.random()*10000000000);switch(type){case'smart':var src='http://www.smartadserver.com/track/pix.asp?'+this.element.getClassParameter('trackCode1')+';'+this.element.getClassParameter('trackCode2')+';'+random;this.options.placeHolder.appendChild(new Element('img',{width:1,height:1,border:0,src:src}));break;case'doubleclick':var src='http://fls.doubleclick.net/activityi;src='+this.element.getClassParameter('trackCode1')+';type='+this.element.getClassParameter('trackCode2')+';cat='+this.element.getClassParameter('trackCode3')+';ord='+random;this.options.placeHolder.appendChild(new Element('iframe',{width:1,frameborder:0,height:1,border:0,src:src}));break;case'marktplaats':var src='http://tr.wl.marktplaats.net/Cnt/Marktplaats/CP/'+this.element.getClassParameter('trackCode1')+'?d='+random;this.options.placeHolder.appendChild(new Element('img',{width:1,height:1,border:0,src:src}));break;case'webads':var src='http://tr.wl.webads.nl/Cnt/WebAds/CP/'+this.element.getClassParameter('trackCode1')+'?d='+random;this.options.placeHolder.appendChild(new Element('img',{width:1,height:1,border:0,src:src}));break;case'adsfac':var src='http://adsfac.eu/pct_mx.asp?L='+this.element.getClassParameter('trackCode1')+'&source=if';this.options.placeHolder.appendChild(new Element('iframe',{width:1,frameborder:0,height:1,border:0,src:src}));break;}}});;Accordion=Class.create({initialize:function(element,options){this.element=$(element);this.options={};this.options.openClass=options.openClass||'active';this.options.duration=options.duration||0.5;this.openElement=element.down('dd.'+this.options.openClass);this.isAnimating=false;this.element.observe('click',this.clickHandler.bindAsEventListener(this));},clickHandler:function(event){var me=event.findElement('a');if(me&&me.match('dt a')){event.stop();var dt=me.up('dt');if(dt){this.animateElement(dt.next('dd'));}}},animateElement:function(element){if(!this.isAnimating){var effects=new Array();var options={};if(!this.openElement||this.openElement!=element){options={sync:true,scaleFrom:0,scaleContent:false,scaleMode:'contents',transition:Effect.Transitions.sinoidal,scaleX:false,scaleY:true};effects.push(new Effect.Scale(element,100,options));}
if(this.openElement){options={sync:true,scaleContent:false,scaleMode:'contents',transition:Effect.Transitions.sinoidal,scaleX:false,scaleY:true};effects.push(new Effect.Scale(this.openElement,0,options));}
new Effect.Parallel(effects,{duration:this.options.duration,fps:35,queue:{position:'end',scope:'accordion'},beforeStart:function(){this.isAnimating=true;element.addClassName(this.options.openClass);element.previous('dt').addClassName(this.options.openClass);}.bind(this),afterFinish:function(){if(this.openElement){this.openElement.removeClassName(this.options.openClass);this.openElement.previous('dt').removeClassName(this.options.openClass);}
if(this.openElement==element){this.openElement=null;}else{this.openElement=element;}
this.isAnimating=false;}.bind(this)});}}});;TabRotator=Class.create({initialize:function(element,options){this.element=$(element);this.options=Object.extend({contentElementSelector:'.detail',tabsElementSelector:'.list',interval:3,parameterName:'id',activeClass:'active',animateLoader:false,animatingLoaderClass:'loader-animating',animationClassPrefix:'state-',animationDuration:1,animationFrames:1,useActivatorOrder:true},options||{});this.contentElement=this.element.down(this.options.contentElementSelector);this.contentElements=this.contentElement.childElements();this.tabsElement=this.element.down(this.options.tabsElementSelector);this.tabElements=this.tabsElement.childElements();this.linkElements=this.tabsElement.select('a');this.activeIndex=this.tabElements.indexOf(this.tabsElement.down('.'+this.options.activeClass));this.zIndex=2;Event.observe(this.tabsElement,'click',this.clickHandler.bindAsEventListener(this));if(this.options.animateLoader){this.frameRegExp=new RegExp('('+this.options.animationClassPrefix+')(\\d+)');this.frameRegExp.compile();this.tabsElement.addClassName(this.options.animatingLoaderClass);this.animationInterval=this.options.animationDuration/this.options.animationFrames;this.startAnimating();}
if(this.options.interval>0){this.timer=new PeriodicalExecuter(this.timerHandler.bindAsEventListener(this),this.options.interval);}},clickHandler:function(event){var link=event.findElement('a');if(link){this.stopAnimating();var tabOrder=this.linkElements.indexOf(link);if(tabOrder>=0){this.timer.stop();this.activateTab(tabOrder);}
link.blur();event.stop();}},timerHandler:function(){if(this.tabElements[this.activeIndex+1]){this.stopAnimating();this.activateTab(this.activeIndex+1);this.startAnimating();}else{this.stopAnimating();this.activateTab(0);this.startAnimating();}},setFrame:function(element,frame){element.className=element.className.replace(this.frameRegExp,"$1"+frame);},startAnimating:function(element){if(this.options.animateLoader){this.activeFrame=1;this.linkElements[this.activeIndex].addClassName(this.options.animationClassPrefix+this.activeFrame);this.animationTimer=new PeriodicalExecuter(this.animationTimerHandler.bindAsEventListener(this),this.animationInterval);}},stopAnimating:function(element){if(this.options.animateLoader){this.animationTimer.stop();this.setFrame(this.linkElements[this.activeIndex],1);}},animationTimerHandler:function(){if(this.activeFrame==this.options.animationFrames){this.activeFrame=1;}else{this.activeFrame+=1;}
this.setFrame(this.linkElements[this.activeIndex],this.activeFrame);},activateTab:function(tabOrder){if(tabOrder!=this.activeIndex){this.tabElements[this.activeIndex].removeClassName(this.options.activeClass);this.contentElements[tabOrder].hide();this.contentElements[tabOrder].addClassName(this.options.activeClass);this.contentElements[this.activeIndex].setStyle({'z-index':this.zIndex-1});this.contentElements[tabOrder].setStyle({'z-index':this.zIndex});new Effect.Appear(this.contentElements[tabOrder],{duration:0.3,afterFinish:function(transport){this.contentElements[this.activeIndex].removeClassName(this.options.activeClass);this.activeIndex=tabOrder;}.bind(this)});this.tabElements[tabOrder].addClassName(this.options.activeClass);}}});;CardOverview=Class.create({initialize:function(element,options){this.element=$(element);this.options=Object.extend({containerwidth:980,margin:150,itemwidth:500,focus:0,ecardTemplateUrl:'/js/templates/ecard.tpl'},options||{});Object.extend(this,pH8.Mixin.needsPages);Object.extend(this,pH8.Mixin.needsTemplates);Object.extend(this,pH8.Mixin.needsDictionary);this.loadedMixins=[];this.waitForTemplates({ecard:this.options.ecardTemplateUrl},function(event){this.loadedMixins['templates']=true;this.ready();}.bind(this));this.waitForDictionary(function(event){this.dictionary=new pH8.Dictionary();this.loadedMixins['dictionary']=true;this.ready();}.bind(this));this.waitForPages(function(event){this.pages=new pH8.Pages();this.loadedMixins['pages']=true;this.ready();}.bind(this));this.count=0;this.cardElements=this.element.down('.cards');this.cards=[];this.initializePostcards();this.minX=(this.options.containerwidth/2)-(this.options.itemwidth/2)-(this.options.margin/2);this.maxX=-(((this.count-1)*(this.options.itemwidth+this.options.margin))-(this.options.containerwidth/2)+(this.options.itemwidth/2)+(this.options.margin/2));this.cardElements.setStyle({'width':this.count*(this.options.itemwidth+this.options.margin)+'px'});this.element.down('.props').setStyle({'width':((this.count-1)*(this.options.itemwidth+this.options.margin))/2+980+'px'});this.setTrackingEvents();},initializePostcards:function(){this.cardElements.select('.card').each(function(div,position){this.cards[position]=new Postcard(div,position,this,{});this.count=position+1;}.bind(this));},ready:function(){if(!this.loadedMixins['dictionary']||!this.loadedMixins['templates']||!this.loadedMixins['pages']){return false;}
Event.observe(document,'keyup',this.keyupHandler.bindAsEventListener(this));new Draggable(this.cardElements,{'constraint':'horizontal','handle':this.element.down('.rope'),'starteffect':false,'endeffect':false,'onDrag':this.handleDrag.bindAsEventListener(this),'horizontalConstraint':[this.minX,this.maxX]});Event.observe(this.element,'DOMMouseScroll',this.wheel.bindAsEventListener(this));Event.observe(this.element,'mousewheel',this.wheel.bindAsEventListener(this));},fetchNeighbor:function(currentActive,delta){var updateCard=this.cards[(currentActive*1)+delta];if(!updateCard){return;}
if(!updateCard.itemID&&!updateCard.isUpdating){updateCard.isUpdating=true;new Ajax.Request('/api/ecardneighbor',{method:'get',parameters:{'key':currentActive*1+delta},onComplete:function(transport){if(transport.status==200){updateCard.setCardData(transport.responseText.evalJSON());}}.bind(this)});}},setTrackingEvents:function(){this.element.down('.props').observe('click',function(event){var me=(event.element().match('.prop'))?event.element():event.element().up('.prop');if(me&&me.match('.plant')){pageTracker._trackEvent('ecards','prop clicked','plant');}
if(me&&me.match('.lamp')){console.log('erh, what are you doing with that lamp?');pageTracker._trackEvent('ecards','prop clicked','lamp');}
if(me&&me.match('.table')){pageTracker._trackEvent('ecards','prop clicked','table');}});},focusItem:function(position){if(position<0){position=0;}
if(position>this.count-1){position=this.count-1;}
this.fetchNeighbor(position,2);this.fetchNeighbor(position,-2);this.fetchNeighbor(position,1);this.fetchNeighbor(position,-1);var newPoint=-((position*(this.options.itemwidth+this.options.margin))-(this.options.containerwidth/2)+(this.options.itemwidth/2)+(this.options.margin/2));new Effect.Move(this.cardElements,{x:newPoint,y:0,mode:'absolute',duration:0.3});new Effect.Morph(this.element,{style:{'backgroundPosition':newPoint/4+'px 0'},duration:0.3});new Effect.Move(this.element.down('.props'),{x:(newPoint/2)-83,y:0,mode:'absolute',duration:0.3});},getCurrentActive:function(){var currentX=this.cardElements.positionedOffset()[0];var active=((-currentX)+(this.options.containerwidth/2)-(this.options.itemwidth/2)-(this.options.margin/2))/(this.options.itemwidth+this.options.margin);return Math.round(active);},wheel:function(event){var delta=0;if(!event){event=window.event;}
if(event.wheelDelta){delta=event.wheelDelta/120;if(window.opera){delta=-delta;}}else if(event.detail){delta=-event.detail/3;}
if(delta){this.handleWheel(delta);}
if(event.preventDefault){event.preventDefault();}
event.returnValue=false;},handleWheel:function(delta){this.cardElements.setStyle({'left':this.cardElements.positionedOffset()[0]+delta*10+'px'});this.handleDrag(null);},keyupHandler:function(event){if(event.keyCode==39){this.getCurrentActive();this.focusItem(this.getCurrentActive()+1);}
if(event.keyCode==37){this.getCurrentActive();this.focusItem(this.getCurrentActive()-1);}},handleDrag:function(dragObject){var currentX=this.cardElements.positionedOffset()[0];this.fetchNeighbor(this.getCurrentActive(),2);this.fetchNeighbor(this.getCurrentActive(),-2);if(this.minX<=currentX){this.cardElements.setStyle({'left':this.minX+'px'});currentX=this.minX;}
if(currentX<=this.maxX){this.cardElements.setStyle({'left':this.maxX+'px'});currentX=this.maxX;}
this.element.setStyle({'backgroundPosition':currentX/4+'px 0'});this.element.down('.props').setStyle({'left':(currentX/2)-83+'px'});}});;Postcard=Class.create({initialize:function(element,position,overviewDelegate,options){this.element=$(element);this.position=position;this.overviewDelegate=overviewDelegate;this.options=Object.extend({},options||{});this.itemID=this.element.getClassParameter('itemID')||false;Event.observe(this.element,'click',this.clickHandler.bindAsEventListener(this));},clickHandler:function(event){if(event.element().match('.close')){this.showFront();event.preventDefault();}
else if((event.findElement('.back input, .back button, .back a, .back label'))&&this.position==this.overviewDelegate.getCurrentActive()){}else{this.overviewDelegate.focusItem(this.position);if(this.position==this.overviewDelegate.getCurrentActive()){this.showBack();}
event.stop();}},setCardData:function(jsonData){this.itemID=jsonData.card.itemID;jsonData.card.cardURL=window.location.protocol+'//'+window.location.hostname+'/vakantiekaart/'+this.itemID;jsonData.dictionary=this.overviewDelegate.dictionary;jsonData.abuse=this.overviewDelegate.options.abuse;jsonData.abuse_body=this.overviewDelegate.dictionary.getText('abuse_body').sub(/\%s/,jsonData.card.bitly);jsonData.card.text=jsonData.card.text.gsub('"',"'");this.element.update(this.overviewDelegate.templates.ecard.process(jsonData));this.isUpdating=false;FB.XFBML.parse(this.element);Event.addBehavior(form_rules);},showBack:function(){this.element.addClassName('active-card');pageTracker._trackEvent('ecards','card show backside',this.itemID);},showFront:function(){this.element.removeClassName('active-card');pageTracker._trackEvent('ecards','card show frontside',this.itemID);}});;FaceBookConnector=Class.create({initialize:function(element,options){this.element=$(element);this.element.appendChild(new Element('div',{id:'fb-root'}));this.options=Object.extend({locale:'en_US'},options||{});this.loader=new pH8.Loader(document.location.protocol+'//connect.facebook.net/'+this.options.locale+'/all.js',true,{containerSelector:'#fb-root'});window.fbAsyncInit=function(){FB.init({appId:this.options.apiKey,status:true,cookie:true,xfbml:true});FB.XFBML.parse();}.bind(this);}});;Maps={};Maps.Version='1.0';Maps.CompatibleWithPH8='2';if(pH8.Version.indexOf(Maps.CompatibleWithPH8)!==0&&console&&console.warn)
console.warn("This version of Maps extensions is tested with pH8 "+Maps.CompatibleWithPH8+" it may not work as expected with this version ("+pH8.Version+")");if(!window.google||!window.google.maps&&console&&console.warn)
console.warn("Maps extensions needs Google Maps API");;Maps.LocationsTable=Class.create({initialize:function(element,options){var page=new pH8.Page();page.registerWidget(this);Object.extend(this,pH8.Mixin.needsDictionary);Object.extend(this,pH8.Mixin.needsTemplates);Object.extend(this,pH8.Mixin.needsPages);this.element=$(element);this.options=Object.extend({locationKey:'locationID',checkForMapDataModifier:false,autoZoom:true,boundingBoxMultiplier:1.1},options||{});this.waitForDictionary(this.onDictionaryLoaded.bind(this));this.waitForPages(this.onPagesLoaded.bind(this));this.waitForTemplates({locationsTable:this.options.locationsTableTemplateUrl},this.onTemplatesLoaded.bind(this));this.rowIndexesByLocationKey={};this.currentRequest=null;},eventHandlers:{click:function(event){var tr=event.findElement('tr');if(tr){var a=tr.down('a');if(a){window.location.href=a.href;}}
event.stop();},mouseover:function(event){var tr=event.findElement('tr');if(tr){var a=tr.down('a');if(a){var query=a.href.toQueryParams();document.fire('map:highlight',{locationKey:query[this.options.locationKey]});}}}},showLocations:function(){var html=this.templates.locationsTable.process({state:'success',locations:this.locations,dictionary:this.dictionary,pages:this.pages.getList()});this.element.update(html);},showLoader:function(){var html=this.templates.locationsTable.process({state:'loading',dictionary:this.dictionary,pages:this.pages.getList()});this.element.update(html);},showError:function(error){var html=this.templates.locationsTable.process({state:'error',error:error,dictionary:this.dictionary,pages:this.pages.getList()});this.element.update(html);},onLocationsFound:function(response){this.currentRequest=null;this.locations=[];if(response.responseJSON&&response.responseJSON.members){response.responseJSON.members.each(function(location,index){if(this.bounds.containsLatLng(new google.maps.LatLng(location.latitude,location.longitude))){this.locations.push(location);this.rowIndexesByLocationKey[location[this.options.locationKey]]=this.locations.size()-1;}}.bind(this));}
this.showLocations();document.fire('map:newdata',{locations:this.locations});this.newSearch=false;},onLocationsError:function(response){this.currentRequest=null;if(response.responseJSON){if(response.status==416&&this.newSearch&&this.options.autoZoom){document.fire('map:zoomin');}else{this.showError(response.responseJSON);document.fire('map:newdata',{locations:[]});this.newSearch=false;}}},handleGetData:function(event){if(event.memo.bounds){this.bounds=event.memo.bounds;this.cachedBounds=this.calculateCachedBoundingBox(event.memo.bounds,event.memo.zoomLevel);}
if(event.memo.position){if(this.position!=event.memo.position){this.position=event.memo.position;this.newSearch=true;}}
if(event.memo.searchName){if(this.searchName!=event.memo.searchName){this.searchName=event.memo.searchName;this.filters={};this.newSearch=true;}}
if(event.memo.filters){this.filters=event.memo.filters;}
if(this.cachedBounds&&this.position&&this.searchName){this.showLoader();document.fire('map:cleardata',{});var sw=this.cachedBounds.getSouthWest();var ne=this.cachedBounds.getNorthEast();if(this.currentRequest){this.currentRequest.transport.abort();}
this.currentRequest=new Ajax.Request(this.options.dataUrl,{method:'get',parameters:Object.extend({type:'json',latitude:this.position.lat(),longitude:this.position.lng(),north:ne.lat(),east:ne.lng(),south:sw.lat(),west:sw.lng(),search_name:this.searchName},this.filters),onSuccess:this.onLocationsFound.bind(this),onFailure:this.onLocationsError.bind(this)});}},handleNewZoomLevel:function(event){this.bounds=null;this.handleSelect(event);},calculateCachedBoundingBox:function(bounds,zoomLevel){var sw=bounds.getSouthWest();var ne=bounds.getNorthEast();var width=ne.lng()-sw.lng();var height=ne.lat()-sw.lat();var projection=new google.maps.MercatorProjection(19);var nePixels=projection.fromLatLngToPixel(ne,zoomLevel);var swPixels=projection.fromLatLngToPixel(sw,zoomLevel);var pixelWidth=nePixels.x-swPixels.x;var leftBound=pixelWidth*Math.floor(swPixels.x/pixelWidth);var rightBound=leftBound+2*pixelWidth;var pixelHeight=nePixels.y-swPixels.y;var topBound=pixelHeight*Math.ceil(nePixels.y/pixelHeight);var bottomBound=pixelHeight*Math.floor(swPixels.y/pixelHeight);var neLatLng=projection.fromPixelToLatLng(new google.maps.Point(rightBound,topBound),zoomLevel);var swLatLng=projection.fromPixelToLatLng(new google.maps.Point(leftBound,bottomBound),zoomLevel);return new google.maps.LatLngBounds(swLatLng,neLatLng);},handleHighlight:function(event){if(event.memo.locationKey){var table=this.element.down('table');var rows=table.down('tbody').select('tr');rows.each(function(row,index){if(index==this.rowIndexesByLocationKey[event.memo.locationKey]){row.addClassName('selected');}else{row.removeClassName('selected');}}.bind(this));}},handleSelect:function(event){if(event.memo.locationKey){var table=this.element.down('table');var rows=table.down('tbody').select('tr');var index=this.rowIndexesByLocationKey[event.memo.locationKey];document.location.href=rows[index].down('a').href;}},onDictionaryLoaded:function(event){this.dictionary=new pH8.Dictionary();this.dictionaryLoaded=true;this.onReady();},onPagesLoaded:function(event){this.pages=new pH8.Pages();this.pagesLoaded=true;this.onReady();},onTemplatesLoaded:function(){this.templatesLoaded=true;this.onReady();},onReady:function(){if(this.dictionaryLoaded&&this.templatesLoaded&&this.pagesLoaded){if(this.options.dataUrl){document.observe('map:getdata',this.handleGetData.bindAsEventListener(this));document.observe('map:select',this.handleSelect.bindAsEventListener(this));document.observe('map:highlight',this.handleHighlight.bindAsEventListener(this));this.element.observe('mouseover',this.eventHandlers.mouseover.bindAsEventListener(this));this.element.observe('click',this.eventHandlers.click.bindAsEventListener(this));}
document.observe('page:ready',this.onPageReady.bindAsEventListener(this));var page=new pH8.Page();page.widgetReady(this);}},onPageReady:function(event){}});;Maps.Map=Class.create({initialize:function(element,options){Object.extend(this,pH8.Mixin.needsSocialWidgets);this.registerWidget(this);Object.extend(this,pH8.Mixin.needsDictionary);Object.extend(this,pH8.Mixin.needsPages);Object.extend(this,pH8.Mixin.needsTemplates);this.element=$(element);this.element.setStyle({visibility:'hidden'});this.options=Object.extend({language:'en',startPoint:new google.maps.LatLng(51.9247240,4.4744973),startZoom:10,minZoom:6,scrollWheel:false,allowDuplicateValue:true,locationKey:'locationID'},options||{});this.locations=new Hash();this.markers=new Hash();this.geocoder=new google.maps.ClientGeocoder();this.waitForDictionary(this.onDictionaryLoaded.bind(this));this.waitForPages(this.onPagesLoaded.bind(this));this.waitForTemplates({infoWindow:this.options.infoWindowTemplateUrl},this.onTemplatesLoaded.bind(this));},saveState:function(data){var page=new pH8.Page();page.setState('map_lat',this.map.getCenter().lat());page.setState('map_lng',this.map.getCenter().lng());page.setState('map_zoom',this.map.getZoom());document.location.href=document.location.href.addHashParam('restoreState',1);},mapClickHandler:function(marker){if(marker){var markerKey=this.markers.index(marker);if(markerKey){document.fire('map:select',{locationKey:markerKey});}}},mapMoveHandler:function(){if(this.handleEvents){document.fire('map:getdata',{position:this.position,bounds:this.map.getBounds(),zoomLevel:this.map.getZoom(),searchName:this.searchName});this.saveState();}},handleSearch:function(event){this.searchName=event.memo.searchName;this.filters=event.memo.filters||{};if(event.memo.position){this.position=event.memo.position;this.showPosition();}else{if(!this.geocoder){this.geocoder=new google.maps.ClientGeocoder();}
this.geocoder.getLatLng(event.memo.searchString,function(coordinate){if(coordinate){this.position=coordinate;this.showPosition();}}.bind(this));}},mapZoomHandler:function(oldZoomLevel,newZoomLevel){document.fire('map:newzoomlevel',{oldZoomLevel:oldZoomLevel,newZoomLevel:newZoomLevel,bounds:this.map.getBounds(),position:this.position,searchName:this.searchName});},handleZoomIn:function(event){this.clearMarkers();this.map.zoomIn();},handleClearData:function(event){this.clearMarkers();},handleNewData:function(event){this.clearMarkers();var locations=event.memo.locations;var selected=event.memo.selected;if(locations){locations.each(function(location){if(selected&&selected.get(id)){marker=this.createMarker(new google.maps.LatLng(parseFloat(location.latitude),parseFloat(location.longitude)),'selected',location.name);}else{marker=this.createMarker(new google.maps.LatLng(parseFloat(location.latitude),parseFloat(location.longitude)),'normal',location.name);}
var markerKey=location[this.options.locationKey];this.markers.set(markerKey,marker);this.map.addOverlay(marker);google.maps.Event.addListener(marker,'mouseover',function(){document.fire('map:highlight',{locationKey:markerKey});});}.bind(this));}},handleHighlight:function(event){if(event.memo.locationKey){var marker=this.markers.get(event.memo.locationKey);if(this.activeMarker){this.activeMarker.setImage(this.options.icons.normal.url);}
if(marker){marker.setImage(this.options.icons.selected.url);this.activeMarker=marker;}}},showPosition:function(){this.handleEvents=false;if(this.positionMarker){this.map.removeOverlay(this.positionMarker);}
this.map.setCenter(this.position);this.map.setZoom(this.options.startZoom);this.positionMarker=this.createMarker(this.position,'position',this.dictionary.getText('your position'));this.map.addOverlay(this.positionMarker);this.element.setStyle({visibility:'visible'});document.fire('map:getdata',{position:this.position,bounds:this.map.getBounds(),zoomLevel:this.map.getZoom(),searchName:this.searchName,filters:this.filters});this.saveState();this.handleEvents=true;},restoreState:function(){var page=new pH8.Page();var savedState=page.getState();if(savedState){this.handleEvents=false;if(this.positionMarker){this.map.removeOverlay(this.positionMarker);}
this.position=new google.maps.LatLng(savedState.latitude,savedState.longitude);this.searchName=savedState.searchName;this.filters=savedState.filters;this.map.setCenter(new google.maps.LatLng(savedState.map_lat,savedState.map_lng));this.map.setZoom(savedState.map_zoom);this.positionMarker=this.createMarker(this.position,'position',this.dictionary.getText('your position'));this.map.addOverlay(this.positionMarker);this.element.setStyle({visibility:'visible'});document.fire('map:getdata',{position:this.position,bounds:this.map.getBounds(),zoomLevel:this.map.getZoom(),searchName:this.searchName,filters:this.filters});this.handleEvents=true;}},createMarker:function(point,markerStyle,title){if(this.options.icons&&this.options.icons[markerStyle]){var icon=new google.maps.Icon(G_DEFAULT_ICON,this.options.icons[markerStyle].url);icon.iconSize=new google.maps.Size(this.options.icons[markerStyle].size[0],this.options.icons[markerStyle].size[1]);icon.iconAnchor=new google.maps.Point(Math.ceil(this.options.icons[markerStyle].size[0]/2),Math.ceil(this.options.icons[markerStyle].size[1]));icon.infoWindowAnchor=new google.maps.Point(10,10);icon.shadow=this.options.icons[markerStyle].shadowUrl;return new google.maps.Marker(point,{icon:icon,title:title});}
return new google.maps.Marker(point,{title:title});},showMarkers:function(){var manager=new google.maps.MarkerManager(this.map,{borderPadding:100});manager.addMarkers(this.markers,this.options.markerZoom);manager.refresh();if(this.options.startLocationId&&this.markersByLocationId[this.options.startLocationId]){this.showInfo(this.markersByLocationId[this.options.startLocationId]);}},clearMarkers:function(){this.markers.each(function(pair){this.map.removeOverlay(pair.value);google.maps.Event.clearListeners(pair.value,'mouseover');}.bind(this));this.markers=new Hash();this.activeMarker=null;},showInfo:function(marker){var i=this.markers.values().indexOf(marker);if(i>-1){this.map.panTo(marker.getLatLng());var html=this.templates.infoWindow.process({language:this.options.language,dictionary:this.dictionary,location:this.locations.get(this.locations.keys()[i])});marker.openInfoWindowHtml(html,{maxWidth:400});}},onDictionaryLoaded:function(event){this.dictionary=new pH8.Dictionary();this.dictionaryLoaded=true;this.onReady();},onPagesLoaded:function(event){this.pages=new pH8.Pages();this.pagesLoaded=true;this.onReady();},onTemplatesLoaded:function(){this.templatesLoaded=true;this.onReady();},onReady:function(){if(this.dictionaryLoaded&&this.templatesLoaded&&this.pagesLoaded){this.map=new google.maps.Map2(this.element);this.map.setCenter(this.options.startPoint,this.options.minZoom);this.map.addControl(new google.maps.SmallZoomControl3D());this.map.setMapType(G_NORMAL_MAP);this.element.setStyle({visibility:'visible'});if(this.options.disableDragging){this.map.disableDragging();}
this.map.enableContinuousZoom();if(this.options.scrollWheel){this.map.enableScrollWheelZoom();}
google.maps.Event.addListener(this.map,'click',this.mapClickHandler.bind(this));google.maps.Event.addListener(this.map,'moveend',this.mapMoveHandler.bind(this));google.maps.Event.addListener(this.map,'zoomend',this.mapZoomHandler.bind(this));document.observe('map:search',this.handleSearch.bindAsEventListener(this));document.observe('map:cleardata',this.handleClearData.bindAsEventListener(this));document.observe('map:zoomin',this.handleZoomIn.bindAsEventListener(this));document.observe('map:newdata',this.handleNewData.bindAsEventListener(this));document.observe('map:highlight',this.handleHighlight.bindAsEventListener(this));this.waitForSocialWidgets(this.onPageReady.bindAsEventListener(this));this.widgetReady(this);}},onPageReady:function(event){var query=document.location.href.parseExtendedQuery();if(query.restoreState){this.restoreState();}}});;Maps.MembersDetailsMap=Class.create(Maps.Map,{initialize:function($super,element,options){$super(element,options);},onPageReady:function(event){if(this.options.autoLoad){var location=Element.getClassParameters(this.element);this.element.setStyle({visibility:'visible'});document.fire('map:newdata',{locations:[location]});}},handleNewData:function(event){this.clearMarkers();var locations=event.memo.locations;if(locations){if(locations.size()==1){var location=locations[0];marker=this.createMarker(new google.maps.LatLng(parseFloat(location.latitude),parseFloat(location.longitude)),'normal',location.name);this.markers.set(location[this.options.locationKey],marker);this.map.addOverlay(marker);this.map.setCenter(marker.getLatLng(),this.options.minZoom);}}},createMarker:function(point,markerStyle,title){if(this.options.icons&&this.options.icons[markerStyle]){var icon=new google.maps.Icon(G_DEFAULT_ICON,this.options.icons[markerStyle].url);icon.iconSize=new google.maps.Size(this.options.icons[markerStyle].size[0],this.options.icons[markerStyle].size[1]);icon.shadow=this.options.icons[markerStyle].shadowUrl;return new google.maps.Marker(point,{icon:icon,title:title,clickable:false});}
return new google.maps.Marker(point,{title:title,clickable:false});},handleSelect:function(e){return;}});;Maps.Filter=Class.create({initialize:function(element,options){Object.extend(this,pH8.Mixin.needsSocialWidgets);this.registerWidget(this);Object.extend(this,pH8.Mixin.needsDictionary);Object.extend(this,pH8.Mixin.needsPages);Object.extend(this,pH8.Mixin.needsTemplates);this.element=$(element);this.options=Object.extend({noSubmitClassName:'no-submit',filterSwitchClassName:'filter-switch',filterSwitchSubfilterClassName:'filter-switch-subfilter'},options||{});this.waitForDictionary(this.onDictionaryLoaded.bind(this));this.waitForPages(this.onPagesLoaded.bind(this));this.waitForTemplates({filter:this.options.filterTemplateUrl},this.onTemplatesLoaded.bind(this));this.savedState={};},saveState:function(data){var page=new pH8.Page();page.setState('filters',data);document.location.href=document.location.href.addHashParam('restoreState',1);},restoreState:function(){var page=new pH8.Page();this.savedState=page.getState();if(this.savedState){this.loadFilter(this.savedState.searchName);}},restoreFilters:function(){var form=this.element.down('form');form.getElements().each(function(element){element=$(element);if(this.savedState.filters[element.name]){if(element.tagName=='INPUT'){if(element.type=='radio'){if(element.readAttribute('value')==this.savedState.filters[element.name]){element.checked=true;}}else{element.setValue(this.savedState.filters[element.name]);}}else if(element.tagName=='SELECT'){element.setValue(this.savedState.filters[element.name]);}
if(element.hasClassName(this.options.filterSwitchSubfilterClassName)){var filter=element.up('fieldset').previous('label').down('input');filter.checked=true;this.enableFilter(filter);}}}.bind(this));},enableFilter:function(filter){var form=$(filter.form);form.select('input.'+this.options.filterSwitchClassName+'[type=radio]').each(function(switchElement){switchElement.up('label').next('fieldset').select('input,select').each(function(subFilterElement){subFilterElement.disable();});});filter.up('label').next('fieldset').select('input,select').each(function(subFilterElement){subFilterElement.enable();});},onChange:function(event){var me=event.element();var form=$(me.form);if(me.hasClassName(this.options.filterSwitchClassName)){this.enableFilter(me);}
var fire=true;if(!me.hasClassName(this.options.noSubmitClassName)){if(form!=document){var activeElements=[];form.getElements().each(function(element,index){if(!element.hasClassName(this.options.filterSwitchClassName)){if(element.hasClassName(this.options.filterSwitchSubfilterClassName)){var filterElement=element.up('fieldset').previous('label').down('input');if(filterElement&&filterElement.checked){activeElements.push(element);filterElement.removeClassName(this.options.noSubmitClassName);}}else{activeElements.push(element);}}}.bind(this));var formData=Form.serializeElements(activeElements,{hash:true});document.fire('map:getdata',{filters:formData});this.saveState(formData);}}},handleSearch:function(event){this.removeFilter();if(event.memo.searchName){this.loadFilter(event.memo.searchName);}},loadFilter:function(searchName){new Ajax.Request('/api/filters',{parameters:{search_name:searchName,type:'json'},method:'get',onSuccess:this.onFilterLoaded.bind(this)});},removeFilter:function(){this.element.update('');var page=new pH8.Page();page.setState('filters',{});this.savedState={};},onFilterLoaded:function(response){if(response.responseJSON){var html=this.templates.filter.process({dictionary:this.dictionary,pages:this.pages.getList(),filters:response.responseJSON});this.element.update(html);if(!Prototype.BrowserFeatures.XPath){this.element.down('form').getElements().each(function(element){element.observe('click',this.onChange.bindAsEventListener(this));}.bind(this));}}else{this.removeFilter();}
this.filterLoaded=true;if(this.savedState){this.restoreFilters();}},onDictionaryLoaded:function(event){this.dictionary=new pH8.Dictionary();this.dictionaryLoaded=true;this.onReady();},onPagesLoaded:function(event){this.pages=new pH8.Pages();this.pagesLoaded=true;this.onReady();},onTemplatesLoaded:function(event){this.templatesLoaded=true;this.onReady();},onReady:function(){if(this.dictionaryLoaded&&this.pagesLoaded&&this.templatesLoaded){this.waitForSocialWidgets(this.onPageReady.bindAsEventListener(this));this.widgetReady(this);}},onPageReady:function(event){var query=document.location.href.parseExtendedQuery();if(query.restoreState){this.restoreState();}
this.element.observe('change',this.onChange.bindAsEventListener(this));document.observe('map:search',this.handleSearch.bindAsEventListener(this));}});;Maps.SearchBox=Class.create({initialize:function(element,options){Object.extend(this,pH8.Mixin.needsSocialWidgets);this.registerWidget(this);Object.extend(this,pH8.Mixin.needsDictionary);Object.extend(this,pH8.Mixin.needsPages);this.element=$(element);this.state='new';this.options=Object.extend({locationFieldName:'location',latitudeFieldName:'latitude',longitudeFieldName:'longitude',searchNameFieldName:'search_name',messageElement:null,googleViewport:null,shouldSubmit:false},options||{});this.locationField=$(this.element[this.options.locationFieldName]);this.latitudeField=$(this.element[this.options.latitudeFieldName]);this.longitudeField=$(this.element[this.options.longitudeFieldName]);if(this.options.googleViewport){this.viewPort=new google.maps.LatLngBounds(new google.maps.LatLng(this.options.googleViewport.south,this.options.googleViewport.west),new google.maps.LatLng(this.options.googleViewport.north,this.options.googleViewport.east));}
this.waitForDictionary(this.onDictionaryLoaded.bind(this));this.waitForPages(this.onPagesLoaded.bind(this));this.element.observe('submit',this.onSubmit.bindAsEventListener(this));this.locationField.observe('focus',this.onFocus.bindAsEventListener(this));},restoreState:function(){var page=new pH8.Page();var state=page.getState();if(state){$(this.element[this.options.latitudeFieldName]).setValue(state.latitude);$(this.element[this.options.longitudeFieldName]).setValue(state.longitude);$(this.element[this.options.locationFieldName]).setValue(state.location);$(this.element[this.options.searchNameFieldName]).setValue(state.searchName);this.state='save';}},saveState:function(){var page=new pH8.Page();page.setState('latitude',$(this.element[this.options.latitudeFieldName]).getValue());page.setState('longitude',$(this.element[this.options.longitudeFieldName]).getValue());page.setState('location',$(this.element[this.options.locationFieldName]).getValue());page.setState('searchName',$(this.element[this.options.searchNameFieldName]).getValue());document.location.href=document.location.href.addHashParam('restoreState',1);},onFocus:function(event){var me=event.element();me.value='';this.state='ready';},onSubmit:function(event){event.stop();if(this.options.messageElement){$(this.options.messageElement).update('');}
if(this.state!='pending'){this.location=$F(this.element[this.options.locationFieldName]);if(this.state=='new'||this.location==''){if(this.options.messageElement){$(this.options.messageElement).update(this.dictionary.getText('error_no_location_entered'));}}else{this.queryGoogle();}}},onPositionFound:function(position){if(position&&this.viewPort.containsLatLng(position)){this.position=position;this.latitudeField.setValue(position.lat());this.longitudeField.setValue(position.lng());this.state='success';if(this.options.shouldSubmit){this.element.submit();}else{this.saveState();document.fire('map:search',{position:position,resetZoom:true,searchName:this.element.search_name.value});}}else{this.state='fail';if(this.options.messageElement){$(this.options.messageElement).update(this.dictionary.getText('error_location_notfound'));}}},queryGoogle:function(){this.state='pending';var geoCoder=new google.maps.ClientGeocoder();if(this.options.googleViewport){geoCoder.setViewport(this.viewPort);}
geoCoder.getLatLng(this.location+',NL',this.onPositionFound.bind(this));},onDictionaryLoaded:function(event){this.dictionary=new pH8.Dictionary();this.dictionaryLoaded=true;this.onReady();},onPagesLoaded:function(event){this.pages=new pH8.Pages();this.pagesLoaded=true;this.onReady();},onReady:function(){if(this.dictionaryLoaded&&this.pagesLoaded){this.waitForSocialWidgets(this.onPageReady.bindAsEventListener(this));this.widgetReady(this);}},hasNewLatLng:function(){if(this.latitudeField.getValue()!=52){return true;}
if(this.longitudeField.getValue()!=5){return true;}
return false;},onPageReady:function(event){var query=document.location.href.parseExtendedQuery();if(query.restoreState){this.restoreState();}
if(this.hasNewLatLng()){if(this.state!='save'){document.fire('map:search',{position:new google.maps.LatLng(this.latitudeField.getValue(),this.longitudeField.getValue()),resetZoom:true,searchName:$(this.element[this.options.searchNameFieldName]).getValue()});}
this.state='ready';}}});;Spotlight=Class.create({initialize:function(element,options){Object.extend(this,pH8.Mixin.needsDictionary);Object.extend(this,pH8.Mixin.needsTemplates);Object.extend(this,pH8.Mixin.needsPages);Object.extend(this,pH8.Mixin.needsConfig);this.element=$(element);this.options=Object.extend({showBanner:true},options||{});this.allowSearch=this.options.allowSearch||false;this.minimumSearchCharacters=this.options.minimumSearchCharacters||3;this.waitForDictionary(this.onDictionaryLoaded.bind(this));this.waitForPages(this.onPagesLoaded.bind(this));this.waitForConfig(this.onConfigLoaded.bind(this));this.waitForTemplates({searchResults:this.options.searchResultsTemplateUrl},this.onTemplatesLoaded.bind(this));this.setEventHandlers();},setEventHandlers:function(){this.element.observe('click',Event.delegate(this.delegates.click).bindAsEventListener(this));this.element.observe('keyup',Event.delegate(this.delegates.keyup).bindAsEventListener(this));this.element.up('form').observe('submit',Event.delegate(this.delegates.submit).bindAsEventListener(this));this.element.up('form').next('div.search-results').observe('click',Event.delegate(this.delegates.click).bindAsEventListener(this));document.observe('spotlight:ready',this.onActive.bindAsEventListener(this));},handleKeyInput:function(e){if(e.keyCode==8||(e.keyCode>48&&e.keyCode<=57)||(e.keyCode>=65&&e.keyCode<=90)){if(this.element.getValue().length>=this.minimumSearchCharacters){this.search();}else if(this.searchResultsListOpen){this.hide();}}else{if(this.searchResultsListOpen){switch(e.keyCode){case Event.KEY_UP:this.navigateResultSetUp();break;case Event.KEY_DOWN:this.navigateResultSetDown();break;case Event.KEY_RETURN:if(this.activeResultLink){window.location=this.activeResultLink.down('a').readAttribute('href');}}}}},navigateResultSetDown:function(){if(this.activeResultLink){if(this.activeResultLink.next('li')){this.activeResultLink.removeClassName('active');this.activeResultLink=this.activeResultLink.next('li').addClassName('active');}else if(this.activeResultLink.up('ul li')&&this.activeResultLink.up('ul li').next('li')){this.activeResultLink.removeClassName('active');this.activeResultLink=this.activeResultLink.up('ul li').next('li').down('li').addClassName('active');}}else{this.activeResultLink=this.resultSetContainer.down('ul li ul li').addClassName('active');}},navigateResultSetUp:function(){if(this.activeResultLink){this.activeResultLink.removeClassName('active');if(this.activeResultLink.previous('li')){this.activeResultLink=this.activeResultLink.previous('li').addClassName('active');}else if(this.activeResultLink.up('ul li')&&this.activeResultLink.up('ul li').previous('li')){this.activeResultLink=this.activeResultLink.up('ul li').previous('li').down('li',this.activeResultLink.up('ul li').previous('li').select('li').size()-1).addClassName('active');}else{this.activeResultLink=null;}}},search:function(){if(this.ajax){this.ajax.transport.abort();}
this.ajax=new Ajax.Request('/api/',{method:'get',parameters:{type:'json',q:this.element.getValue(),action:'search'},onSuccess:this.handleJSONData.bind(this),onFailure:this.handleJSONData.bind(this)});},handleJSONData:function(transport){var searchResultBox=this.templates.searchResults.process({modules:transport.responseJSON,dictionary:this.dictionary,pages:this.pages.getList(),searchstring:this.element.getValue(),config:this.config,status:transport.getStatus()+'',showBanner:this.options.showBanner});this.resultSetContainer.update(searchResultBox);this.show();},show:function(){Cufon.refresh('.title');this.resultSetContainer.removeClassName('hidden');this.searchResultsListOpen=true;},hide:function(){this.resultSetContainer.addClassName('hidden');this.resultSetContainer.update('');this.searchResultsListOpen=false;},delegates:{click:{'a.close':function(e){e.stop();if(this.searchResultsListOpen){this.hide();}}},keyup:{'input#search-form-searchstring':function(e){this.handleKeyInput(e);}},submit:{'.search-form':function(e){if(this.activeResultLink){e.stop();}}}},onDictionaryLoaded:function(event){this.dictionary=new pH8.Dictionary();this.dictionaryLoaded=true;this.onReady();},onTemplatesLoaded:function(){this.templatesLoaded=true;this.onReady();},onPagesLoaded:function(){this.pages=new pH8.Pages();this.pagesLoaded=true;this.onReady();},onConfigLoaded:function(){var tempConfig=new pH8.Config();this.config=new Hash();$H(tempConfig.getList()).each(function(pair){this.config.set(pair.key,new Hash());$H(pair.value).each(function(secondPair){this.config.get(pair.key).set(secondPair.value,secondPair.key);}.bind(this));}.bind(this));this.configLoaded=true;this.onReady();},onReady:function(){if(this.dictionaryLoaded&&this.templatesLoaded&&this.pagesLoaded&&this.configLoaded){this.allowSearch=true;document.fire('spotlight:ready');}},onActive:function(e){this.element.writeAttribute('autocomplete','off');this.resultSetContainer=this.element.up('form').next('div.search-results');}});;LicensePlateInput=Class.create({initialize:function(element,options){this.element=$(element);this.options=options||{};this.setEventHandlers();this.onReady();},delegates:{keyup:{'.license':function(e){if(this.element.getValue().length>=6){this.format();}}}},onReady:function(){if(!this.element.readAttribute('maxlength')){this.element.writeAttribute('maxlength',8);this.element.setStyle({textTransform:'uppercase'});}},setEventHandlers:function(){this.element.observe('keyup',Event.delegate(this.delegates.keyup).bindAsEventListener(this));},format:function(){var strippedValue=this.element.getValue().gsub(/[-\s]+/,'');var firstRegex=/^[a-zA-Z]{1}\d{3}[a-zA-Z]{2}$/;var secondRegex=/^\d[a-zA-Z]{3}\d{2}$/;var thirdRegex=/^\d{2}[a-zA-Z]{3}\d$/;var fourthRegex=/^[a-zA-Z]{2}\d{3}[a-zA-Z]{1}$/;var fifthRegex=/^\w{6}$/;var slices={};if(strippedValue.match(firstRegex)||strippedValue.match(secondRegex)){slices.first=strippedValue.substr(0,1);slices.second=strippedValue.substr(1,3);slices.third=strippedValue.substr(4,2);}else if(strippedValue.match(thirdRegex)||strippedValue.match(fourthRegex)){slices.first=strippedValue.substr(0,2);slices.second=strippedValue.substr(2,3);slices.third=strippedValue.substr(5,1);}else if(strippedValue.match(fifthRegex)){slices.first=strippedValue.substr(0,2);slices.second=strippedValue.substr(2,2);slices.third=strippedValue.substr(4,2);}else{slices=false;}
if(slices){this.element.value="#{slices.first}-#{slices.second}-#{slices.third}".interpolate({slices:slices});}}});;NewsCarousel=Class.create({initialize:function(element,options){this.element=$(element);this.options=Object.extend({shouldRotate:true,interval:5},options||{});this.element.observe('click',Event.delegate(this.delegates.click).bindAsEventListener(this));this.element.select('li:not(.latest)').each(function(element){element.setStyle({display:'none'});});if(this.options.shouldRotate){this.startRotating();}},delegates:{click:{'a.morenews':function(e){e.stop();this.toggleList();},'a.morenews span':function(e){e.stop();this.toggleList();},'a.morenews span canvas':function(e){e.stop();this.toggleList();}}},startRotating:function(){this.interval=setInterval(this.switchDisplayItem.bind(this),(this.options.interval*1000));},stopRotating:function(){clearInterval(this.interval);},switchDisplayItem:function(){var currentItem=this.element.down('li.latest');var nextItem=currentItem.next('li');if(!nextItem){nextItem=this.element.down('li');}
currentItem.up('ul').setStyle({height:currentItem.up('ul').getDimensions().height+'px'});Effect.Fade(currentItem,{duration:1.0,queue:{scope:'newscarousel',position:'first'},afterFinish:function(){currentItem.removeClassName('latest');}});Effect.Appear(nextItem,{duration:1.0,queue:{scope:'newscarousel',position:'last'},beforeStart:function(){},afterFinish:function(){nextItem.addClassName('latest');}});},toggleList:function(){var container=this.element.down('div');if(container.hasClassName('active')){this.stopRotating();container.removeClassName('active');container.addClassName('inactive');}else{container.removeClassName('inactive');container.addClassName('active');this.startRotating();}}});;Tool={};;Tool.OccasionCar=Class.create({initialize:function(element,options){Object.extend(this,pH8.Mixin.needsSocialWidgets);Object.extend(this,pH8.Mixin.needsTemplates);Object.extend(this,pH8.Mixin.needsPages);Object.extend(this,pH8.Mixin.needsDictionary);this.registerWidget(this);this.element=$(element);this.options=Object.extend({yearSliderRestraints:{1930:10,1970:5,1980:1,2010:0},priceSliderRestraints:{0:500,10000:1000,15000:5000,50000:25000,100000:50000,300000:699999,999999:0},mileageSliderRestraints:{0:1000,10000:10000,100000:50000,500000:100000,800000:0}},options||{});this.slider={};this.options.fixedYearSliderValues=this.buildSliderSteps(new Hash(this.options.yearSliderRestraints));this.options.fixedPriceSliderValues=this.buildSliderSteps(new Hash(this.options.priceSliderRestraints));this.options.fixedMileageSliderValues=this.buildSliderSteps(new Hash(this.options.mileageSliderRestraints));this.waitForPages(this.onPagesLoaded.bind(this));this.waitForTemplates({'slider':'/js/templates/slider.tpl'},this.templatesLoaded);this.waitForDictionary(this.dictionaryLoaded.bindAsEventListener(this),'nl');this.dictionary=new pH8.Dictionary('nl');this.addObservers();this.setLocationBehavior();},addObservers:function(){this.element.observe('submit',this.onSubmit.bindAsEventListener(this));},onSubmit:function(event){if(event.element().hasClassName('occasion-car-form')){pageTracker._trackEvent('occasion search','step 1 complete');}else{pageTracker._trackEvent('occasion search','step 2 change search query');}},waitForBrandChange:function(callback){document.observe('occasioncar:newbrand',callback);},delegates:{change:{'select[name="F_MERK"]':function(event){document.fire('occasioncar:newbrand',{brand:event.element().getValue()});}}},onBrandChange:function(event){this.ajax=new Ajax.Request('/api/autotrack',{parameters:{brand:event.memo.brand},method:'get',onStart:function(){this.element['F_MODEL'].disable();}.bind(this),onFailure:this.handleError.bind(this),onSuccess:this.handleJSONData.bind(this)});},handleError:function(transport){document.location.href='/index.php?pageID='+this.pages.getPage('error');},handleJSONData:function(transport){this.element['F_MODEL'].enable();this.element['F_MODEL'].update('');if(transport.responseJSON){transport.responseJSON.each(function(brand){var option=new Element('option',{value:brand}).update(brand);if(this.queryParameters.get('F_MODEL')==brand){option.writeAttribute("selected","selected");}
Element.insert(this.element['F_MODEL'],option);},this);}},onSliderValueChanged:function(handles,name,elementName,fixedSliderValues,valueModifier){this.element[elementName+'1'].value=fixedSliderValues.get((handles[0]/10).round());this.element[elementName+'2'].value=fixedSliderValues.get((handles[1]/10).round());this.element.down('div.'+name+'-slider span.min').update(valueModifier(this.element[elementName+'1'].getValue()));this.element.down('div.'+name+'-slider span.max').update(valueModifier(this.element[elementName+'2'].getValue()));},buildSliderSteps:function(hash){var returnHash=new Hash();var previousPair=null;hash.each(function(pair){if(previousPair!=null){var yearDiff=pair.key-previousPair.key;var stepSize=previousPair.value;var indexDiff=yearDiff/stepSize;lastKey=returnHash.keys().last()||0;for(var i=0;i<indexDiff+1;i++){returnHash.set(parseInt(lastKey)+i,stepSize*i+parseInt(previousPair.key));}}
previousPair=pair;});return returnHash;},getStepNumber:function(hash,value){return parseInt(hash.keys()[hash.values().indexOf(parseInt(value))]);},createSlider:function(name,elementName,fixedSliderValues,valueModifier){if(!this.element[elementName+'1']||!this.element[elementName+'2']){return false;}
if(!this._slidersneeded){this._slidersneeded=new Hash();}
this._slidersneeded.set(name,true);var minInput=this.element[elementName+'1'];var maxInput=this.element[elementName+'2'];minInput.hide();maxInput.hide();this.element.down('label[for="'+elementName+'1"]').hide();this.element.down('label[for="'+elementName+'2"]').hide();if(!valueModifier){valueModifier=function(value){return value;};}
this.element[elementName+'1'].insert({'before':this.templates.slider.process({'name':name,'label':this.dictionary.getText(name)})});var maxRange=parseInt(fixedSliderValues.keys().last())*10;var defaultValues=[0,maxRange];if(minInput.getValue()){defaultValues[0]=this.getStepNumber(fixedSliderValues,minInput.getValue())*10;}else{minInput.value=fixedSliderValues.values().first();}
if(maxInput.getValue()){defaultValues[1]=this.getStepNumber(fixedSliderValues,maxInput.getValue())*10;}else{maxInput.value=fixedSliderValues.values().last();}
this.element.down('div.'+name+'-slider span.min').update(valueModifier(minInput.getValue()));this.element.down('div.'+name+'-slider span.max').update(valueModifier(maxInput.getValue()));this.slider[name]=new Control.Slider([this.element.down('div.'+name+'-slider-min'),this.element.down('div.'+name+'-slider-max')],this.element.down('div.'+name+'-slider'),{range:$R(0,maxRange),values:$R(0,maxRange),sliderValue:[0,maxRange],restricted:true,spans:[this.element.down('div.'+name+'-slider-span')],onSlide:function(handles){this.onSliderValueChanged(handles,name,elementName,fixedSliderValues,valueModifier);}.bind(this),onChange:function(handles){if(this.slidersAnimated){pageTracker._trackEvent('slider changed',name,'min: '+valueModifier(fixedSliderValues.get((handles[0]/10).round()))+' max: '+valueModifier(fixedSliderValues.get((handles[1]/10).round())));}
this.onSliderValueChanged(handles,name,elementName,fixedSliderValues,valueModifier);}.bind(this)});this.sliderReady(name,defaultValues);},slidersReady:function(){var status=this._slidersneeded;$H(this._slidersneeded).each(function(pair){if(!this._slidersready.get(pair.key)){status=false;}}.bind(this));if(status){var stop={};new PeriodicalExecuter(function(pe){this._slidersready.each(function(pair){var currentValues=this.slider[pair.key].values;if(!stop[pair.key]){stop[pair.key]={};}
if(currentValues[0]<pair.value[0]){this.slider[pair.key].setValue(currentValues[0]+5,0);stop[pair.key].min=false;}else{stop[pair.key].min=true;}
if(currentValues[1]>pair.value[1]){this.slider[pair.key].setValue(currentValues[1]-5,1);stop[pair.key].max=false;}else{stop[pair.key].max=true;}}.bind(this));var sliderStatus=true;$H(stop).each(function(pair){if(!pair.value.min||!pair.value.max){sliderStatus=false;}}.bind(this));if(sliderStatus){this.slidersAnimated=true;pe.stop();}}.bind(this),0.08);}},sliderAnimated:function(sliderName){if(!this._slidersanimated){this._slidersanimated=new Hash();}
this._slidersanimated.set(sliderName,true);var status=true;this._slidersready.each(function(pair){if(!this._slidersanimated.get(pair.key)){status=false;}}.bind(this));this.slidersAnimated=status;},sliderReady:function(sliderName,slideToParams){if(!this._slidersready){this._slidersready=new Hash();}
this._slidersready.set(sliderName,slideToParams);},onPageReady:function(event){this.pageReady=true;this.waitForBrandChange(this.onBrandChange.bind(this));this.element.observe('change',Event.delegate(this.delegates.change).bindAsEventListener(this));if(!Prototype.BrowserFeatures.XPath){this.element.select('select[name="F_MERK"]').each(function(element){element.observe('change',function(event){document.fire('occasioncar:newbrand',{brand:event.element().getValue()});});}.bind(this));}
this.element.getElements();this.parseQueryParameters();this.createSlider('price','F_PRIJS',this.options.fixedPriceSliderValues,function(value){if(value>=999999){return this.dictionary.getText('no_limit');}
return'€ '+value;}.bind(this));this.createSlider('year','F_BOUWJ',this.options.fixedYearSliderValues);this.createSlider('mileage','F_KMST',this.options.fixedMileageSliderValues,function(value){return value+" km";}.bind(this));if(this.element['F_MERK'].getValue()){document.fire('occasioncar:newbrand',{brand:this.element['F_MERK'].getValue()});}
this.slidersReady();},templatesLoaded:function(){this.templatesReady=true;this.continueLoading();},dictionaryLoaded:function(){this.dictionaryReady=true;this.continueLoading();},onPagesLoaded:function(event){this.pages=new pH8.Pages();this.pagesLoaded=true;this.continueLoading();},continueLoading:function(){if(this.templatesReady&&this.dictionaryReady&&this.pagesLoaded){this.waitForSocialWidgets(this.onPageReady.bindAsEventListener(this));this.widgetReady(this);}},parseQueryParameters:function(){var params=window.location.search.substring(1).split('\x26');this.queryParameters=new Hash();params.each(function(part){var nameValue=part.split('=');this.queryParameters.set(nameValue[0],nameValue[1]);}.bind(this));},setLocationBehavior:function(){if(this.element.down('#F_PC_CIJFERS')&&this.element.down('#F_STRAAL_POSTC')){var straalField=this.element.down('#F_STRAAL_POSTC');var postcodeField=this.element.down('#F_PC_CIJFERS');straalField.disable();checkField=function(event){if(postcodeField.value.length>0){straalField.enable();}else{straalField.disable();}};checkField();postcodeField.observe("keyup",checkField);}}});;Tool.ExchangeCar=Class.create({initialize:function(element,options){Object.extend(this,pH8.Mixin.needsSocialWidgets);Object.extend(this,pH8.Mixin.needsDictionary);this.registerWidget(this);this.element=$(element);this.options=Object.extend({},options||{});this.waitForDictionary(this.onDictionaryLoaded.bindAsEventListener(this));},onDictionaryLoaded:function(event){this.dictionaryLoaded=true;this.dictionary=new pH8.Dictionary();this.onReady();},onReady:function(){if(this.dictionaryLoaded){this.waitForSocialWidgets(this.onPageReady.bindAsEventListener(this));this.widgetReady(this);}},onPageReady:function(){this.addEventObservers();},addEventObservers:function(){this.element.observe('click',Event.delegate(this.delegates.click).bindAsEventListener(this));this.element.observe('submit',Event.delegate(this.delegates.submit).bindAsEventListener(this));},delegates:{click:{'ul li a':function(){this.showWaitingScreen();},'a':function(){this.showWaitingScreen();}},submit:{'.exchange-car-additional-info':function(event){event.element().submit();this.showWaitingScreen();}}},showWaitingScreen:function(){this.element.hide();this.element.insert({'after':'<p class="wait-screen">'+this.dictionary.getText('please_wait')+'</p>'});}});;Tool.ExchangeCarFeatures=Class.create({initialize:function(element,options){this.element=$(element);this.options=Object.extend({},options||{});Object.extend(this,pH8.Mixin.needsPages);Object.extend(this,pH8.Mixin.needsDictionary);this.loadedMixins=[];this.waitForDictionary(function(event){this.dictionary=new pH8.Dictionary();this.loadedMixins['dictionary']=true;this.onPageReady();}.bind(this));this.waitForPages(function(event){this.pages=new pH8.Pages();this.loadedMixins['pages']=true;this.onPageReady();}.bind(this));this.waitForBrandChange(this.onBrandChange.bind(this));this.waitForYDFTChange(this.onYDFTChange.bind(this));this.waitForModelChange(this.onModelChange.bind(this));},onPageReady:function(){if(!this.loadedMixins['dictionary']||!this.loadedMixins['pages']){return false;}
this.element.select('select[name="brandID"]').each(function(element){element.observe('change',function(event){document.fire('featurescar:newbrand');});}.bind(this));this.element.select('select[name="modelID"]').each(function(element){element.observe('change',function(event){document.fire('featurescar:newmodel');});}.bind(this));this.element.select('select[name="year"]').each(function(element){element.observe('change',function(event){document.fire('featurescar:newydft');});}.bind(this));this.element.select('select[name="door"]').each(function(element){element.observe('change',function(event){document.fire('featurescar:newydft');});}.bind(this));this.element.select('select[name="fuel"]').each(function(element){element.observe('change',function(event){document.fire('featurescar:newydft');});}.bind(this));this.element.select('select[name="transmission"]').each(function(element){element.observe('change',function(event){document.fire('featurescar:newydft');});}.bind(this));},waitForBrandChange:function(callback){document.observe('featurescar:newbrand',callback);},waitForYDFTChange:function(callback){document.observe('featurescar:newydft',callback);},waitForModelChange:function(callback){document.observe('featurescar:newmodel',callback);},onBrandChange:function(event){this.showWaitingScreen();this.clearYDFT();this.ajax=new Ajax.Request('/api/exchangecarbydetails',{parameters:{apiVersion:"1.0",brandID:this.element['info-car-form-brandID'].getValue()},method:'get',onCreate:function(){this.element['info-car-form-modelID'].disable();this.element['info-car-form-year'].disable();this.element['info-car-form-doors'].disable();this.element['info-car-form-fuel'].disable();this.element['info-car-form-transmission'].disable();}.bind(this),onFailure:this.handleError.bind(this),onSuccess:this.handleBrandJSONData.bind(this)});},handleError:function(transport){document.location.href='/index.php?pageID='+this.pages.getPage('error');},handleBrandJSONData:function(transport){this.element['info-car-form-modelID'].enable();this.element['info-car-form-year'].enable();this.element['info-car-form-modelID'].update('');if(transport.responseJSON){transport.responseJSON.models.each(function(brand){var option=new Element('option',{value:brand.TypeID}).update(brand.TypeNaam);Element.insert(this.element['info-car-form-modelID'],option);},this);}
this.hideWaitingScreen();},onYDFTChange:function(event){if(this.element['info-car-form-year'].getValue()>0){this.hideNoVersionScreen();this.showWaitingScreen();this.ajax=new Ajax.Request('/api/exchangecarbydetails',{parameters:{apiVersion:"1.0",brandID:this.element['info-car-form-brandID'].getValue(),typeID:this.element['info-car-form-modelID'].getValue(),deuren:this.element['info-car-form-doors'].getValue(),brandstof:this.element['info-car-form-fuel'].getValue(),transmissie:this.element['info-car-form-transmission'].getValue(),year:this.element['info-car-form-year'].getValue()},method:'get',onCreate:function(){this.element['info-car-form-brandID'].disable();this.element['info-car-form-modelID'].disable();this.element['info-car-form-year'].disable();this.element['info-car-form-doors'].disable();this.element['info-car-form-fuel'].disable();this.element['info-car-form-transmission'].disable();}.bind(this),onFailure:this.handleError.bind(this),onSuccess:this.handleYDFTJSONData.bind(this)});}},handleYDFTJSONData:function(transport){this.element['info-car-form-brandID'].enable();this.element['info-car-form-modelID'].enable();this.element['info-car-form-year'].enable();this.element['info-car-form-doors'].enable();this.element['info-car-form-fuel'].enable();this.element['info-car-form-transmission'].enable();if(transport.responseJSON){if(transport.responseJSON.versions.length==0){this.showNoVersionScreen();}}
this.hideWaitingScreen();},onModelChange:function(event){this.clearYDFT();},clearYDFT:function(){this.element['info-car-form-year'].selectedIndex=0;this.element['info-car-form-doors'].selectedIndex=0;this.element['info-car-form-fuel'].selectedIndex=0;this.element['info-car-form-transmission'].selectedIndex=0;},showWaitingScreen:function(){this.element.hide();this.element.insert({'after':'<p class="wait-screen">'+this.dictionary.getText('please_wait')+'</p>'});},hideWaitingScreen:function(){this.element.show();$$('p.wait-screen')[0].remove();},showNoVersionScreen:function(){this.element.insert({'top':'<div class="no-versions"><p>'+this.dictionary.getText('no_versions')+'</p></div>'});},hideNoVersionScreen:function(){this.element.show();if($$('div.no-versions')[0]){$$('div.no-versions')[0].remove();}}});;var general_rules={'#onestat-placeholder':function(){var d=document;var sid=Element.getClassParameter(this,'sid');var CONTENTSECTION="";var CUSTOMDATA="";var osp_URL=d.URL;var osp_Title=d.title;var t=new Date();var p="http"+(d.URL.indexOf('https:')===0?'s':'')
+"://stat.onestat.com/stat.aspx?tagver=2&sid="+sid;p+="&url="+escape(osp_URL);p+="&ti="+escape(osp_Title);p+="&section="+escape(CONTENTSECTION);p+="&custom="+escape(CUSTOMDATA);p+="&rf="+escape(document.referrer);p+="&tz="+escape(t.getTimezoneOffset());p+="&ch="+escape(t.getHours());p+="&js=1";p+="&ul="
+escape(navigator.appName=="Netscape"?navigator.language:navigator.userLanguage);if(osp_URL!=d.URL){p+="&ol="+escape(d.URL);}
if(typeof(screen)=="object"){p+="&sr="+screen.width+"x"+screen.height;p+="&cd="+screen.colorDepth;p+="&jo="+(navigator.javaEnabled()?"Yes":"No");}
this.innerHTML='<img id="ONESTAT_TAG" width="1" height="1" src="'+p+'" >';},'#analytics-placeholder':function(){var params=this.getClassParameters();if(params.sid){pageTracker=_gat._getTracker(params.sid);pageTracker._setDomainName("none");pageTracker._setAllowLinker(true);pageTracker._setAllowHash(false);if(params.target){pageTracker._trackPageview(unescape(params.target));}else{pageTracker._trackPageview();}}},'.hilite-keywords':function(){var hiliter=new KeywordHiliter("ajax.php",this);hiliter.options.elementTag='ABBR';hiliter.fetchKeywords();},'.no-javascript':function(){this.hide();},'.show-no-javascript':function(){this.show();}};Event.addBehavior(general_rules);var hyperlink_rules={'a.void:click':function(e){return false;},'a.popup:click':function(e){var params=this.getClassParameters();var width=params.width||684;var height=params.height||350;var top=params.top||200;var left=params.left||'50%';window.open(this.href,'PopUp','width='+width+',height='+height+',top='+top+',left='+left+',scrollbars=0,status=no,resizable=0,toolbar=0,titlebar=0,menubar=0,location=0');return false;},'a.external:click,a.new-window:click':function(e){if(!e.ctrlKey&&!e.altKey&&!e.shiftKey){window.open(this.href);return false;}},'a.status:mouseover':function(e){window.status=this.title;return true;},'a.status:mouseout':function(e){window.status='';return true;},'a.switch:click':function(e){var c=$(this.id.replace('-switch',''));var content=$(c.id+'-content');if(c){c.toggle();}
return false;},'a.tabswitch:click':function(e){var container=$(this.getAttribute('rel'));if(container){var other=$(container.getAttribute('rel'));if(other){container.addClassName('hide');other.removeClassName('hide');}}
return false;},'a.modal:click':function(e){var image=this.up().next().down('img');var dialog=new MUIL.Dialog.Image(image);return false;},'a.submit':function(e){var params=this.getClassParameters();var form=$(params.form);if(form){form.submit();}
return false;},'a.morenews:click':function(event){var container=this.up('div');if(container){if(container.hasClassName('active')){container.removeClassName('active');container.addClassName('inactive');}else{container.removeClassName('inactive');container.addClassName('active');}
event.stop();}}};Event.addBehavior(hyperlink_rules);var form_rules={'form.auto-submit':function(e){this.submit();},'select.auto-submit:change':function(e){this.form.submit();},'input.auto-upper:blur':function(e){this.value=this.value.toUpperCase();},'input.auto-upper:change':function(e){this.value=this.value.toUpperCase();},'.default-value:blur':function(e){if(this.value==''){var params=this.getClassParameters();if(params.default_value!=''){this.value=params.default_value;this.addClassName('auto-clear');}}},'input.auto-blur:focus':function(e){this.className=this.className.replace('-off','-on');var fieldLabel=$(this.form).down('[for='+this.id+']');if(fieldLabel){fieldLabel.className=fieldLabel.className.replace('-off','-on');var image=fieldLabel.down('img');if(image){image.src=image.src.replace('_normal','_hover');}}
var fieldSet=this.up('fieldset');if(fieldSet&&fieldSet.up('fieldset')){var legend=fieldSet.down('legend');if(legend){legend.className=legend.className.replace('-off','-on');}}},'input.auto-blur:blur':function(e){this.className=this.className.replace('-on','-off');var fieldLabel=$(this.form).down('[for='+this.id+']');if(fieldLabel){fieldLabel.className=fieldLabel.className.replace('-on','-off');var image=fieldLabel.down('img');if(image){image.src=image.src.replace('_hover','_normal');}}
var fieldSet=this.up('fieldset');if(fieldSet&&fieldSet.up('fieldset')){var legend=fieldSet.down('legend');if(legend){legend.className=legend.className.replace('-on','-off');}}},'.auto-clear:focus':function(e){if(this.hasClassName('auto-clear')){this.value='';}
this.removeClassName('auto-clear');},'input.rollover:mouseover':function(el){if(!this.hasClassName('active')){this.className=this.className.replace('-normal','-hover');if(this.type=='image'){this.src=this.src.replace('_normal','_hover');}}},'input.rollover:mouseout':function(e){if(!this.hasClassName('active')){this.className=this.className.replace('-hover','-normal');if(this.type=='image'){this.src=this.src.replace('_hover','_normal');}}},'#apkreminder-form:submit':function(e){e.stop();var licenseplate=e.element().getInputs('text','txtKentekenveld')[0];licenseplate.value=licenseplate.getValue().gsub('-','');e.element().submit();},'.overlabel':function(){this.addClassName('overlabel-apply');this.removeClassName('overlabel');},'.overlabel-apply label:click':function(event){var field=$(this.getAttribute('for'));if(field){field.focus();}},'.overlabel-apply input:focus':function(event){var label=$(this.form).down('label[for='+this.id+']');if(label){label.setStyle({textIndent:'-10000px'});}},'.overlabel-apply .text':function(){if(''!=this.getValue()){var label=$(this.form).down('label[for='+this.id+']');if(label){console.log(label,this);label.setStyle({textIndent:'-10000px'});}}},'.overlabel-apply .text:blur':function(event){if(''==this.getValue()){var label=$(this.form).down('label[for='+this.id+']');if(label){label.setStyle({textIndent:'0px'});}}}};Event.addBehavior(form_rules);var rollover_rules={'img.rollover:mouseover':function(el){this.src=this.src.replace('_normal','_hover');return false;},'img.rollover:mouseout':function(el){this.src=this.src.replace('_hover','_normal');return false;}};Event.addBehavior(rollover_rules);var menu_rules={'ul.menu':function(){var menu=new pH8.Menu(this);}};Event.addBehavior(menu_rules);var accordion_rules={'dl.info-list':function(event){var accordion=new Accordion(this,{});}};Event.addBehavior(accordion_rules);var campaign_rules={'div.campaign':function(){var tabRotator=new TabRotator(this,{contentElementSelector:'.campaign-list',tabsElementSelector:'.campaign-loader',parameterName:'campaignID',interval:4,animateLoader:false,animatingLoaderClass:'campaign-loader-animating',animationClassPrefix:'state-',animationFrames:18,animationDuration:1.5});}};Event.addBehavior(campaign_rules);var location_rules={'div.locations-filter':function(){var filter=new Maps.Filter(this,{filterTemplateUrl:'/js/templates/filter.tpl'});},'div.locations-table':function(){var table=new Maps.LocationsTable(this,{dataUrl:'/api/members',locationKey:'memberID',locationsTableTemplateUrl:'/js/templates/locationstable.tpl',locationsErrorTemplateUrl:'/js/templates/locationserror.tpl'});},'div.locations-map':function(){var map=new Maps.Map(this,{locationKey:'memberID',autoLoad:true,infoWindowTemplateUrl:'/js/templates/infowindow.tpl',icons:{normal:{size:[25,33],url:'/images/marker_default.png',shadowSize:[35,33],shadowUrl:'/images/marker_shadow.png'},selected:{size:[25,33],url:'/images/marker_selected.png',shadowSize:[35,33],shadowUrl:'/images/marker_shadow.png'},position:{size:[25,33],url:'/images/marker_active.png',shadowSize:[0,0],shadowUrl:'/images/marker_shadow.png'}}});},'form#member-form':function(){var search=new Maps.SearchBox(this,{locationFieldName:'locationsearch',locationsTableTemplateUrl:'/js/templates/locationstable.tpl',locationsErrorTemplateUrl:'/js/templates/locationserror.tpl',messageElement:this.next(),googleViewport:{north:53.509299,south:50.756069,west:3.363889,east:7.209444}});},'form#member-form-small':function(){var search=new Maps.SearchBox(this,{locationFieldName:'locationsearch',locationsTableTemplateUrl:'/js/templates/locationstable.tpl',locationsErrorTemplateUrl:'/js/templates/locationserror.tpl',messageElement:this.next(),shouldSubmit:true,googleViewport:{north:53.509299,south:50.756069,west:3.363889,east:7.209444}});}};Event.addBehavior(location_rules);var member_details_map_rules={'div.member-details-map':function(){var memberMap=new Maps.MembersDetailsMap(this,{minZoom:11,locationKey:'memberID',autoLoad:true,infoWindowTemplateUrl:'/js/templates/infowindow.tpl',icons:{normal:{size:[25,33],url:'/images/marker_default.png',shadowSize:[35,33],shadowUrl:'/images/marker_shadow.png'}}});}};Event.addBehavior(member_details_map_rules);var spotlight_rules={'input#search-form-searchstring':function(){var spotlight=new Spotlight(this,{searchResultsTemplateUrl:'/js/templates/spotlight.tpl'});}};Event.addBehavior(spotlight_rules);var license_plate_rules={'input.license':function(){var licensePlateInput=new LicensePlateInput(this,{});}};Event.addBehavior(license_plate_rules);var tools_rules={'.occasion-car-form':function(){var occasionCarTool=new Tool.OccasionCar(this,{});},'.filter-list-occasion-car form':function(){var occasionCarToolFilter=new Tool.OccasionCar(this,{});},'.version-list':function(){var exchangeCarTool=new Tool.ExchangeCar(this,{});},'a.occasion-detail:click':function(event){pageTracker._trackEvent('occasion search','step 2 complete',event.element().innerHTML);},'a.occasion-member-detail:click':function(event){pageTracker._trackEvent('occasion search','step 3 to member',event.element().previous('h3').innerHTML);},'.exchange-car-features-form':function(){var exchangeCarFeaturesTool=new Tool.ExchangeCarFeatures(this,{});}};Event.addBehavior(tools_rules);var gallery_rules={'div.occasion-detail':function(){var tabRotator=new TabRotator(this,{contentElementSelector:'.image-gallery',tabsElementSelector:'.image-gallery-thumbs',parameterName:'imageGalleryID',interval:4,animateLoader:false,animatingLoaderClass:'image-gallery-loader-animating',animationClassPrefix:'state-',animationFrames:18,animationDuration:1.5});}};Event.addBehavior(gallery_rules);var analytics_rules={'.form-fail-analytics':function(event){var fields=this.getClassParameter('failedfields').split(',');var formname=this.getClassParameter('formname');fields.each(function(field){pageTracker._trackEvent('forms','field fail',formname+'->'+field);});}};Event.addBehavior(analytics_rules);var flash_rules={'#neos-stream':function(e){var FO={data:this.getClassParameter('stream'),width:"768",height:"432",xi:"false",flashvars:{},version:"9.0.0",params:{menu:"false",allowfullscreen:"true",allowScriptAccess:"always"}};swfobject.embedSWF(FO.data,this.id,FO.width,FO.height,FO.version,FO.xi,FO.flashvars,FO.params,FO.attributes);},'#ecard-upload':function(e){var FO={data:"/flash/"+this.getClassParameter('app'),width:"964",height:"530",xi:"false",flashvars:{fileName:this.getClassParameter('fileName'),actieID:escape(this.getClassParameter('actieID')),uploadScript:this.getClassParameter('uploadScript'),imagePath:this.getClassParameter('imagePath'),maxFileSize:this.getClassParameter('maxFileSize'),initScript:this.getClassParameter('initScript')},version:"9.0.0",params:{menu:"false",allowfullscreen:"false",allowScriptAccess:"always"}};swfobject.embedSWF(FO.data,this.id,FO.width,FO.height,FO.version,FO.xi,FO.flashvars,FO.params,FO.attributes);}};Event.addBehavior(flash_rules);var holidaycampaign_rules={'.cardoverview':function(event){var options={focus:this.getClassParameter('focus'),abuse:this.getClassParameter('abuse')};cardoverview=new CardOverview(this,options);}};Event.addBehavior(holidaycampaign_rules);var facebook_rules={'.cardoverview':function(){var facebookconnector=new FaceBookConnector(this,{locale:this.getClassParameter('locale'),apiKey:this.getClassParameter('apiKey'),appID:this.getClassParameter('appID')});}};Event.addBehavior(facebook_rules);var tracker_rules={'.tracker':function(){tracker=new TrackingCode(this);}};Event.addBehavior(tracker_rules);