var trackbarActive=true;var currentHoverParameter=null;var chp_trackbar=new Class({options:{mode:0,form:null,trackbar:null,inputLeft:null,inputRight:null,label:null,labeltype:0,values:null,decimals:0,step:null,limitLeft:0,limitRight:100,valueLeft:null,valueRight:null,t:null,showApply:false,extremumValueToNull:1},initialize:function(_1){var _2,tb,w,sl,_3,sr,_4,_5,_6;this.setOptions(_1);this.bound={"start":this.start.bindWithEvent(this),"drag":this.drag.bindWithEvent(this),"stop":this.stop.bind(this),"update":this.update.bind(this),"set":this.set.bindWithEvent(this)};_2=this.options.mode;tb=this.options.trackbar;tb.removeClass("hid");this.elem=tb;w=tb.offsetWidth;this.trackbarWidth=w;sl=tb.querySelector(".left-slider");this.sliderLeft=sl;$(sl).addEvent("mousedown",this.bound.start);_3=sl.offsetWidth;this.sliderLeftWidth=_3;if(_2!=1){sr=tb.querySelector(".right-slider");this.sliderRight=sr;$(sr).addEvent("mousedown",this.bound.start);_4=sr.offsetWidth;}else{_4=0;}this.sliderRightWidth=_4;this.sliderLeftX=0;this.sliderRightX=0;_5=tb.querySelector(".chp-fullrange");$(_5).addListener("mousedown",this.bound.start);this.fullrange=_5;if(_2!=1){_6=tb.querySelector(".chp-selrange");$(_6).addListener("mousedown",this.bound.start);this.range=_6;}this.inputLeft=this.options.form[this.options.inputLeft];if(!_2){this.inputRight=this.options.form[this.options.inputRight];this.inputLeft.addListener("change",this.bound.set);this.inputRight.addListener("change",this.bound.set);}this.activePixels=w-_3-_4;this.rangeOfValues=this.options.limitRight-this.options.limitLeft;this.pixelsPerValue=this.activePixels/this.rangeOfValues;this.update();},start:function(_7){var p,_8,_9,_a,x,_b,_c,_d,_e;_7=new Event(_7);if(!currentHoverParameter){p=getParentElement(this.sliderLeft,"chp-trackbarparam");if(p){p.fireEvent("mouseenter");}}trackbarActive=true;_8=false;_9=getY(this.elem)-window.getScrollTop();this.elem.setProperty("style","position:fixed;width:"+this.trackbarWidth+"px;top:"+_9+"px;");if(_7.target==this.fullrange){if(this.options.mode==1){this.slider=this.sliderLeft;this.startX=this.slider.getLeft()+this.sliderLeftWidth/2;_a=_7.page.x-this.startX;}else{_b=this.sliderLeft.getLeft();_d=_7.page.x;if(_d<_b){this.slider=this.sliderLeft;this.startX=_b+this.sliderLeftWidth/2;_a=_d-this.startX;}else{this.slider=this.sliderRight;this.startX=this.slider.getLeft()+this.sliderRightWidth/2;_a=_d-this.startX;}}_8=true;}else{if(_7.target==this.range){_b=this.sliderRight.getLeft();_c=this.sliderLeft.getLeft();_e=(_b+_c+this.sliderLeftWidth)/2;_d=_7.page.x;if(_d<_e){this.slider=this.sliderLeft;this.startX=_c+this.sliderLeftWidth/2;_a=_d-this.startX;}else{this.slider=this.sliderRight;this.startX=_b+this.sliderRightWidth/2;_a=_d-this.startX;}_8=true;}else{this.slider=_7.target;this.startX=_7.page.x;}}x=this.slider.offsetLeft;if(this.slider===this.sliderRight){x-=this.sliderRightWidth;}this.sliderPosX=(x>this.activePixels)?this.activePixels:x;document.addEvent("mousewheel",this.disableMouseWheel);if(window.addEventListener){window.addEventListener("DOMMouseScroll",this.disableMouseWheel,true);}document.addListener("mousemove",this.bound.drag);document.addListener("mouseup",this.bound.stop);if(this.options.label){this.labelValue=this.options.label.querySelector(".ppvalue");}_7.stop();if(_8){this.calcDrag(_a);}},drag:function(_f){_f=new Event(_f);var _10=_f.page.x-this.startX;this.calcDrag(_10);_f.stop();},calcDrag:function(_11){var v=((_11+this.sliderPosX)/this.activePixels)*this.rangeOfValues+this.options.limitLeft;v=v.toFixed(this.options.decimals).toFloat();if($defined(this.options.step)){v=v/this.options.step;v=Math.round(v)*this.options.step;}if(v<this.options.limitLeft){v=this.options.limitLeft;}if(v>this.options.limitRight){v=this.options.limitRight;}if(this.slider===this.sliderLeft){if(v==this.options.valueLeft||((v==this.options.valueLeft||this.options.valueLeft==null)&&v==this.options.limitLeft)){return;}}else{if(v==this.options.valueRight||((v==this.options.valueRight||this.options.valueRight==null)&&v==this.options.limitRight)){return;}}this.options.showApply=true;if(this.slider===this.sliderRight){this.setValueRight(v);}else{this.setValueLeft(v);}},stop:function(_12){trackbarActive=false;_12=new Event(_12);var xy={custom:true,x:_12.page.x,y:_12.page.y,};if(currentHoverParameter){currentHoverParameter.fireEvent("mouseleave",xy);}document.removeListener("mousemove",this.bound.drag);document.removeListener("mouseup",this.bound.stop);this.slider=null;this.elem.style.position="absolute";this.elem.style.top="";document.removeEvent("mousewheel",this.disableMouseWheel);if(window.removeEventListener){window.removeEventListener("DOMMouseScroll",this.disableMouseWheel,true);}},update:function(){if(this.options.labeltype==1){this.notSetLabel=true;}this.setValueLeft(this.options.valueLeft);if(this.options.mode!=1){this.setValueRight(this.options.valueRight);}this.notSetLabel=false;},set:function(){var l=this.inputLeft.value.toInt();var r=this.inputRight.value.toInt();if(l){this.setValueLeft(l);}else{this.setValueLeft(this.options.limitLeft);}if(r){this.setValueRight(r);}else{this.setValueRight(this.options.limitRight);}},setValueLeft:function(v){var vr=this.options.valueRight;var inp,rs,vrs,ll=null,lr=null;var r=this.checkValue(v,vr,this.options.limitLeft,"left");this.options.valueLeft=r;var _13=this.options.mode;if(_13==0){this.inputLeft.value=(r==null)?"":r;}else{if(_13==1){rs=(r==null)?null:(this.options.values?this.options.values[r]:r);this.inputLeft.value=rs?rs:"";if(!this.notSetLabel){this.setLabel(rs,null);}}else{if(r==null||r==this.options.limitLeft){if(vr==null||vr==this.options.limitRight){inp="";}else{vrs=this.options.values?this.options.values[vr]:vr;inp=":"+vrs;lr=vrs;}}else{if(this.options.values){rs=this.options.values[r];vrs=this.options.values[vr];}else{rs=r;vrs=vr;}if(vr==null||vr==this.options.limitRight){if(r==this.options.limitRight){inp=rs+":"+rs;ll=lr=rs;}else{inp=rs+":";ll=rs;}}else{inp=rs+":"+vrs;ll=rs;lr=vrs;}}this.inputLeft.value=inp;if(!this.notSetLabel){this.setLabel(ll,lr);}}}var w=this.width(r==null?0:(r-this.options.limitLeft));this.sliderLeft.setStyle("left",w+"px");this.sliderLeftX=w;if(_13!=1){this.updateRangeWidth();}return this.options.valueLeft;},setValueRight:function(v){var vl=this.options.valueLeft;var inp,rs,vls,ll=null,lr=null;var r=this.checkValue(v,vl,this.options.limitRight,"right");this.options.valueRight=r;var _14=this.options.mode;if(_14==0){this.inputRight.value=(r==null)?"":r;}else{if(r==null||r==this.options.limitRight){if(vl==null||vl==this.options.limitLeft){inp="";}else{vls=this.options.values?this.options.values[vl]:vl;inp=vls+":";ll=vls;}}else{if(this.options.values){rs=this.options.values[r];vls=this.options.values[vl];}else{rs=r;vls=vl;}if(vl==null||vl==this.options.limitLeft){if(r==this.options.limitLeft){inp=rs+":"+rs;ll=lr=rs;}else{inp=":"+rs;lr=rs;}}else{inp=vls+":"+rs;ll=vls;lr=rs;}}this.inputLeft.value=inp;if(!this.notSetLabel){this.setLabel(ll,lr);}}var w=this.width(r==null?0:(this.options.limitRight-r));this.sliderRight.setStyle("right",w+"px");this.sliderRightX=w;this.updateRangeWidth();return this.options.valueRight;},checkValue:function(v,_15,e,_16){l=this.options.limitLeft;r=this.options.limitRight;if(_16=="left"){_15=(_15==null?r:_15);v=(v==null?null:(v<l?l:(v<_15?v:_15)));}else{if(_16=="right"){_15=(_15==null?l:_15);v=(v==null?null:(v>r?r:(v>_15?v:_15)));}}return v==e&&this.options.extremumValueToNull?null:v;},width:function(_17){var r=(this.pixelsPerValue)*_17;return Math.round(r);},updateRangeWidth:function(){$(this.range).setStyles({left:this.sliderLeftX,right:this.sliderRightX});},setLabel:function(l,r){var lv=this.labelValue||this.options.label.querySelector(".ppvalue"),opt=this.options,s="";if(opt.showApply&&opt.labeltype==1){s="<button type=\"button\" class=\"ppapply\" onclick=\"applyRefines("+this.options.form.name+")\">";}if(opt.labeltype==0){s+="<span class=\"ppvalue2\" data-pname=\""+opt.inputLeft+"\" onclick=\"clearRefine(this,"+this.options.form.name+")\" onmouseover=\"clearHover(this,true)\" onmouseout=\"clearHover(this,false)\">";}if(opt.mode==1){s+=(l)?l:words.all;}else{if(!l){l=opt.values?opt.values[opt.limitLeft]:opt.limitLeft;}if(!r){r=opt.values?opt.values[opt.limitRight]:opt.limitRight;}if(l==r){s+="<b>"+l+"</b>";if(opt.t.u){s+=" "+opt.t.u;}}else{if(opt.labeltype==1){s+=words.from+" <b>"+l+"</b> "+words.to+" <b>"+r+"</b>";}else{s+="<b>"+l+"</b> - <b>"+r+"</b>";}if(opt.t.u){s+=" "+opt.t.u;}}}if(opt.showApply&&opt.labeltype==1){s+=" - <b>"+words.apply+"</b></button>";}if(opt.labeltype==0){s+="</span>";}if(opt.showApply&&opt.labeltype==0){s+=" <button type=\"button\" class=\"ppapply2\" onclick=\"applyRefines("+this.options.form.name+")\">"+words.apply+"</button>";}if(opt.labeltype==0){s+="<div class=\"clear\"></div>";}lv.innerHTML=s;},disableMouseWheel:function(_18){var e=new Event(_18);e.preventDefault();return false;}});chp_trackbar.implement(new Options);function getY(el){var top=0;do{top+=el.offsetTop||0;el=el.offsetParent;}while(el);return top;};function getParentElement(el,_19){do{if(el.className==_19){return el;}el=el.parentNode;}while(el);return null;};function applyRefines(f){var els=f.querySelectorAll("input[type='hidden']"),hp=document.getElementById("high-price"),lp=document.getElementById("low-price");for(i=0,j=els.length;i<j;++i){if(els[i].value==""){$(els[i]).remove?$(els[i]).remove():$(els[i]).destroy();}}if(hp&&hp.value==""){hp.name="";}if(lp&&lp.value==""){lp.name="";}f.submit();};function clearRefine(el,f){var t=chp[el.getAttribute("data-pname")];if(t.options.valueLeft==null&&t.options.valueRight==null){return;}t.options.valueLeft=null;t.options.valueRight=null;t.update();applyRefines(f);};function clearHover(el,on){var t=chp[el.getAttribute("data-pname")];if(!on){$(el).removeClass("cl-hov");return;}if(t.options.valueLeft==null&&t.options.valueRight==null){return;}$(el).addClass("cl-hov");};
