/*Fuel - Powering your web applicaitons. Copyright (c) 2010 - Arnout Kazemier ( hotels.nl ) */(function(top,tmp){var document=top.document,documentElement=document.documentElement,fn=[Object.prototype.toString],userAgent=navigator.userAgent.toLowerCase(),appVerson=navigator.appMinorVersion,object="object",string="string",number="number",undefined,v,fuel=top.fuel=top.fuel||{},vanilla;try{while(top!==top.top){top=top.top}if(top!==self){top.location.replace(self.location.href)}}catch(e){}vanilla=v={extend:function(toExtend,extendWith,ignoreUndefined){if(!extendWith){return}toExtend=toExtend||vanilla;var fn=vanilla.is.fn(extendWith),items;for(items in extendWith){if(ignoreUndefined&&(extendWith[items]||toExtend.prototype[items])==undefined){continue}if(fn){toExtend.prototype[items]=extendWidth[items]}else{toExtend[items]=extendWith[items]}}return v},addEvent:function(type,fn,context){context=context||window;return context.attachEvent?context.attachEvent("on"+type,fn):context.addEventListener(type,fn,false)},contains:function(array,string){var i=array.length;while(i--){if(array[i]==string){return i}}return false},is:{fn:function(o){return fn[0].call(o)==="[object Function]"},array:function(o){return fn[0].call(o)==="[object Array]"},object:function(o){return fn[0].call(o)==="[object Object]"},string:function(o){return fn[0].call(o)==="[object String]"},number:function(o){return fn[0].call(o)==="[object Number]"},node:function(o){return o.nodeType},bool:function(o){return fn[0].call(o)==="[object Boolean]"}},browser:{version:(userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[0,"0"])[1],servicepack:appVerson?appVerson.toLowerCase().replace(/;/g,""):false,webkit:/webkit/.test(userAgent),opera:/opera/.test(userAgent),ie:/msie/.test(userAgent)&&!/opera/.test(userAgent),firefox:/mozilla/.test(userAgent)&&!/(compatible|webkit)/.test(userAgent),chrome:/google/.test(userAgent)&&/webkit/.test(userAgent),mobile_safari:/Apple.*Mobile.*Safari/.test(userAgent),iphone:/(iphone|ipod)/.test(userAgent)},supports:{workers:!!(top.Worker&&Worker.prototype.terminate),gears:!!(top.google&&!!top.google.gears),sessionStorage:!!top.sessionStorage,localStorage:!!top.localStorage,json:!!(top.JSON&&top.JSON.parse)},params:(function(){var source=top.location.search.substr(1).split("&"),result={},y=source.length,m,c,a,tmp;while(y--){m=source[y].split("=");c=unescape(m[0]?m[0]:"");a=unescape(m[1]?m[1]:"");if(a.match(/^0$|^[1-9]\d*$/)){a=parseInt(a)}else{a=a.toLowerCase()}if(!result[c]){result[c]=a}else{if(typeof result[c]!=object){tmp=result[c];result[c]=[tmp]}result[c].push(a)}}return result})(),poll:function(element,callback,timeout){var ele=document.getElementById(element);if(ele){return callback(ele)}else{(function(ele){ele=document.getElementById(element);if(ele){return callback(ele)}return setTimeout(arguments.callee,timeout||10)})(ele)}return v},chunk:function(items,process,context,callback){var todo=items.concat();setTimeout(function(){var start=+new Date();do{process.call(context,todo.shift())}while(todo.length>0&&(+new Date()-start<50));if(todo.length>0){setTimeout(arguments.callee,25)}else{return callback?callback(items):false}},25);return v},notify:function(){this.observers=[];this.suppressNotifications=false;this.addObserver=function(observer){if(!observer){return}var i=this.observers.length,len=i;while(i--){if(this.observers[i]==observer){return}}this.observers[len]=observer};this.removeObserver=function(observer){if(!observer){return}var i=this.observers.length;while(i--){if(this.observers[i]==observer){return this.observers.splice(i,1)}}};this.notifyObservers=function(methodName,data){if(!methodName||this.suppressNotifications){return}var i=this.observers.length,obs;while(i--){obs=this.observers[i];if(obs){if(typeof obs=="function"){obs(methodName,this,data)}else{if(obs[methodName]&&typeof obs[methodName]=="function"){obs[methodName](this,data)}}}}};this.enableNotifications=function(){this.suppressNotifications=false};this.disableNotifications=function(){this.suppressNotifications=true}},scrollto:function(element){var stylize=function(element){return !+"\v1"?element.currentStyle:document.defaultView.getComputedStyle(element,null)},getPosition=function(element){var computedStyle,tryComputedStyle,position={x:0,y:0};if(element.style.left&&/px/i.test(element.style.left)){position.x=parseInt(element.style.left,10)}else{computedStyle=stylize(element);var tryComputedStyle=computedStyle&&computedStyle.left&&/px/i.test(computedStyle.left);if(tryComputedStyle){position.x=parseInt(computedStyle.left,10)}if(!tryComputedStyle||position.x==0){position.x=element.offsetLeft}}if(element.style.top&&/px/i.test(element.style.top)){position.y=parseInt(element.style.top,10)}else{if(!computedStyle){computedStyle=stylize(element)}var tryComputedStyle=computedStyle&&computedStyle.top&&/px/i.test(computedStyle.top);if(tryComputedStyle){position.y=parseInt(computedStyle.top,10)}if(!tryComputedStyle||position.y==0){position.y=element.offsetTop}}return position};scroll(0,getPosition(element).y)},forEach:function(obj,fn){if(!obj){return v}var key,i=0,length,undefined,result=[];if(vanilla.is.array(obj)){length=obj.length;for(;i<length;i++){result[result.length]=fn.apply(top,[obj[i],i]);if(result[result.length-1]===false){break}}}else{for(var key in obj){result[result.length]=fn.apply(top,[obj[key],key]);if(result[result.length-1]===false){break}}}return result.length?result:v},stringify:function(obj){var t=typeof(obj);if(t!=object||obj===null){if(t==string){obj='"'+obj+'"'}return String(obj)}else{var n,v,json=[],arr=vanilla.is.array(obj);for(n in obj){if(n!=="ds_JSONObject"){v=obj[n];t=typeof(v);if(t==string){v='"'+v+'"'}else{if(t=="object"&&v!==null){v=vanilla.stringify(v)}}json.push((arr?"":'"'+n+'":')+String(v))}}return(arr?"[":"{")+String(json)+(arr?"]":"}")}},cache:(function(){var internals={},kb=2000,notSupported=function(){return(vanilla.browser.ie&&vanilla.browser.version<=6&&vanilla.browser.servicepack!="sp3")},process=function(str){var unsave=function(){return(Function("return "+str))()},res;if(vanilla.supports.json){try{res=JSON.parse(str)}catch(e){res=unsave()}}else{res=unsave()}return res||false},limit=function(){return Math.round(top.name.length/1024)<kb},stringify=function(data){if(!vanilla.is.string(data)){if(vanilla.is.array(data)||vanilla.is.object(data)){return vanilla.stringify(data)}else{try{data=data.toString()}catch(e){}}}return data},api={getKey:function(){var cookie=vanilla.cookie.getItem("cacheToken"),p=vanilla.params;return cookie||[p.destination,p.arrival,p.departure,p.lang,p.num_persons].join("/")},setItem:function(key,data){key=key||api.getKey();data=(data=data||(internals&&key?internals[key]:false))?stringify(data):false;if(!data||notSupported()||!vanilla.is.string(data)||!key||data==undefined){return v}if(!vanilla.supports.sessionStorage){if(!limit()){top.name=""}top.name+=(top.name.match("::")?"||":"")+[key,data].join("::")}else{sessionStorage.setItem(key,data)}return v},getItem:function(key,raw){key=key||api.getKey();if(!key||notSupported()){return}if(!vanilla.supports.sessionStorage){var data=top.name.split("||"),i=data.length,items,result;while(i--){items=data[i].split("::");if(items[0]===key){return process(items[1])}}}else{var data=sessionStorage.getItem(key);return raw?data?data:"[no-data]":data?process(data.value||data):false}return false},clear:function(){if(!vanilla.supports.sessionStorage){top.name=""}else{if(sessionStorage.clear){sessionStorage.clear()}else{if(sessionStorage.removeItem){var storage;for(storage in sessionStorage){sessionStorage.removeItem(storage)}}}}return v},setInternals:function(data,key){key=key||api.getKey();if(!key||!data){return v}internals[key]=data;return v},getInternals:function(key){key=key||api.getKey();return internals[key]}};return api})(),cookie:(function(){var limit=8190,exceeds=function(str){return(document.cookie.length+str.length)>limit},set=function(key,data,options){var defaults={days:1,domain:document.domain,path:"/"},date=new Date(),dough;key=key+"=";vanilla.extend(defaults,options);date.setTime(date.getTime()+(defaults.days*86400000));defaults.days=date.toGMTString();dough=[key+escape(data),"expires="+defaults.days,"path="+defaults.path,"domain="+defaults.domain].join(";");if(!exceeds(dough)){return document.cookie=dough}else{return false}},get=function(key){var cookieJar=document.cookie.split(";"),i=cookieJar.length,tmp;key=key+"=";while(i--){tmp=cookieJar[i];while(tmp.charAt(0)==" "){tmp=tmp.substring(1,tmp.length)}if(tmp.indexOf(key)==0){return unescape(tmp.substring(key.length,tmp.length))}}return false},clear=function(key){return set(key,"",{days:-1})},once=function(key){var data=get(key);clear(key);return data};return{getItem:get,setItem:set,clear:clear,once:once}})(),eval:function(str){return eval(str)},remove:function(object){for(var i=1,arg=arguments,length=arg.length;i<length;i++){delete object[arg[i]]}return v},script:{clean:function(src){return typeof src==string&&src.length>0?/^(.*\/)?([^?\/#]*)(\?.*)?(#.*)?$/i.exec(src)[2].toLowerCase():""},exists:function(src){var scripts=document.getElementsByTagName("script"),i=scripts.length;while(i--){if(typeof scripts[i].src===string&&src===vanilla.script.clean(scripts[i].src)){return true}}return false}},ready:false,readyQue:[],onDOMReady:function(fn){if(vanilla.ready){return fn.call(document,vanilla,fuel)}if(!vanilla.readyQue.length){var ready=function(){if(vanilla.ready){return}vanilla.ready=true;var i=vanilla.readyQue.length;while(i--){vanilla.readyQue[i].call(document,vanilla,fuel)}vanilla.readyQue.length=0};if(document.readyState&&!+"\v1"){if(location.protocol!=="https"){document.write("<script id='vanillaready' defer=true src=//:><\/script>");document.getElementById("vanillaready").onreadystatechange=function(){if(this.readyState&&this.readyState!=="complete"&&this.readyState!=="loaded"){return}ready()}}else{(function(){try{documentElement.doScroll("left")}catch(e){return setTimeout(arguments.callee,0)}ready()})()}}else{if(document.readySate&&vanilla.is.webkit&&vanilla.is.version<525){(function(){return/loaded|complete/.test(document.readyState)?ready():setTimeout(arguments.callee,0)})()}else{if(document.addEventListener){document.addEventListener("DOMContentLoaded",ready,false)}}}vanilla.addEvent("load",ready)}vanilla.readyQue[vanilla.readyQue.length]=fn},getLanguage:function(){var languageTag=document.getElementsByTagName("html")[0].getAttribute("lang")||document.getElementsByTagName("html")[0].getAttribute("xml:lang");if(!languageTag){languageTag="en"}else{languageTag=languageTag.toLowerCase()}return languageTag}};vanilla.extend(fuel,{vanillatize:function(){return vanilla},env:{lang:vanilla.getLanguage()},parseDate:function(arrdate,datePickerController,fancy){if(!arrdate||!arrdate.match(/arrival/g)){return{}}datePickerController=datePickerController||window.datePickerController;var frags=arrdate.split(arrdate.match("&")?"&":","),fix=function(num){return num<10?"0"+num:num},result={},length=frags.length,i=0,pattern="y-ds-m-ds-d",contents,arrival,departure,range=new Date(),ret={};for(;i<length;i++){contents=frags[i].split("=");result[contents[0]]=contents[1].match(/^([0-9\-]*)$/g)?contents[1].split("-"):contents[1];if(arrdate.match(",")){result[contents[0]].reverse()}}arrival=datePickerController.parseDateString(result.arrival.join(""),pattern);ret.arrival=datePickerController.printFormattedDate(arrival,fancy);range.setTime(arrival.getTime()+86400000);departure=datePickerController.parseDateString(result.departure.join(""),pattern);ret.departure=datePickerController.printFormattedDate(departure,fancy);departure.setTime(arrival.getTime()+2592000000);ret.arrival_rangelow=result.arrival.join("");ret.departure_rangelow=[range.getFullYear(),fix(range.getMonth()+1),fix(range.getDate())].join("");ret.departure_rangehigh=[departure.getFullYear(),fix(departure.getMonth()+1),fix(departure.getDate())].join("");return ret},_autosuggest:function(){if(!fuel.data){fuel.data={}}var ds=fuel.data,suggestions,context=document.body;if(!ds.suggestions){this.setAttribute("AutoComplete","off");suggestions=Spry.$("suggestions");ds.suggestions=new Spry.Data.DataSet({url:"/cgi-bin/autocomplete.pl?lang="+fuel.env.lang,name:"suggestions",useUnique:false,jsonpsuffix:"_suggest"});ds.suggestions.dataWasLoaded=true;ds.destination=new Spry.Data.NestedDataSet(ds.suggestions,"destinations",{name:"destinations"});ds.destination.addObserver({onPostLoad:function(){try{var data=ds.suggestions.data,i=data.length,regexp=new RegExp("(<[^>]*>)|("+(Spry.$("search").value.replace(/([-.*+?^${}()|[\]\/\\])/,"\\$1").replace(/([\.\/\]\[\{\}\(\)\\\$\^\?\*\|\!\=\+\-])/g,"\\$1")||"amsterdam")+")","igm"),nested,j,rows;while(i--){nested=ds.destination.getNestedDataSetForParentRow(data[i]);if(nested){rows=nested.getData();j=rows.length;while(j--){rows[j].result=rows[j].name.replace(regexp,function(a,b,c){return"<strong>"+c+"</strong>"})}}}}catch(e){}}});fuel.autosuggest=new Spry.Widget.AutoSuggest("autosuggest",suggestions,ds.destination,"name",{loadFromServer:true,urlParam:"q",containsString:true,callback:function(str){Spry.$("type").value=str.length?str[1]:"city"},hasFocus:true,stopFocus:false,moveNextKeyCode:40,movePrevKeyCode:38});Spry.Data.initRegions(suggestions);Spry.$$("#search",context).removeEventListener("keydown",arguments.callee)}},_datePicker:function(datePickerController,fancy,output,click,arrival_min,arrival_max,departure_min,departure_max,close){var arrival=Spry.$$('input[name="arrival"]'),departure=Spry.$$('input[name="departure"]'),koekje=fuel.parseDate(vanilla.cookie.getItem("arrdate"),datePickerController,fancy),nodepart=Spry.$("no-depart");arrival.forEach(function(node,i){var a={},d={},self=this;a[this.id]=d[departure[i].id]=fancy;if(koekje&&koekje.arrival&&koekje.departure){this.value=koekje.arrival;departure[i].value=koekje.departure}datePickerController.createDatePicker({formElements:a,rangeLow:arrival_min,rangeHigh:arrival_max,showWeeks:true,noToday:true,noFadeEffect:true,close:close,statusFormat:"l-cc-sp-d-sp-F-sp-Y",callbackFunctions:{dateset:[function(options){if(!options.date){return}if(departure[i].id=="departure"&&nodepart&&this.firstRunRan){nodepart.checked=false}this.firstRunRan=true;var date=new Date(options.date);date.setTime(options.date.getTime()+86400000);datePickerController.setRangeLow(departure[i].id,datePickerController.printFormattedDate(date,output,true));if(document.getElementById("fd-"+self.id)){departure[i].value=datePickerController.printFormattedDate(date,fancy,true)}date.setTime(date.getTime()+2505600000);datePickerController.setRangeHigh(departure[i].id,datePickerController.printFormattedDate(date,output,true))}]}});datePickerController.createDatePicker({formElements:d,rangeLow:koekje.departure_rangelow||departure_min,rangeHigh:koekje.departure_rangehigh||departure_max,showWeeks:true,noToday:true,noFadeEffect:true,close:close,statusFormat:"l-cc-sp-d-sp-F-sp-Y",callbackFunctions:{dateset:[function(){if(!this.firstRunRan){return this.firstRunRan=true}if(departure[i].id=="departure"&&nodepart){nodepart.checked=false}}]}});this.readOnly=departure[i].readOnly=true}).addEventListener(click,function(){datePickerController.show(this.id)});departure.addEventListener(click,function(){datePickerController.show(this.id)})},_ready:function(dp_args,context,$$){fuel._datePicker.apply(top,dp_args);$$("ul.service").forEach(function(){var active,timer,li=$$("li.change",this),a=$$("li.change span + a",this);li.forEach(function(node,index){Spry.Utils.addEventListener(this,"click",function(){if(active){Spry.Utils.removeClassName(active,"active")}active=li[index];Spry.Utils.addClassName(active,"active");return false})});$$("ul",this).addEventListener("mouseover",function(){try{clearTimeout(timer)}catch(e){}});$$("ul",this).addEventListener("mouseout",function(){timer=setTimeout(function(){Spry.Utils.removeClassName(active,"active")},1000)});$$("ul a",this).addEventListener("click",function(){if(this.href){top.location=this.href}})})},_init:function(version,context,$$,value){var set=Spry.Utils.setAttribute,form=Spry.$("frm-search"),field;$$("#autosuggest",context).forEach(function(){$$("div",this).setAttribute("spry:region","fuel.data.suggestions fuel.data.destination");$$("ul",this).setAttribute("spry:repeat","fuel.data.suggestions");var li=$$("li",this);set(li[0],"spry:content","{fuel.data.suggestions::name}");set(li[1],"spry:repeat","fuel.data.destination");set(li[1],"spry:suggest","{fuel.data.destination::name},{fuel.data.suggestions::type}");set(li[1],"spry:content","{fuel.data.destination::result} <span>{fuel.data.destination::hotel_count}</span>")});field=$$("#search",context).addEventListener("keydown",fuel._autosuggest);$$("form.newsletter",context).forEach(function(){var text=$$("#email",context).addEventListener("focus",function(){return this.value==text?this.value="":false}).addEventListener("blur",function(){return this.value==""?this.value=text:false})[0].value});$$("form.search-header",context).forEach(function(){var text=field.addEventListener("focus",function(){var type=Spry.$("type");if(type){type.value=""}return this.value==text?this.value="":false}).addEventListener("blur",function(){return this.value==""?this.value=text:false})[0].value}).addEventListener("submit",function(){if(field[0].value==value||field[0].value==""){Spry.Effect.DoShake(field[0],{duration:500});return false}});$$("ul.page-options li:last-child",context).addEventListener("click",function(){top.print()});Spry.Utils.addEventListener(top,"unload",function(){$$("ul.page-options li:last-child",context).removeEventListener("click",function(){top.print()});Spry.Utils.removeEventListener(top,"unload",arguments.callee)});fuel.inject.script("https:"==document.location.protocol?"https://ssl.google-analytics.com/ga.js":"http://scripts.hotels.nl/js/version:"+version+"/ga.js").wait(function(){(fuel.pageTracker=_gat._getTracker("UA-499674-5"))._setDomainName("www.hotels.nl");fuel.pageTracker._trackPageview()})},inject:(function(allscripts){var api=function(){vanilla.notify.call(this);var self=this;this.script=function(){var engine=new diesel(this);return engine.script.apply(engine,arguments)};this.wait=function(){var engine=new diesel(this);return engine.wait.apply(engine,arguments)};this.diesel=function(where,queue){return(new diesel(this,queue,where))};this.observe=function(observer){self.addObserver(observer);return self}},diesel=function(observer,queue,where){this.scripts={};this.queue=!(!queue);this.observer=observer;this.location=where||(document.getElementsByTagName("head")[0]||documentElement);this.loading=false;this.ready=false;this.que=null;this.executeables=[]};diesel.prototype={load:function(src,type,lang,duplicate){var filename=vanilla.script.clean(src),self=this,callback=function(script){if(((this.readyState||fn[0].call(top.opera)==="[object Opera]")&&this.readyState!=="complete"&&this.readyState!=="loaded")||script.loaded){return}this.onload=this.onreadystatechange=null;script.loaded=true;setTimeout(function(){self.observer.notifyObservers(filename,{vanilla:vanilla,fuel:fuel,ready:vanilla.ready,script:this})},0);var i;for(i in self.scripts){if(self.scripts[i]!=Object.prototype[i]&&!(self.scripts[i].loaded)){return}}self.ready=true;if(self.que!==null){return self.que()}};duplicate=!!duplicate;if(duplicate&&(typeof allscripts[filename]!==undefined||vanilla.script.exists(filename))){return this.que!==null?this.que():""}if(this.scripts[filename]==undefined){this.scripts[filename]={loaded:false}}else{this.scripts[filename].loaded=false}allscripts[filename]=true;this.loading=true;setTimeout(function(){var scripty=document.createElement("script");scripty.setAttribute("type",type||"text/javascript");scripty.setAttribute("language",lang||"javascript");scripty.setAttribute("src",src);scripty.onload=scripty.onreadystatechange=function(){callback.call(scripty,self.scripts[filename])};self.location.appendChild(scripty)})},script:function(){var arg=arguments,length=arg.length,i=0,self=this,type;return this.executeOrQue(function(){for(;i<length;i++){type=typeof arg[i];if(vanilla.is.array(arg[i])){arg.callee.apply(null,arg[i])}else{if(type===object){self.load(arg[i].src,arg[i].type,arg[i].lang,arg[i].duplicate)}else{if(type===string){self.load(arg[i])}}}}return self},self)},wait:function(fn){var old=fn,engine=new diesel(this.observer,true,this.location),self=this;fn=function(){try{if(vanilla.is.fn(old)){old()}}catch(e){}return engine.processQues()};return this.executeOrQue(function(){if(self.loading&&!self.ready){self.que=fn}else{setTimeout(fn,0)}return engine},engine)},executeOrQue:function(execute,ret){if(this.queue){this.executeables[this.executeables.length]=execute;return ret}return execute()},processQues:function(){for(var i=0,fns=this.executeables,length=fns.length;i<length;i++){fns[i](vanilla,fuel,this)}this.observer.notifyObservers("processedQue",{vanilla:vanilla,fuel:fuel,ready:vanilla.ready,que:this.executeables.concat()});this.executeables.length=0},diesel:function(where,queue){return(new diesel(this.observer,queue,where))}};api.prototype=new vanilla.notify();api.prototype.constructor=api;return new api()})({})});if(fn[0].call(top.opera)==="[object Opera]"){history.navigationMode="compatible"}else{if(!+"\v1"&&vanilla.browser.version==6){try{document.execCommand("BackgroundImageCache",false,true)}catch(e){}}}tmp.content=(tmp.scripts=document.getElementsByTagName("script"))[tmp.scripts.length-1].innerHTML;vanilla.onDOMReady(function(){tmp.end=(new Date()).valueOf();var e=document.getElementById("parsetime");if(e){e.innerHTML=tmp.end-fuel.start}});vanilla.addEvent("load",function(){tmp.enddate=(new Date()).valueOf();var e=document.getElementById("loadtime");if(e){e.innerHTML=tmp.enddate-fuel.start}});return setTimeout(Function(tmp.content.replace(/(\/\*([\s\S]*?)\*\/)|(?:^\s*<!--\s*|\s*(?:\/\/)?\s*-->\s*$)|(<!--([\s\S]*?)-->)/gm,"")),0)})(window,{});