function sTokenizer(b,a){this.src=b;this.opts=a;this.delim=this.opts.delim||"~";this.breakPoint=this.opts.breakPoint||7;this.peek=null;this.callfn=function(){if(typeof this.opts.callBack!="function"){return}this.opts.callBack(this.peek,this.delim)};this.walk=function(){var d=0;for(var c=0;c<this.src.length;++c){ch=this.src.charAt(c);if(ch==this.delim){d++}if(d==this.breakPoint){this.peek=this.src.charAt(this.breakPoint+1);break}}this.callfn()}}var smartList=function(a){return this._init(a)};smartList.prototype={_init:function(a){this.Selectors={place:[],type:[]};this.Attributes={kamers:[],perceel:[],woon:[]};this.Attributes.kamers=["1","2","3","4","5"];this.Attributes.perceel=["0-250","250-500","500-1000","1000-2500","2500-5000","5000-9999"];this.Attributes.woon=["0-50","50-75","75-100","100-150","150-250"];this.listContainer=document.getElementById("SearchContainer");this.recInfos=a.recInfo;this._debug=((a.debug=="undefined")||a.debug==null)?false:a.debug;this.curPreFilter=((a.preFilter=="undefined")||a.preFilter==null)?null:a.preFilter;this.smartNav=((a.smartNav=="undefined")||a.smartNav==null)?null:a.smartNav;if(a.recInfo){this._setup_new()}else{return}var b=1;if(this.curPreFilter!=null){this.tokenizer=new sTokenizer(this.curPreFilter,{callBack:function(c,d){if(c==d){b=1}else{if(c==2){b=2}else{b=1}}}});this.tokenizer.walk()}this.prePriceType=b;this.setList()},setList:function(){if(!gr_objExists(this.listContainer)){return}var a=document.getElementById("ssFilterType");if(!gr_objExists(a)){a=1}else{a=a.value}if(a==2){this.addSelect(this.listContainer,this.Selectors.place,"Plaats");this.addSelect(this.listContainer,this.Selectors.type,"Type");if((priceList=this.getPriceList(this.prePriceType))!==false){this.addSelect(this.listContainer,priceList,"Prijs","&euro; ",true)}}else{this.addBox(this.listContainer,this.Selectors.place,"Plaats");this.addBox(this.listContainer,this.Selectors.type,"Type");if((priceList=this.getPriceList(this.prePriceType))!==false){this.addBox(this.listContainer,priceList,"Prijs","&euro; ",true)}this.extSearch(this.listContainer)}if(this._debug){alert("DEBUG_[SET_LIST] listboxen aangemaakt.")}},_setup_new:function(){var a,c;for(var b=0;b<this.recInfos.length;b++){if(!gr_objExists(document.getElementById(this.recInfos[b]))||document.getElementById(this.recInfos[b]).style.display=="none"){continue}a=document.getElementById(this.recInfos[b]).value.split("~");if(this.smartNav!=null){if(this.curPreFilter=="INT_RECENT"){a[0]+="~"+a[7]}if(this.smartNav.indexOf(a[0])==-1){continue}}if((c=this.Selectors.place.indexOf(a[2]))==-1){this.Selectors.place.push(a[2])}if((c=this.Selectors.type.indexOf(a[3]))==-1){this.Selectors.type.push(a[3])}}this.Selectors.place.sort();this.Selectors.type.sort();if(this._debug){alert("DEBUG_[LIST_SETUP] de lijsten zijn succesvol aangemaakt.")}},addSelect:function(f,c,e,h,g){var b=document.createElement("div");b.className="ssFilterSelect ssFilter"+e;b.filterTitle=document.createElement("span");b.filterTitle.className="ssFilterSelectName";if(gr_isIE){b.filterTitle.innerText=e+" "}else{b.filterTitle.textContent=e+" "}b.appendChild(b.filterTitle);e=e.toLowerCase();h=(!h)?"":h;b.filterSelect=document.createElement("select");b.filterSelect.onchange=function(){setSFilter(this,e.toString())};b.filterSelect.fItems=[];b.filterSelect.Empty=document.createElement("option");if(gr_isIE){b.filterSelect.Empty.innerText="-- Geen voorkeur --"}else{b.filterSelect.Empty.textContent="-- Geen voorkeur --"}b.filterSelect.Empty.value="geen";b.filterSelect.appendChild(b.filterSelect.Empty);for(var d=0;d<c.length;d++){b.filterSelect.fItems.push(document.createElement("option"));b.filterSelect.fItems[d].value=c[d];if(e=="prijs"){if(d==0||d==c.length-1){b.filterSelect.fItems[d].innerHTML=this.formatArrPrice(c[d])}else{b.filterSelect.fItems[d].innerHTML=(!g)?c[d]+h:h+this.formatArrPrice(c[d])}}else{b.filterSelect.fItems[d].innerHTML=(!g)?c[d]+h:h+c[d]}b.filterSelect.appendChild(b.filterSelect.fItems[d])}b.appendChild(b.filterSelect);f.appendChild(b);if(this._debug){alert("DEBUG_[ADD_SELECT] select: "+e+" aangemaakt.")}},addBox:function(f,b,e,i,h){var g=document.createElement("div");g.className="ssFilterSelect ssFilter"+e;g.filterTitle=document.createElement("span");g.filterTitle.className="ssFilterSelectName";if(gr_isIE){g.filterTitle.innerText=e}else{g.filterTitle.textContent=e}g.appendChild(g.filterTitle);e=e.toLowerCase();g.filterSelect=document.createElement("ul");g.filterSelect.Empty=document.createElement("li");g.filterSelect.Empty.onclick=function(){clsFilter(this,e.toString())};if(gr_isIE){g.filterSelect.Empty.innerText="-- Geen voorkeur --"}else{g.filterSelect.Empty.textContent="-- Geen voorkeur --"}g.filterSelect.appendChild(g.filterSelect.Empty);i=(!i)?"":i;g.filterSelect.fItems=[];for(var d=0,c=b.length;d<c;++d){g.filterSelect.fItems.push(document.createElement("li"));g.filterSelect.fItems[d].onclick=function(){setFilter(this,e.toString())};g.filterSelect.fItems[d].className="filter_norm";g.filterSelect.fItems[d].title=b[d];if(e=="prijs"){if(d==0||d==b.length-1){g.filterSelect.fItems[d].innerHTML=this.formatArrPrice(b[d])}else{g.filterSelect.fItems[d].innerHTML=(!h)?b[d]+i:i+this.formatArrPrice(b[d])}}else{g.filterSelect.fItems[d].innerHTML=(!h)?b[d]+i:i+b[d]}g.filterSelect.appendChild(g.filterSelect.fItems[d])}g.appendChild(g.filterSelect);f.appendChild(g);if(this._debug){alert("DEBUG_[ADD_BOX] select: "+e+" aangemaakt.")}},formatArrPrice:function(b){var a=b.split("-");a[0]=this.formatPrice(a[0],true);a[1]=this.formatPrice(a[1],true);if(a[0]=="0"){return"tot &euro; "+a[1]}if(a[1]=="9.999.999"){return"vanaf &euro; "+a[0]}return a.join(" - ")},formatPrice:function(b,a){b=b.toString().replace(/\$|\,/g,"");a=!!a;for(var c=0;c<Math.floor((b.length-(1+c))/3);++c){b=b.substr(0,b.length-(4*c+3))+"."+b.substr(b.length-(4*c+3))}return((a)?"":"&euro; ")+b},getPriceList:function(a){if(!gr_objExists(document.getElementById("ssPriceFilter"+a))){return false}if(document.getElementById("ssPriceFilter"+a).value==""){return false}return document.getElementById("ssPriceFilter"+a).value.split("~")},advFilter:function(b){var c=document.getElementById("SearchContainer");if(!gr_objExists(document.getElementById("attrSearchContainer"))){var a=document.createElement("div");a.id="attrSearchContainer";c.appendChild(a);this.addBox(a,this.Attributes.perceel,"Perceel","m&sup2");this.addBox(a,this.Attributes.woon,"Woon","m&sup2");this.addBox(a,this.Attributes.kamers,"Kamers","+ kamers");b.innerHTML="Gereduceerd zoeken";b.className="Deducted";b.setAttribute("rel","Klik hier om gereduceerd te filtereren.");return}if(document.getElementById("attrSearchContainer").style.display=="none"){document.getElementById("attrSearchContainer").style.display="block";b.innerHTML="Gereduceerd zoeken";b.className="Deducted";b.setAttribute("rel","Klik hier om gereduceerd te filtereren.")}else{document.getElementById("attrSearchContainer").style.display="none";b.innerHTML="Uitgebreid zoeken";b.className="Extensive";b.setAttribute("rel","Klik hier om uitgebreider te filtereren.")}},extSearch:function(b){if(!gr_objExists(b)){return}var a=document.createElement("span");a.innerHTML="Uitgebreid zoeken";a.id="ExtensiveSearch";a.className="Extensive";a.setAttribute("rel","Klik hier om uitgebreider te filtereren.");a.onclick=function(){advFilter(this)};b.appendChild(a)}};var GR_SmartListInit=function(a){mySmartList=new smartList(a)};var advFilter=function(a){mySmartList.advFilter(a)};
