jQuery.ui||(function($){var _remove=$.fn.remove,isFF2=$.browser.mozilla&&(parseFloat($.browser.version)<1.9);$.ui={version:"1.7.1",plugin:{add:function(module,option,set){var proto=$.ui[module].prototype;for(var i in set){proto.plugins[i]=proto.plugins[i]||[];proto.plugins[i].push([option,set[i]]);}},call:function(instance,name,args){var set=instance.plugins[name];if(!set||!instance.element[0].parentNode){return;}for(var i=0;i<set.length;i++){if(instance.options[set[i][0]]){set[i][1].apply(instance.element,args);}}}},contains:function(a,b){return document.compareDocumentPosition?a.compareDocumentPosition(b)&16:a!==b&&a.contains(b);},hasScroll:function(el,a){if($(el).css("overflow")=="hidden"){return false;}var scroll=(a&&a=="left")?"scrollLeft":"scrollTop",has=false;if(el[scroll]>0){return true;}el[scroll]=1;has=(el[scroll]>0);el[scroll]=0;return has;},isOverAxis:function(x,reference,size){return(x>reference)&&(x<(reference+size));},isOver:function(y,x,top,left,height,width){return $.ui.isOverAxis(y,top,height)&&$.ui.isOverAxis(x,left,width);},keyCode:{BACKSPACE:8,CAPS_LOCK:20,COMMA:188,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38}};if(isFF2){var attr=$.attr,removeAttr=$.fn.removeAttr,ariaNS="http://www.w3.org/2005/07/aaa",ariaState=/^aria-/,ariaRole=/^wairole:/;$.attr=function(elem,name,value){var set=value!==undefined;return(name=="role"?(set?attr.call(this,elem,name,"wairole:"+value):(attr.apply(this,arguments)||"").replace(ariaRole,"")):(ariaState.test(name)?(set?elem.setAttributeNS(ariaNS,name.replace(ariaState,"aaa:"),value):attr.call(this,elem,name.replace(ariaState,"aaa:"))):attr.apply(this,arguments)));};$.fn.removeAttr=function(name){return(ariaState.test(name)?this.each(function(){this.removeAttributeNS(ariaNS,name.replace(ariaState,""));}):removeAttr.call(this,name));};}$.fn.extend({remove:function(){$("*",this).add(this).each(function(){$(this).triggerHandler("remove");});return _remove.apply(this,arguments);},enableSelection:function(){return this.attr("unselectable","off").css("MozUserSelect","").unbind("selectstart.ui");},disableSelection:function(){return this.attr("unselectable","on").css("MozUserSelect","none").bind("selectstart.ui",function(){return false;});},scrollParent:function(){var scrollParent;if(($.browser.msie&&(/(static|relative)/).test(this.css("position")))||(/absolute/).test(this.css("position"))){scrollParent=this.parents().filter(function(){return(/(relative|absolute|fixed)/).test($.curCSS(this,"position",1))&&(/(auto|scroll)/).test($.curCSS(this,"overflow",1)+$.curCSS(this,"overflow-y",1)+$.curCSS(this,"overflow-x",1));}).eq(0);}else{scrollParent=this.parents().filter(function(){return(/(auto|scroll)/).test($.curCSS(this,"overflow",1)+$.curCSS(this,"overflow-y",1)+$.curCSS(this,"overflow-x",1));}).eq(0);}return(/fixed/).test(this.css("position"))||!scrollParent.length?$(document):scrollParent;}});$.extend($.expr[":"],{data:function(elem,i,match){return !!$.data(elem,match[3]);},focusable:function(element){var nodeName=element.nodeName.toLowerCase(),tabIndex=$.attr(element,"tabindex");return(/input|select|textarea|button|object/.test(nodeName)?!element.disabled:"a"==nodeName||"area"==nodeName?element.href||!isNaN(tabIndex):!isNaN(tabIndex))&&!$(element)["area"==nodeName?"parents":"closest"](":hidden").length;},tabbable:function(element){var tabIndex=$.attr(element,"tabindex");return(isNaN(tabIndex)||tabIndex>=0)&&$(element).is(":focusable");}});function getter(namespace,plugin,method,args){function getMethods(type){var methods=$[namespace][plugin][type]||[];return(typeof methods=="string"?methods.split(/,?\s+/):methods);}var methods=getMethods("getter");if(args.length==1&&typeof args[0]=="string"){methods=methods.concat(getMethods("getterSetter"));}return($.inArray(method,methods)!=-1);}$.widget=function(name,prototype){var namespace=name.split(".")[0];name=name.split(".")[1];$.fn[name]=function(options){var isMethodCall=(typeof options=="string"),args=Array.prototype.slice.call(arguments,1);if(isMethodCall&&options.substring(0,1)=="_"){return this;}if(isMethodCall&&getter(namespace,name,options,args)){var instance=$.data(this[0],name);return(instance?instance[options].apply(instance,args):undefined);}return this.each(function(){var instance=$.data(this,name);(!instance&&!isMethodCall&&$.data(this,name,new $[namespace][name](this,options))._init());(instance&&isMethodCall&&$.isFunction(instance[options])&&instance[options].apply(instance,args));});};$[namespace]=$[namespace]||{};$[namespace][name]=function(element,options){var self=this;this.namespace=namespace;this.widgetName=name;this.widgetEventPrefix=$[namespace][name].eventPrefix||name;this.widgetBaseClass=namespace+"-"+name;this.options=$.extend({},$.widget.defaults,$[namespace][name].defaults,$.metadata&&$.metadata.get(element)[name],options);this.element=$(element).bind("setData."+name,function(event,key,value){if(event.target==element){return self._setData(key,value);}}).bind("getData."+name,function(event,key){if(event.target==element){return self._getData(key);}}).bind("remove",function(){return self.destroy();});};$[namespace][name].prototype=$.extend({},$.widget.prototype,prototype);$[namespace][name].getterSetter="option";};$.widget.prototype={_init:function(){},destroy:function(){this.element.removeData(this.widgetName).removeClass(this.widgetBaseClass+"-disabled"+" "+this.namespace+"-state-disabled").removeAttr("aria-disabled");},option:function(key,value){var options=key,self=this;if(typeof key=="string"){if(value===undefined){return this._getData(key);}options={};options[key]=value;}$.each(options,function(key,value){self._setData(key,value);});},_getData:function(key){return this.options[key];},_setData:function(key,value){this.options[key]=value;if(key=="disabled"){this.element[value?"addClass":"removeClass"](this.widgetBaseClass+"-disabled"+" "+this.namespace+"-state-disabled").attr("aria-disabled",value);}},enable:function(){this._setData("disabled",false);},disable:function(){this._setData("disabled",true);},_trigger:function(type,event,data){var callback=this.options[type],eventName=(type==this.widgetEventPrefix?type:this.widgetEventPrefix+type);event=$.Event(event);event.type=eventName;if(event.originalEvent){for(var i=$.event.props.length,prop;i;){prop=$.event.props[--i];event[prop]=event.originalEvent[prop];}}this.element.trigger(event,data);return !($.isFunction(callback)&&callback.call(this.element[0],event,data)===false||event.isDefaultPrevented());}};$.widget.defaults={disabled:false};$.ui.mouse={_mouseInit:function(){var self=this;this.element.bind("mousedown."+this.widgetName,function(event){return self._mouseDown(event);}).bind("click."+this.widgetName,function(event){if(self._preventClickEvent){self._preventClickEvent=false;event.stopImmediatePropagation();return false;}});if($.browser.msie){this._mouseUnselectable=this.element.attr("unselectable");this.element.attr("unselectable","on");}this.started=false;},_mouseDestroy:function(){this.element.unbind("."+this.widgetName);($.browser.msie&&this.element.attr("unselectable",this._mouseUnselectable));},_mouseDown:function(event){event.originalEvent=event.originalEvent||{};if(event.originalEvent.mouseHandled){return;}(this._mouseStarted&&this._mouseUp(event));this._mouseDownEvent=event;var self=this,btnIsLeft=(event.which==1),elIsCancel=(typeof this.options.cancel=="string"?$(event.target).parents().add(event.target).filter(this.options.cancel).length:false);if(!btnIsLeft||elIsCancel||!this._mouseCapture(event)){return true;}this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet){this._mouseDelayTimer=setTimeout(function(){self.mouseDelayMet=true;},this.options.delay);}if(this._mouseDistanceMet(event)&&this._mouseDelayMet(event)){this._mouseStarted=(this._mouseStart(event)!==false);if(!this._mouseStarted){event.preventDefault();return true;}}this._mouseMoveDelegate=function(event){return self._mouseMove(event);};this._mouseUpDelegate=function(event){return self._mouseUp(event);};$(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);($.browser.safari||event.preventDefault());event.originalEvent.mouseHandled=true;return true;},_mouseMove:function(event){if($.browser.msie&&!event.button){return this._mouseUp(event);}if(this._mouseStarted){this._mouseDrag(event);return event.preventDefault();}if(this._mouseDistanceMet(event)&&this._mouseDelayMet(event)){this._mouseStarted=(this._mouseStart(this._mouseDownEvent,event)!==false);(this._mouseStarted?this._mouseDrag(event):this._mouseUp(event));}return !this._mouseStarted;},_mouseUp:function(event){$(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;this._preventClickEvent=(event.target==this._mouseDownEvent.target);this._mouseStop(event);}return false;},_mouseDistanceMet:function(event){return(Math.max(Math.abs(this._mouseDownEvent.pageX-event.pageX),Math.abs(this._mouseDownEvent.pageY-event.pageY))>=this.options.distance);},_mouseDelayMet:function(event){return this.mouseDelayMet;},_mouseStart:function(event){},_mouseDrag:function(event){},_mouseStop:function(event){},_mouseCapture:function(event){return true;}};$.ui.mouse.defaults={cancel:null,distance:1,delay:0};})(jQuery);(function($){$.widget("ui.slider",$.extend({},$.ui.mouse,{_init:function(){var self=this,o=this.options;this._keySliding=false;this._handleIndex=null;this._detectOrientation();this._mouseInit();this.element.addClass("ui-slider"+" ui-slider-"+this.orientation+" ui-widget"+" ui-widget-content"+" ui-corner-all");this.range=$([]);if(o.range){if(o.range===true){this.range=$("<div></div>");if(!o.values){o.values=[this._valueMin(),this._valueMin()];}if(o.values.length&&o.values.length!=2){o.values=[o.values[0],o.values[0]];}}else{this.range=$("<div></div>");}this.range.appendTo(this.element).addClass("ui-slider-range");if(o.range=="min"||o.range=="max"){this.range.addClass("ui-slider-range-"+o.range);}this.range.addClass("ui-widget-header");}if($(".ui-slider-handle",this.element).length==0){$('<a href="#"></a>').appendTo(this.element).addClass("ui-slider-handle");}if(o.values&&o.values.length){while($(".ui-slider-handle",this.element).length<o.values.length){$('<a href="#"></a>').appendTo(this.element).addClass("ui-slider-handle");}}this.handles=$(".ui-slider-handle",this.element).addClass("ui-state-default"+" ui-corner-all");this.handle=this.handles.eq(0);this.handles.add(this.range).filter("a").click(function(event){event.preventDefault();}).hover(function(){$(this).addClass("ui-state-hover");},function(){$(this).removeClass("ui-state-hover");}).focus(function(){$(".ui-slider .ui-state-focus").removeClass("ui-state-focus");$(this).addClass("ui-state-focus");}).blur(function(){$(this).removeClass("ui-state-focus");});this.handles.each(function(i){$(this).data("index.ui-slider-handle",i);});this.handles.keydown(function(event){var ret=true;var index=$(this).data("index.ui-slider-handle");if(self.options.disabled){return;}switch(event.keyCode){case $.ui.keyCode.HOME:case $.ui.keyCode.END:case $.ui.keyCode.UP:case $.ui.keyCode.RIGHT:case $.ui.keyCode.DOWN:case $.ui.keyCode.LEFT:ret=false;if(!self._keySliding){self._keySliding=true;$(this).addClass("ui-state-active");self._start(event,index);}break;}var curVal,newVal,step=self._step();if(self.options.values&&self.options.values.length){curVal=newVal=self.values(index);}else{curVal=newVal=self.value();}switch(event.keyCode){case $.ui.keyCode.HOME:newVal=self._valueMin();break;case $.ui.keyCode.END:newVal=self._valueMax();break;case $.ui.keyCode.UP:case $.ui.keyCode.RIGHT:if(curVal==self._valueMax()){return;}newVal=curVal+step;break;case $.ui.keyCode.DOWN:case $.ui.keyCode.LEFT:if(curVal==self._valueMin()){return;}newVal=curVal-step;break;}self._slide(event,index,newVal);return ret;}).keyup(function(event){var index=$(this).data("index.ui-slider-handle");if(self._keySliding){self._stop(event,index);self._change(event,index);self._keySliding=false;$(this).removeClass("ui-state-active");}});this._refreshValue();},destroy:function(){this.handles.remove();this.range.remove();this.element.removeClass("ui-slider"+" ui-slider-horizontal"+" ui-slider-vertical"+" ui-slider-disabled"+" ui-widget"+" ui-widget-content"+" ui-corner-all").removeData("slider").unbind(".slider");this._mouseDestroy();},_mouseCapture:function(event){var o=this.options;if(o.disabled){return false;}this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()};this.elementOffset=this.element.offset();var position={x:event.pageX,y:event.pageY};var normValue=this._normValueFromMouse(position);var distance=this._valueMax()-this._valueMin()+1,closestHandle;var self=this,index;this.handles.each(function(i){var thisDistance=Math.abs(normValue-self.values(i));if(distance>thisDistance){distance=thisDistance;closestHandle=$(this);index=i;}});if(o.range==true&&this.values(1)==o.min){closestHandle=$(this.handles[++index]);}this._start(event,index);self._handleIndex=index;closestHandle.addClass("ui-state-active").focus();var offset=closestHandle.offset();var mouseOverHandle=!$(event.target).parents().andSelf().is(".ui-slider-handle");this._clickOffset=mouseOverHandle?{left:0,top:0}:{left:event.pageX-offset.left-(closestHandle.width()/2),top:event.pageY-offset.top-(closestHandle.height()/2)-(parseInt(closestHandle.css("borderTopWidth"),10)||0)-(parseInt(closestHandle.css("borderBottomWidth"),10)||0)+(parseInt(closestHandle.css("marginTop"),10)||0)};normValue=this._normValueFromMouse(position);this._slide(event,index,normValue);return true;},_mouseStart:function(event){return true;},_mouseDrag:function(event){var position={x:event.pageX,y:event.pageY};var normValue=this._normValueFromMouse(position);this._slide(event,this._handleIndex,normValue);return false;},_mouseStop:function(event){this.handles.removeClass("ui-state-active");this._stop(event,this._handleIndex);this._change(event,this._handleIndex);this._handleIndex=null;this._clickOffset=null;return false;},_detectOrientation:function(){this.orientation=this.options.orientation=="vertical"?"vertical":"horizontal";},_normValueFromMouse:function(position){var pixelTotal,pixelMouse;if("horizontal"==this.orientation){pixelTotal=this.elementSize.width;pixelMouse=position.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0);}else{pixelTotal=this.elementSize.height;pixelMouse=position.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0);}var percentMouse=(pixelMouse/pixelTotal);if(percentMouse>1){percentMouse=1;}if(percentMouse<0){percentMouse=0;}if("vertical"==this.orientation){percentMouse=1-percentMouse;}var valueTotal=this._valueMax()-this._valueMin(),valueMouse=percentMouse*valueTotal,valueMouseModStep=valueMouse%this.options.step,normValue=this._valueMin()+valueMouse-valueMouseModStep;if(valueMouseModStep>(this.options.step/2)){normValue+=this.options.step;}return parseFloat(normValue.toFixed(5));},_start:function(event,index){var uiHash={handle:this.handles[index],value:this.value()};if(this.options.values&&this.options.values.length){uiHash.value=this.values(index);uiHash.values=this.values();}this._trigger("start",event,uiHash);},_slide:function(event,index,newVal){var handle=this.handles[index];if(this.options.values&&this.options.values.length){var otherVal=this.values(index?0:1);if((index==0&&newVal>=otherVal)||(index==1&&newVal<=otherVal)){newVal=otherVal;}if(newVal!=this.values(index)){var newValues=this.values();newValues[index]=newVal;var allowed=this._trigger("slide",event,{handle:this.handles[index],value:newVal,values:newValues});var otherVal=this.values(index?0:1);if(allowed!==false){this.values(index,newVal,(event.type=="mousedown"&&this.options.animate),true);}}}else{if(newVal!=this.value()){var allowed=this._trigger("slide",event,{handle:this.handles[index],value:newVal});if(allowed!==false){this._setData("value",newVal,(event.type=="mousedown"&&this.options.animate));}}}},_stop:function(event,index){var uiHash={handle:this.handles[index],value:this.value()};if(this.options.values&&this.options.values.length){uiHash.value=this.values(index);uiHash.values=this.values();}this._trigger("stop",event,uiHash);},_change:function(event,index){var uiHash={handle:this.handles[index],value:this.value()};if(this.options.values&&this.options.values.length){uiHash.value=this.values(index);uiHash.values=this.values();}this._trigger("change",event,uiHash);},value:function(newValue){if(arguments.length){this._setData("value",newValue);this._change(null,0);}return this._value();},values:function(index,newValue,animated,noPropagation){if(arguments.length>1){this.options.values[index]=newValue;this._refreshValue(animated);if(!noPropagation){this._change(null,index);}}if(arguments.length){if(this.options.values&&this.options.values.length){return this._values(index);}else{return this.value();}}else{return this._values();}},_setData:function(key,value,animated){$.widget.prototype._setData.apply(this,arguments);switch(key){case"orientation":this._detectOrientation();this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-"+this.orientation);this._refreshValue(animated);break;case"value":this._refreshValue(animated);break;}},_step:function(){var step=this.options.step;return step;},_value:function(){var val=this.options.value;if(val<this._valueMin()){val=this._valueMin();}if(val>this._valueMax()){val=this._valueMax();}return val;},_values:function(index){if(arguments.length){var val=this.options.values[index];if(val<this._valueMin()){val=this._valueMin();}if(val>this._valueMax()){val=this._valueMax();}return val;}else{return this.options.values;}},_valueMin:function(){var valueMin=this.options.min;return valueMin;},_valueMax:function(){var valueMax=this.options.max;return valueMax;},_refreshValue:function(animate){var oRange=this.options.range,o=this.options,self=this;if(this.options.values&&this.options.values.length){var vp0,vp1;this.handles.each(function(i,j){var valPercent=(self.values(i)-self._valueMin())/(self._valueMax()-self._valueMin())*100;var _set={};_set[self.orientation=="horizontal"?"left":"bottom"]=valPercent+"%";$(this).stop(1,1)[animate?"animate":"css"](_set,o.animate);if(self.options.range===true){if(self.orientation=="horizontal"){(i==0)&&self.range.stop(1,1)[animate?"animate":"css"]({left:valPercent+"%"},o.animate);(i==1)&&self.range[animate?"animate":"css"]({width:(valPercent-lastValPercent)+"%"},{queue:false,duration:o.animate});}else{(i==0)&&self.range.stop(1,1)[animate?"animate":"css"]({bottom:(valPercent)+"%"},o.animate);(i==1)&&self.range[animate?"animate":"css"]({height:(valPercent-lastValPercent)+"%"},{queue:false,duration:o.animate});}}lastValPercent=valPercent;});}else{var value=this.value(),valueMin=this._valueMin(),valueMax=this._valueMax(),valPercent=valueMax!=valueMin?(value-valueMin)/(valueMax-valueMin)*100:0;var _set={};_set[self.orientation=="horizontal"?"left":"bottom"]=valPercent+"%";this.handle.stop(1,1)[animate?"animate":"css"](_set,o.animate);(oRange=="min")&&(this.orientation=="horizontal")&&this.range.stop(1,1)[animate?"animate":"css"]({width:valPercent+"%"},o.animate);(oRange=="max")&&(this.orientation=="horizontal")&&this.range[animate?"animate":"css"]({width:(100-valPercent)+"%"},{queue:false,duration:o.animate});(oRange=="min")&&(this.orientation=="vertical")&&this.range.stop(1,1)[animate?"animate":"css"]({height:valPercent+"%"},o.animate);(oRange=="max")&&(this.orientation=="vertical")&&this.range[animate?"animate":"css"]({height:(100-valPercent)+"%"},{queue:false,duration:o.animate});}}}));$.extend($.ui.slider,{getter:"value values",version:"1.7.1",eventPrefix:"slide",defaults:{animate:false,delay:0,distance:0,max:100,min:0,orientation:"horizontal",range:false,step:1,value:0,values:null}});})(jQuery);(function($){$.fn.extend({animateToClass:function(to,duration,easing,callback){if(!to){return this;}styles=selectStyle(to);if(!styles){return this;}return this.animate(styles,duration,easing,callback);}});function selectStyle(sel){if(sel.substr(0,1)!="."){sel="."+sel;}for(var cont=0;cont<document.styleSheets.length;cont++){v=document.styleSheets[cont];attrClass=selectAttr(sel,v);if(attrClass!=false){break;}}if(!attrClass){attrClass=Array();}objStyle={};if(attrClass==""){return false;}if(attrClass.match(";")){attrClass=attrClass.split(";");}else{attrClass=[attrClass];}$(attrClass).each(function(i,v){if(v!=""){v=v.split(":");v[0]=toCamelCase(v[0]);objStyle[v[0]]=$.trim(v[1]);}});return objStyle;}function selectAttr(sel,v){attrClass=false;if($.browser.msie){if(v.rules.length>0){$(v.rules).each(function(i2,v2){if(sel==v2.selectorText){attrClass=v2.style.cssText;}});}else{if(v.imports.length>0){$(v.imports).each(function(i2,v2){if(sel==v2.selectorText){attrClass=v2.style.cssText;}else{if(v2=="[object]"||v2=="[Object CSSStyleSheet]"||v2=="[object CSSImportRule]"){return selectAttr(sel,v2);}}});}}}else{$(v.cssRules).each(function(i2,v2){if(sel==v2.selectorText){attrClass=v2.style.cssText;}else{if(v2=="[object CSSImportRule]"){return selectAttr(sel,v2.styleSheet);}}});}return attrClass;}function toCamelCase(str){str=$.trim(str);str=str.replace(/-/g," ");str=str.toLowerCase();strArr=str.split(" ");var nStr="";$(strArr).each(function(i,v){if(i==0){nStr+=v;}else{nStr+=v.substr(0,1).toUpperCase();nStr+=v.substr(1,v.length);}});return nStr;}})(jQuery);eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36));};if(!"".replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c);}k=[function(e){return d[e];}];e=function(){return"\\w+";};c=1;}while(c--){if(k[c]){p=p.replace(new RegExp("\\b"+e(c)+"\\b","g"),k[c]);}}return p;}('(5($){$.J.L=5(r){8 1={d:0,A:0,b:"h",v:"N",3:4};6(r){$.D(1,r)}8 m=9;6("h"==1.b){$(1.3).p("h",5(b){8 C=0;m.t(5(){6(!$.k(9,1)&&!$.l(9,1)){$(9).z("o")}j{6(C++>1.A){g B}}});8 w=$.M(m,5(f){g!f.e});m=$(w)})}g 9.t(5(){8 2=9;$(2).c("s",$(2).c("i"));6("h"!=1.b||$.k(2,1)||$.l(2,1)){6(1.u){$(2).c("i",1.u)}j{$(2).K("i")}2.e=B}j{2.e=x}$(2).T("o",5(){6(!9.e){$("<V />").p("X",5(){$(2).Y().c("i",$(2).c("s"))[1.v](1.Z);2.e=x}).c("i",$(2).c("s"))}});6("h"!=1.b){$(2).p(1.b,5(b){6(!2.e){$(2).z("o")}})}})};$.k=5(f,1){6(1.3===E||1.3===4){8 7=$(4).F()+$(4).O()}j{8 7=$(1.3).n().G+$(1.3).F()}g 7<=$(f).n().G-1.d};$.l=5(f,1){6(1.3===E||1.3===4){8 7=$(4).I()+$(4).U()}j{8 7=$(1.3).n().q+$(1.3).I()}g 7<=$(f).n().q-1.d};$.D($.P[\':\'],{"Q-H-7":"$.k(a, {d : 0, 3: 4})","R-H-7":"!$.k(a, {d : 0, 3: 4})","S-y-7":"$.l(a, {d : 0, 3: 4})","q-y-7":"!$.l(a, {d : 0, 3: 4})"})})(W);',62,62,"|settings|self|container|window|function|if|fold|var|this||event|attr|threshold|loaded|element|return|scroll|src|else|belowthefold|rightoffold|elements|offset|appear|bind|left|options|original|each|placeholder|effect|temp|true|of|trigger|failurelimit|false|counter|extend|undefined|height|top|the|width|fn|removeAttr|lazyload|grep|show|scrollTop|expr|below|above|right|one|scrollLeft|img|jQuery|load|hide|effectspeed".split("|"),0,{}));HZIcon=function(){};HZIcon.DEFAULT_SEARCH_ICON=function(){return G_DEFAULT_ICON;};HZIcon._HOUSE_ICON=null;HZIcon.HOUSE_ICON=function(){if(HZIcon._HOUSE_ICON){return HZIcon._HOUSE_ICON;}HZIcon._HOUSE_ICON=new GIcon();HZIcon._HOUSE_ICON.image="/images/icons/addressIcon.png";HZIcon._HOUSE_ICON.iconSize=new GSize(22,35);HZIcon._HOUSE_ICON.shadowSize=new GSize(22,20);HZIcon._HOUSE_ICON.iconAnchor=new GPoint(6,20);HZIcon._HOUSE_ICON.infoWindowAnchor=new GPoint(5,1);return HZIcon._HOUSE_ICON;};HZIcon._FLICKR=null;HZIcon.FLICKR=function(){if(HZIcon._FLICKR){return HZIcon._FLICKR;}HZIcon._FLICKR=new GIcon();HZIcon._FLICKR.image="/images/digital_camera_icon.png";HZIcon._FLICKR.iconSize=new GSize(35,28);HZIcon._FLICKR.iconAnchor=new GPoint(17,28);HZIcon._FLICKR.infoWindowAnchor=new GPoint(16,1);return HZIcon._FLICKR;};HZIcon._ELEMENTARY_SCHOOL=null;HZIcon.ELEMENTARY_SCHOOL=function(){if(HZIcon._ELEMENTARY_SCHOOL){return HZIcon._ELEMENTARY_SCHOOL;}HZIcon._ELEMENTARY_SCHOOL=new GIcon();HZIcon._ELEMENTARY_SCHOOL.image="/images/icons/icon_elementary.png";HZIcon._ELEMENTARY_SCHOOL.iconSize=new GSize(22,35);HZIcon._ELEMENTARY_SCHOOL.iconAnchor=new GPoint(11,35);HZIcon._ELEMENTARY_SCHOOL.infoWindowAnchor=new GPoint(10,1);return HZIcon._ELEMENTARY_SCHOOL;};HZIcon._HIGH_SCHOOL=null;HZIcon.HIGH_SCHOOL=function(){if(HZIcon._HIGH_SCHOOL){return HZIcon._HIGH_SCHOOL;}HZIcon._HIGH_SCHOOL=new GIcon();HZIcon._HIGH_SCHOOL.image="/images/icons/icon_highschool.png";HZIcon._HIGH_SCHOOL.iconSize=new GSize(22,35);HZIcon._HIGH_SCHOOL.iconAnchor=new GPoint(11,35);HZIcon._HIGH_SCHOOL.infoWindowAnchor=new GPoint(10,1);return HZIcon._HIGH_SCHOOL;};HZIcon._SCHOOL=null;HZIcon.SCHOOL=function(){if(HZIcon._SCHOOL){return HZIcon._SCHOOL;}HZIcon._SCHOOL=new GIcon();HZIcon._SCHOOL.image="/images/icons/icon_school.png";HZIcon._SCHOOL.iconSize=new GSize(22,35);HZIcon._SCHOOL.iconAnchor=new GPoint(11,35);HZIcon._SCHOOL.infoWindowAnchor=new GPoint(10,1);return HZIcon._SCHOOL;};HZIcon._HOSPITAL=null;HZIcon.HOSPITAL=function(){if(HZIcon._HOSPITAL){return HZIcon._HOSPITAL;}HZIcon._HOSPITAL=new GIcon();HZIcon._HOSPITAL.image="/images/icons/icon_hospital.png";HZIcon._HOSPITAL.iconSize=new GSize(22,35);HZIcon._HOSPITAL.iconAnchor=new GPoint(12,40);HZIcon._HOSPITAL.infoWindowAnchor=new GPoint(10,1);return HZIcon._HOSPITAL;};HZIcon._RESTAURANT=null;HZIcon.RESTAURANT=function(){if(HZIcon._RESTAURANT){return HZIcon._RESTAURANT;}HZIcon._RESTAURANT=new GIcon();HZIcon._RESTAURANT.image="/images/icons/icon_restaurant.png";HZIcon._RESTAURANT.iconSize=new GSize(22,35);HZIcon._RESTAURANT.iconAnchor=new GPoint(12,40);HZIcon._RESTAURANT.infoWindowAnchor=new GPoint(10,1);return HZIcon._RESTAURANT;};HZIcon._PUB=null;HZIcon.PUB=function(){if(HZIcon._PUB){return HZIcon._PUB;}HZIcon._PUB=new GIcon();HZIcon._PUB.image="/images/icons/icon_bar.png";HZIcon._PUB.iconSize=new GSize(22,35);HZIcon._PUB.iconAnchor=new GPoint(12,40);HZIcon._PUB.infoWindowAnchor=new GPoint(10,1);return HZIcon._PUB;};HZIcon._COFFEE=null;HZIcon.COFFEE=function(){if(HZIcon._COFFEE){return HZIcon._COFFEE;}HZIcon._COFFEE=new GIcon();HZIcon._COFFEE.image="/images/icons/icon_coffee.png";HZIcon._COFFEE.iconSize=new GSize(22,35);HZIcon._COFFEE.iconAnchor=new GPoint(12,40);HZIcon._COFFEE.infoWindowAnchor=new GPoint(10,1);return HZIcon._COFFEE;};HZIcon._GRAVEYARD=null;HZIcon.GRAVEYARD=function(){if(HZIcon._GRAVEYARD){return HZIcon._GRAVEYARD;}HZIcon._GRAVEYARD=new GIcon();HZIcon._GRAVEYARD.image="/images/icons/icon_graveyard.png";HZIcon._GRAVEYARD.iconSize=new GSize(22,35);HZIcon._GRAVEYARD.iconAnchor=new GPoint(12,40);HZIcon._GRAVEYARD.infoWindowAnchor=new GPoint(10,1);return HZIcon._GRAVEYARD;};HZIcon._TIMMIES=null;HZIcon.TIMMIES=function(){if(HZIcon._TIMMIES){return HZIcon._TIMMIES;}HZIcon._TIMMIES=new GIcon();HZIcon._TIMMIES.image="/images/icons/icon_tims.png";HZIcon._TIMMIES.iconSize=new GSize(22,35);HZIcon._TIMMIES.iconAnchor=new GPoint(12,40);HZIcon._TIMMIES.infoWindowAnchor=new GPoint(10,1);return HZIcon._TIMMIES;};HZIcon._STARBUCKS=null;HZIcon.STARBUCKS=function(){if(HZIcon._STARBUCKS){return HZIcon._STARBUCKS;}HZIcon._STARBUCKS=new GIcon();HZIcon._STARBUCKS.image="/images/icons/icon_starbucks.png";HZIcon._STARBUCKS.iconSize=new GSize(22,35);HZIcon._STARBUCKS.iconAnchor=new GPoint(12,40);HZIcon._STARBUCKS.infoWindowAnchor=new GPoint(10,1);return HZIcon._STARBUCKS;};HZIcon._CREDITUNION=null;HZIcon.CREDITUNION=function(){if(HZIcon._CREDITUNION){return HZIcon._CREDITUNION;}HZIcon._CREDITUNION=new GIcon();HZIcon._CREDITUNION.image="/images/cu.gif";HZIcon._CREDITUNION.iconSize=new GSize(26,26);HZIcon._CREDITUNION.iconAnchor=new GPoint(13,26);HZIcon._CREDITUNION.infoWindowAnchor=new GPoint(13,1);if(HZIcon._CREDITUNION){return HZIcon._CREDITUNION;}};HZIcon._PARK=null;HZIcon.PARK=function(){if(HZIcon._PARK){return HZIcon._PARK;}HZIcon._PARK=new GIcon();HZIcon._PARK.image="/images/icons/icon_park.png";HZIcon._PARK.iconSize=new GSize(22,35);HZIcon._PARK.iconAnchor=new GPoint(13,26);HZIcon._PARK.infoWindowAnchor=new GPoint(13,1);return HZIcon._PARK;};HZIcon._TTC=null;HZIcon.TTC=function(){if(HZIcon._TTC){return HZIcon._TTC;}HZIcon._TTC=new GIcon();HZIcon._TTC.image="/images/icons/icons_ttc.png";HZIcon._TTC.iconSize=new GSize(22,35);HZIcon._TTC.iconAnchor=new GPoint(13,26);HZIcon._TTC.infoWindowAnchor=new GPoint(13,1);return HZIcon._TTC;};HZIcon._CHILD_CARE=null;HZIcon.CHILD_CARE=function(){if(HZIcon._CHILD_CARE){return HZIcon._CHILD_CARE;}HZIcon._CHILD_CARE=new GIcon();HZIcon._CHILD_CARE.image="/images/icons/childcare.png";HZIcon._CHILD_CARE.iconSize=new GSize(35,35);HZIcon._CHILD_CARE.iconAnchor=new GPoint(13,26);HZIcon._CHILD_CARE.infoWindowAnchor=new GPoint(13,1);return HZIcon._CHILD_CARE;};HZIcon._GROCERY_STORE=null;HZIcon.GROCERY_STORE=function(){if(HZIcon._GROCERY_STORE){return HZIcon._GROCERY_STORE;}HZIcon._GROCERY_STORE=new GIcon();HZIcon._GROCERY_STORE.image="/images/icons/grocery.png";HZIcon._GROCERY_STORE.iconSize=new GSize(35,35);HZIcon._GROCERY_STORE.iconAnchor=new GPoint(13,26);HZIcon._GROCERY_STORE.infoWindowAnchor=new GPoint(13,1);return HZIcon._GROCERY_STORE;};HZIcon._GO_TRAIN=null;HZIcon.GO_TRAIN=function(){if(HZIcon._GO_TRAIN){return HZIcon._GO_TRAIN;}HZIcon._GO_TRAIN=new GIcon();HZIcon._GO_TRAIN.image="/images/icons/go.png";HZIcon._GO_TRAIN.iconSize=new GSize(35,35);HZIcon._GO_TRAIN.iconAnchor=new GPoint(13,26);HZIcon._GO_TRAIN.infoWindowAnchor=new GPoint(13,1);return HZIcon._GO_TRAIN;};HZIcon._LCBO=null;HZIcon.LCBO=function(){if(HZIcon._LCBO){return HZIcon._LCBO;}HZIcon._LCBO=new GIcon();HZIcon._LCBO.image="/images/icons/lcbo.png";HZIcon._LCBO.iconSize=new GSize(23,35);HZIcon._LCBO.iconAnchor=new GPoint(10,33);HZIcon._LCBO.infoWindowAnchor=new GPoint(7,1);return HZIcon._LCBO;};HZIcon._LISTING=null;HZIcon.LISTING=function(){if(HZIcon._LISTING){return HZIcon._LISTING;}HZIcon._LISTING=new GIcon();HZIcon._LISTING.image="/images/icons/icon_listing.png";HZIcon._LISTING.iconSize=new GSize(23,35);HZIcon._LISTING.iconAnchor=new GPoint(10,33);HZIcon._LISTING.infoWindowAnchor=new GPoint(7,1);return HZIcon._LISTING;};HZIcon._LISTING2=null;HZIcon.LISTING2=function(){if(HZIcon._LISTING2){return HZIcon._LISTING2;}HZIcon._LISTING2=new GIcon();HZIcon._LISTING2.image="/images/icons/icon_listing_highlight.png";HZIcon._LISTING2.iconSize=new GSize(28,43);HZIcon._LISTING2.iconAnchor=new GPoint(12,39);HZIcon._LISTING2.infoWindowAnchor=new GPoint(7,1);return HZIcon._LISTING2;};HZIcon._BANK=null;HZIcon.BANK=function(){if(HZIcon._BANK){return HZIcon._BANK;}HZIcon._BANK=new GIcon();HZIcon._BANK.image="/images/icons/icon_bank.png";HZIcon._BANK.iconSize=new GSize(23,35);HZIcon._BANK.iconAnchor=new GPoint(10,33);HZIcon._BANK.infoWindowAnchor=new GPoint(7,1);return HZIcon._BANK;};HZIcon._AGENT=null;HZIcon.AGENT=function(){if(HZIcon._AGENT){return HZIcon._AGENT;}HZIcon._AGENT=new GIcon();HZIcon._AGENT.image="/images/icons/real_estate_agent.png";HZIcon._AGENT.iconSize=new GSize(23,35);HZIcon._AGENT.iconAnchor=new GPoint(10,33);HZIcon._AGENT.infoWindowAnchor=new GPoint(7,1);return HZIcon._AGENT;};HZIcon._ZIPCAR=null;HZIcon.ZIPCAR=function(){if(HZIcon._ZIPCAR){return HZIcon._ZIPCAR;}HZIcon._ZIPCAR=new GIcon();HZIcon._ZIPCAR.image="/images/icons/icon_zipcars.png";HZIcon._ZIPCAR.iconSize=new GSize(20,34);HZIcon._ZIPCAR.iconAnchor=new GPoint(10,33);HZIcon._ZIPCAR.infoWindowAnchor=new GPoint(7,1);return HZIcon._ZIPCAR;};HZIcon._TWITTER_BLUE=null;HZIcon.TWITTER_BLUE=function(){if(HZIcon._TWITTER_BLUE){return HZIcon._TWITTER_BLUE;}HZIcon._TWITTER_BLUE=new GIcon();HZIcon._TWITTER_BLUE.image="/images/tweets/blue.png";HZIcon._TWITTER_BLUE.iconSize=new GSize(23,36);HZIcon._TWITTER_BLUE.iconAnchor=new GPoint(10,33);HZIcon._TWITTER_BLUE.infoWindowAnchor=new GPoint(7,1);return HZIcon._TWITTER_BLUE;};HZIcon._TWITTER_WHITE=null;HZIcon.TWITTER_WHITE=function(){if(HZIcon._TWITTER_WHITE){return HZIcon._TWITTER_WHITE;}HZIcon._TWITTER_WHITE=new GIcon();HZIcon._TWITTER_WHITE.image="/images/tweets/white.png";HZIcon._TWITTER_WHITE.iconSize=new GSize(23,36);HZIcon._TWITTER_WHITE.iconAnchor=new GPoint(10,33);HZIcon._TWITTER_WHITE.infoWindowAnchor=new GPoint(7,1);return HZIcon._TWITTER_WHITE;};HZIcon._BEER_STORE=null;HZIcon.BEER_STORE=function(){if(HZIcon._BEER_STORE){return HZIcon._BEER_STORE;}HZIcon._BEER_STORE=new GIcon();HZIcon._BEER_STORE.image="/images/icons/beerstore.png";HZIcon._BEER_STORE.iconSize=new GSize(35,35);HZIcon._BEER_STORE.iconAnchor=new GPoint(13,26);HZIcon._BEER_STORE.infoWindowAnchor=new GPoint(13,1);return HZIcon._BEER_STORE;};HZIcon.icons=[HZIcon.DEFAULT_SEARCH_ICON,HZIcon.HOSPITAL,HZIcon.RESTAURANT,HZIcon.PUB,HZIcon.ELEMENTARY_SCHOOL,HZIcon.HIGH_SCHOOL,HZIcon.COFFEE,HZIcon.GRAVEYARD,HZIcon.CREDITUNION,HZIcon.TIMMIES,HZIcon.STARBUCKS,HZIcon.SCHOOL,HZIcon.PARK,HZIcon.TTC,HZIcon.CHILD_CARE,HZIcon.GROCERY_STORE,HZIcon.GO_TRAIN,HZIcon.LCBO,HZIcon.LISTING,HZIcon.LISTING2,HZIcon.BANK,HZIcon.AGENT,HZIcon.ZIPCAR,HZIcon.TWITTER_BLUE,HZIcon.TWITTER_WHITE,HZIcon.BEER_STORE];HZIcon.getIcon=function(index){if(index<0||index>=HZIcon.icons.length){index=0;}return HZIcon.icons[index]();};HZAjax=function(url,func){this.url_=url;this.func_=func;this.LOADED=false;this.params=null;this.requestType="GET";this.xmlhttp=null;this.async=true;this.aborted=false;};HZAjax.prototype.setParams=function(s){this.params=s;};HZAjax.prototype.setRequestType=function(type){this.requestType=type;};HZAjax.prototype.send=function(){this.xmlhttp=null;if(window.ActiveXObject){this.xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}else{if(window.XMLHttpRequest){this.xmlhttp=new XMLHttpRequest();}}if(this.xmlhttp!=null){if(this.func_!=null){this.xmlhttp.onreadystatechange=this.func_;}this.xmlhttp.open(this.requestType,this.url_,this.async);if(this.params){this.xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");this.xmlhttp.setRequestHeader("Content-length",this.params.length);this.xmlhttp.setRequestHeader("Connection","close");}this.xmlhttp.send(this.params);}else{alert("Your browser does not support XMLHTTP.");}};HZAjax.prototype.abort=function(){this.xmlhttp.abort();};HZAjax.prototype.checkReadyState=function(){if(this.aborted){return false;}try{if(this.xmlhttp.readyState==4){if(this.xmlhttp.status==200){return true;}else{alert("Problem retrieving XML data: status->"+this.xmlhttp);}}}catch(e){}};var loadingListings=false,stopLoadingListings=false,city,readingSliderCookies=false;var province,currentListings=null,mapLoaded=false,currentThreshold=null;var postLoadThreshold=null,testDiv,firstAjax=true,selectedListing=null;var swlat,swlng,nelat,nelng,centreLat,centreLng,zoom,origBounds,currentBounds;var cm,realCount=0,brokerages=null,brokeragesHash=null,initialLoad=true;var areaRegion,waterfrontOnly,listingsContainer,markerOverlay,cmarkerOverlay,isRobot;function initListings(){listingsContainer=$("#homelisting-content");listingsContainer.bind("scroll",scrollListings);$("#other-home-links").hide();loadListings();}function loadListings(){loadMap();}function requestListings(){listingsRequest();setupSliderEvents();}function loadMap(){if(typeof google.maps!="object"){$("#map").html("Unable to load Map");return;}var centre=new google.maps.LatLng(centreLat,centreLng);map=new google.maps.Map(document.getElementById("mapDiv"),{zoom:zoom,center:centre,mapTypeId:google.maps.MapTypeId.ROADMAP,disableDoubleClickZoom:true});if(swlat!=null){fromBounds();}google.maps.event.addListenerOnce(map,"idle",function(){origBounds=map.getBounds();requestListings();cm=new ClusterManager(map,"<a title='' href='javascript:setCentre(%latSection, %lngSection);'>Zoom in</a> to see %count home(s)");});google.maps.event.addListener(map,"zoom_changed",zoomEnd);google.maps.event.addListener(map,"dragend",dragEnd);markerOverlay=new ListingMarkerOverlay();markerOverlay.setMap(map);cmarkerOverlay=new ClusterMarkerOverlay();cmarkerOverlay.setMap(map);cookieCentred();mapLoaded=true;}function cookieCentred(){var s=readCookie("hzforsalecentre");if(s==null){return;}var parts=s.split(",");if(parts.length!=3){return;}var centreLat=parseFloat(parts[0]);var centreLng=parseFloat(parts[1]);var centreZoom=parseInt(parts[2]);map.setCenter(new google.maps.LatLng(centreLat,centreLng));map.setZoom(centreZoom);}function readSliderCookies(){readingSliderCookies=true;var changed=false;var s;s=readCookie("hzpricemin");if(s!=null){$("#filter-price").slider("values",0,s);$("#price-amount").val(s+" - "+$("#filter-price").slider("values",1));changed=true;}s=readCookie("hzpricemax");if(s!=null){$("#filter-price").slider("values",1,s);$("#price-amount").val($("#filter-price").slider("values",0)+" - "+s);changed=true;}s=readCookie("hzbedsmin");if(s!=null){$("#filter-beds").slider("values",0,parseInt(s));$("#beds-amount").val(s+" - "+$("#filter-beds").slider("values",1));changed=true;}s=readCookie("hzbedsmax");if(s!=null){$("#filter-beds").slider("values",1,parseInt(s));$("#beds-amount").val($("#filter-beds").slider("values",0)+" - "+s);changed=true;}s=readCookie("hzbathmin");if(s!=null){$("#filter-bath").slider("values",0,parseInt(s));$("#bath-amount").val(s+" - "+$("#filter-bath").slider("values",1));changed=true;}s=readCookie("hzbathmax");if(s!=null){$("#filter-bath").slider("values",1,parseInt(s));$("#bath-amount").val($("#filter-bath").slider("values",0)+" - "+s);changed=true;}readingSliderCookies=false;if(changed){thresholdChange();}}function setCookieCentred(){var centre=map.getCenter();var s=centre.lat()+","+centre.lng()+","+map.getZoom();var date=new Date();date.setTime(date.getTime()+300000);document.cookie="hzforsalecentre="+s+"; expires="+date.toGMTString()+"; path="+window.location.pathname;}function track(type,item1,item2){if(isRobot){return;}var paramList="type="+type+"&item1="+item1+"&item2="+item2+"&track=";trackAjax=new HZAjax("/phpHelpers/util/trackAjax.php?"+paramList,null);trackAjax.send();}function sliderCookie(field){var min=$("#filter-"+field).slider("values",0);var max=$("#filter-"+field).slider("values",1);var date=new Date();date.setTime(date.getTime()+300000);document.cookie="hz"+field+"min="+min+"; expires="+date.toGMTString()+"; path="+window.location.pathname;document.cookie="hz"+field+"max="+max+"; expires="+date.toGMTString()+"; path="+window.location.pathname;}function scrollListings(event){var done=false;$(this).find(".listingli").each(function(){if(done){return;}if(aboveTheTop(this)){return;}if(belowTheFold(this)){done=true;return;}$(this).find("img").each(function(){if($(this).attr("original")!="undefined"){$(this).attr("src",$(this).attr("original"));}});});}function fromBounds(){var bounds=new google.maps.LatLngBounds();var sw=new google.maps.LatLng(swlat,swlng);var ne=new google.maps.LatLng(nelat,nelng);var nw=new google.maps.LatLng(nelat,swlng);var se=new google.maps.LatLng(swlat,nelng);bounds.extend(sw);bounds.extend(ne);bounds.extend(nw);bounds.extend(se);var centre=bounds.getCenter();centreLat=centre.lat();centreLng=centre.lng();}function zoomEnd(){var newLevel=map.getZoom();Listing.closeInfoWindow();ClusterPoint.closeInfoWindow();if(newLevel<zoom||(realCount>=500)){if(brokerageId==0&&agentId==0){cm.hide();cm.empty();loadNewListings();}}else{updateDisplayListings();}zoom=newLevel;setCookieCentred();}function dragEnd(){if(Listing.currentInfoWindowListing!=null){if(!Listing.currentInfoWindowListing.inMapBounds()){Listing.closeInfoWindow();}else{Listing.currentInfoWindowListing.adjustInfoWindow();}}cm.hide();cm.empty();zoom=map.getZoom();loadNewListings();setCookieCentred();}function readCookie(name){var nameEQ=name+"=";var ca=document.cookie.split(";");for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==" "){c=c.substring(1,c.length);}if(c.indexOf(nameEQ)==0){return c.substring(nameEQ.length,c.length);}}return null;}function loadNewListings(){if(brokerageId==0&&agentId==0){unloadListings();listingsRequest();}}function unloadListings(){removeLiMouseListeners();for(var i=0;i<currentListings.length;i++){currentListings[i].hide();currentListings[i].jsonObject=null;}currentListings=null;}function homesTypeChange(type){if($("#li-"+type).hasClass("checked")){if(type=="residential"){currentThreshold.removeType("house");}else{currentThreshold.removeType(type);}$("#li-"+type).removeClass("checked");}else{if(type=="residential"){currentThreshold.addtype("house");}else{currentThreshold.addtype(type);}$("#li-"+type).addClass("checked");}cm.hide();cm.empty();loadNewListings();}function typeListString(){var first=true;var s="";if($("#li-residential").hasClass("checked")){first=false;s+="house";}if($("#li-vacant").hasClass("checked")){if(first){first=false;}else{s+=",";}s+="vacant";}if($("#li-commercial").hasClass("checked")){if(first){first=false;}else{s+=",";}s+="commercial";}return s;}function listingsRequest(){var params=getParams(params);postLoadThreshold=currentThreshold;$("#li-waterfront").parent().hide();listingsAjax=new HZAjax("/phpHelpers/rets/listingsAjax.php?"+params,listingsResponse);listingsAjax.send();}function getParams(useThreshold){var params;if(brokerageId>0){params="brokerId="+brokerageId;}else{if(agentId>0){params="agentId="+agentId;}else{var bounds=map.getBounds();var mapSW=bounds.getSouthWest();var mapNE=bounds.getNorthEast();var types;if(currentThreshold!=null){types=typeListString();}else{types="house";}params="cty="+city+"&prv="+province+"&types="+types+"&allphotos="+"&swlat="+mapSW.lat()+"&nelat="+mapNE.lat()+"&swlng="+mapSW.lng()+"&nelng="+mapNE.lng();params+="&ignorecw=";if(waterfrontOnly){params+="&waterfront=yes";}if(initialLoad){initialLoad=false;params+="&usecache=";}if(areaRegion!=""){params+="&region="+areaRegion;}}}if(useThreshold){params+=currentThreshold.asParams();}return params;}function getRealCount(){var params=getParams(true);countAjax=new HZAjax("/phpHelpers/rets/listingsCountAjax.php?"+params,countResponse);countAjax.send();}function countResponse(){if(countAjax.xmlhttp.readyState==4){realCount=parseInt(countAjax.xmlhttp.responseText);showRealCount();}}function showRealCount(){if(realCount<0){realCount=0;}$("#propertyCount").html(realCount);if(realCount>=500){$("#realcountdiv").show();}else{$("#realcountdiv").hide();}}function listingsResponse(){if(listingsAjax.checkReadyState()){var jsonResults=eval("("+listingsAjax.xmlhttp.responseText+")");realCount=parseInt(jsonResults.total);showRealCount();var innerHTMLArray=new Array();jsonResults=jsonResults.listings;if(loadingListings==true){stopLoadingListings=true;unloadListings();stopLoadingListings=false;}loadingListings=true;currentThreshold=new Threshold();currentListings=new Array();if(brokerages==null){brokerages=new Array();brokeragesHash=new Array();}var numListings=jsonResults.length;var ulList=$("#listlist");var showWaterfront=false;ulList.html("");for(var i=0;i<numListings;i++){var jsonResult=jsonResults[i];jsonResult.brokerage=jsonResult.brokerage.replace(/ *- *[A-F1-9][0-9]*.*$/,"");var listing=new Listing(jsonResult);var office=jsonResult.brokerage;listing.jsonObject.index=i;if(!showWaterfront){if(listing.jsonObject.waterfrontyn=="Y"){$("#li-waterfront").parent().show();$("#other-home-links").show();showWaterfront=true;}}if(stopLoadingListings){return;}if(i<10){ulList.append(listing.liHTML("src"));}else{innerHTMLArray.push(listing.liHTML("original"));}currentListings.push(listing);currentThreshold.setMinBeds(listing.beds());currentThreshold.setMaxBeds(listing.beds());currentThreshold.setMinBaths(listing.baths());currentThreshold.setMaxBaths(listing.baths());currentThreshold.setMinPrice(listing.price());currentThreshold.setMaxPrice(listing.price());currentThreshold.setMinDays(listing.days());currentThreshold.setMaxDays(listing.days());}if(jsonResults.length==0){currentThreshold.zeroValues();}if(numListings>10){var tmp=innerHTMLArray.join("");ulList.append(tmp);}liMouseListeners();listingsAjax=null;if(stopLoadingListings){return;}postLoadThresholdChanges();if(firstAjax){currentThreshold.initHTMLfromThreshold();firstAjax=false;}else{currentThreshold.setHTMLfromThreshold();}if(stopLoadingListings){return;}loadingListings=false;cm.show();displayListings(false,true);readSliderCookies();}}function belowTheFold(element){var fold=listingsContainer.offset().top+listingsContainer.height();return fold<=$(element).offset().top;}function aboveTheTop(element){var fold=listingsContainer.offset().top;return tmp=fold>=$(element).offset().top+$(element).height();}function debugTime(s){var currentTime=new Date();var minutes=currentTime.getMinutes();var seconds=currentTime.getSeconds();var milli=currentTime.getMilliseconds();}function addBroker(office){var index=brokerages.length;var liHTML='<li><div id="li-office-'+index+'" class="checkbox"></div>'+office+"</li>";brokerages.push(office);$("#office-list").append(liHTML);$("#li-office-"+index).click(officeClicked).addClass("checked");}function officeClicked(){var index=this.id.replace(/^li-office-/,"");var office=brokerages[index];if($(this).hasClass("checked")){$(this).removeClass("checked");hideBroker(office);}else{$(this).addClass("checked");showBroker(office);}cm.hide();cm.show();}function applyOfficeChecks(){var numOffices=brokerages.length;var changed=false;for(var i=0;i<numOffices;i++){if(!$("#li-office-"+i).hasClass("checked")){var office=brokerages[i];hideBroker(office);changed=true;}}if(changed){cm.hide();cm.show();}}function hideBroker(office){for(var i=0;i<currentListings.length;i++){var listing=currentListings[i];if(listing.brokerage()==office){if(listing.showing){listing.hide();}}}}function showBroker(office){for(var i=0;i<currentListings.length;i++){if(currentListings[i].brokerage()==office){if(!listing.showing){listing.show();}}}}function setupSliderEvents(){$("#filter-price").bind("slidechange",function(event,ui){if(readingSliderCookies){return;}thresholdChange();sliderCookie("price");});$("#filter-beds").bind("slidechange",function(event,ui){if(readingSliderCookies){return;}thresholdChange();sliderCookie("beds");});$("#filter-bath").bind("slidechange",function(event,ui){if(readingSliderCookies){return;}thresholdChange();sliderCookie("bath");});$("#li-residential").addClass("checked");$("#li-residential").click(function(){homesTypeChange("residential");});$("#li-vacant").click(function(){homesTypeChange("vacant");});$("#li-commercial").click(function(){homesTypeChange("commercial");});$("#li-waterfront").click(function(){if($(this).hasClass("checked")){$(this).removeClass("checked");if(waterfrontOnly){waterfrontOnly=false;unloadListings();listingsRequest();}}else{waterfrontProperties(true);waterfrontOnly=true;listingsContainer.trigger("scroll");$(this).addClass("checked");cm.recluster();showRealCount();}});}function waterfrontProperties(onlyWaterfront){$("#listlist").find("li.listingli").each(function(){var mls=$(this).attr("id").replace(/^li-/,"");var index=parseInt($(this).attr("aidx"));var mlsListing=currentListings[index];if($(this).attr("waterfrontyn")=="N"){if(onlyWaterfront){realCount--;mlsListing.hide();}else{realCount++;mlsListing.show();}}});}function postLoadThresholdChanges(){if(postLoadThreshold==null){displayListings(false,false);return;}currentThreshold.hasMinPrice=postLoadThreshold.hasMinPrice;currentThreshold.hasMaxPrice=postLoadThreshold.hasMaxPrice;currentThreshold.hasMinBeds=postLoadThreshold.hasMinBeds;currentThreshold.hasMaxBeds=postLoadThreshold.hasMaxBeds;currentThreshold.hasMinBaths=postLoadThreshold.hasMinBaths;currentThreshold.hasMaxBaths=postLoadThreshold.hasMaxBaths;currentThreshold.hasMinDays=postLoadThreshold.hasMinDays;currentThreshold.hasMaxBaths=postLoadThreshold.hasMaxDays;if(!currentThreshold.same(postLoadThreshold)){if(postLoadThreshold.minPrice>currentThreshold.minPrice&&currentThreshold.hasMinPrice){currentThreshold.minPrice=postLoadThreshold.minPrice;}else{currentThreshold.hasMinPrice=false;}if(postLoadThreshold.maxPrice<currentThreshold.maxPrice&&currentThreshold.hasMaxPrice){currentThreshold.maxPrice=postLoadThreshold.maxPrice;}else{currentThreshold.hasMaxPrice=false;}if(postLoadThreshold.minBeds>currentThreshold.minBeds&&currentThreshold.hasMinBeds){currentThreshold.minBeds=postLoadThreshold.minBeds;}else{currentThreshold.hasMinBeds=false;}if(postLoadThreshold.maxBeds<currentThreshold.maxBeds&&currentThreshold.hasMaxBeds){currentThreshold.maxBeds=postLoadThreshold.maxBeds;}else{currentThreshold.hasMaxBeds=false;}if(postLoadThreshold.minBaths>currentThreshold.minBaths&&currentThreshold.hasMinBaths){currentThreshold.minBaths=postLoadThreshold.minBaths;}else{currentThreshold.hasMinBaths=false;}if(postLoadThreshold.maxBaths<currentThreshold.maxBaths&&currentThreshold.hasMinBaths){currentThreshold.maxBaths=postLoadThreshold.maxBaths;}else{currentThreshold.hasMaxBaths=false;}if(postLoadThreshold.minDays>currentThreshold.minDays&&currentThreshold.hasMinDays){currentThreshold.minDays=postLoadThreshold.minDays;}else{currentThreshold.hasMinDays=false;}if(postLoadThreshold.maxDays<currentThreshold.maxDays&&currentThreshold.hasMinDays){currentThreshold.maxDays=postLoadThreshold.maxDays;}else{currentThreshold.hasMaxDays=false;}$("#price-amount").val(priceInK(currentThreshold.minPrice)+" - "+priceInK(currentThreshold.maxPrice));$("#beds-amount").val(""+currentThreshold.minBeds+" - "+currentThreshold.maxBeds);$("#bath-amount").val(""+currentThreshold.minBaths+" - "+currentThreshold.maxBaths);$("#days-amount").val(""+currentThreshold.minDays+" - "+currentThreshold.maxDays);}currentThreshold.typeList=postLoadThreshold.typeList;displayListings(true,false);}function thresholdChange(){var newThreshold=new Threshold();newThreshold.setFromHTML();if(!currentThreshold.same(newThreshold)){currentThreshold.userChangeValues(newThreshold);displayListings(true,false);cm.recluster();getRealCount();}}function updateDisplayListings(){cm.hide();cm.show();displayListings(true,true);getRealCount();}function displayListings(animateCount,checkBounds){var matched=0;for(var i=0;i<currentListings.length;i++){var listing=currentListings[i];if(listing.meetThreshold(currentThreshold)&&(!checkBounds||(checkBounds&&listing.inBounds()))){matched++;if(!listing.showing){listing.show();}}else{if(listing.showing){listing.hide();}}}if($("#li-waterfront").hasClass("checked")){waterfrontProperties(true);}if(animateCount){$("#listingCountText").animateToClass("listingCount_anamation1",2000).animateToClass("listingCount_anamation2",1000);}}function removeLiMouseListeners(){$(".listingli").unbind("mouseover").unbind("mouseout");}function liMouseListeners(){$(".listingli").mouseover(function(){var liID=$(this).attr("id");var index=parseInt($(this).attr("aidx"));var mls=liID.replace(/^li-/,"").replace(/_/," ");var mlsListing=currentListings[index];mlsListing.selectedMarker();}).mouseout(function(){var liID=$(this).attr("id");var index=parseInt($(this).attr("aidx"));var mls=liID.replace(/^li-/,"").replace(/_/," ");var mlsListing=currentListings[index];mlsListing.unselectedMarker();});}function Listing(json){this.jsonObject=json;this.marker_=null;this.photo_=null;this.showing=true;this.hzInfoWindow=null;if(this.jsonObject.lat!="0"){this.marker();this.marker_.hidden=true;}this.inBounds_=false;this.clustered=false;}Listing.counter=0;Listing.currentInfoWindowListing=null;Listing.reClustered=function(){if(Listing.currentInfoWindowListing!=null){if(Listing.currentInfoWindowListing.clustered){Listing.closeInfoWindow();}}};Listing.viewListing=function(){if(Listing.currentInfoWindowListing!=null){Listing.currentInfoWindowListing.viewListing();}};Listing.closeInfoWindow=function(){if(Listing.currentInfoWindowListing!=null){$("#marker-info-window").fadeOut();Listing.currentInfoWindowListing=null;}};Listing.iconShadow=new google.maps.MarkerImage("/images/icons/shadow-icon_listing.png",new google.maps.Size(41,35),new google.maps.Point(0,0),new google.maps.Point(11,35));Listing.iconHilitedShadow=new google.maps.MarkerImage("/images/icons/shadow-icon_listing_highlight.png",new google.maps.Size(59,53),new google.maps.Point(0,0),new google.maps.Point(16,53));Listing.prototype.select=function(){if(selectedListing){selectedListing.unselect();selectedListing=null;}$("#"+this.liID()).addClass("listingBorder-hilight");selectedListing=this;};Listing.prototype.inMapBounds=function(){return map.getBounds().contains(this.marker_.getPosition());};Listing.prototype.isShowing=function(){return !this.marker_.hidden;};Listing.prototype.unselect=function(){$("#"+this.liID()).removeClass("listingBorder-hilight");};Listing.prototype.selectedMarker=function(){this.marker_.setIcon("/images/icons/icon_listing_highlight.png");this.marker_.setShadow(Listing.iconHilitedShadow);};Listing.prototype.unselectedMarker=function(){this.marker_.setShadow(Listing.iconShadow);this.marker_.setIcon("/images/icons/icon_listing.png");};Listing.prototype.marker=function(){if(this.marker_){return this.marker_;}var marker=new google.maps.Marker({position:new google.maps.LatLng(parseFloat(this.jsonObject.lat),parseFloat(this.jsonObject.lng)),map:map,icon:"/images/icons/icon_listing.png",shadow:Listing.iconShadow});marker.listingObject=this;cm.addPoint(marker);var self=this;google.maps.event.addListener(marker,"click",function(){self.infoWindow();});google.maps.event.addListener(marker,"mouseover",function(){self.infoLabel();});google.maps.event.addListener(marker,"mouseout",function(){self.hideInfoLabel();});this.marker_=marker;return marker;};Listing.prototype.inBounds=function(){return this.inBounds_;};Listing.prototype.hideInfoLabel=function(){$("#marker-info-label").hide();};Listing.prototype.infoLabel=function(){var iWindow=document.getElementById("marker-info-label");var lY=markerOverlay.getProjection().fromLatLngToDivPixel(this.marker_.getPosition()).y;var lX=markerOverlay.getProjection().fromLatLngToDivPixel(this.marker_.getPosition()).x;iWindow.innerHTML="<nobr>"+this.jsonObject.address+"<nobr><br /><span>Click to see details</span>";var left=lX+20;var mapWidth=$("#mapDiv").width();var adrWidth=$("#marker-info-label").width();if((left+adrWidth)>mapWidth){left=lX-30-adrWidth;}iWindow.style.top=(lY-40)+"px";iWindow.style.left=left+"px";iWindow.style.display="block";};Listing.prototype.adjustInfoWindow=function(){var mapWidth=$("#mapDiv").width();var markerPositions=xyPositions(this.marker_.getPosition());var lY=markerPositions.absolute.y;var lX=markerPositions.absolute.x;var iWindow=document.getElementById("marker-info-window");if(markerPositions.relative.x>$("#bubble-template").width()+20){lX=lX-$("#bubble-template").width()-20;if($("#bubble-beak").hasClass("bubble-beak")){$("#bubble-beak").removeClass("bubble-beak").addClass("bubble-beak-right");}}else{if($("#bubble-beak").hasClass("bubble-beak-right")){$("#bubble-beak").removeClass("bubble-beak-right").addClass("bubble-beak");}}iWindow.style.top=(lY-90)+"px";iWindow.style.left=(lX+10)+"px";$("#bubble-beak").css("top",62);if($("#mapDiv").height()<markerPositions.relative.y+70){lY=lY-$("#marker-info-window").height()+5;$("#marker-info-window").css("top",lY);$("#bubble-beak").css("top",$("#marker-info-window").height()-34);}else{if($("#mapDiv").height()<markerPositions.relative.y+$("#marker-info-window").height()-30){var beakTop=parseInt($("#bubble-beak").css("top"));lY=lY-140;$("#marker-info-window").css("top",lY);$("#bubble-beak").css("top",beakTop+50);}else{if(markerPositions.relative.y<80){$("#marker-info-window").css("top",markerPositions.absolute.y-30);$("#bubble-beak").css("top",0);}}}};Listing.prototype.infoWindow=function(){var bubbleBeakLeft=true;this.hideInfoLabel();track("forSale info window",this.jsonObject.mls,"");Listing.currentInfoWindowListing=this;$("#marker-info-label").hide();var template=document.getElementById("bubble-template").innerHTML;var markerPositions=xyPositions(this.marker_.getPosition());template=template.replace(/{head}/gi,this.jsonObject.address+" - "+this.jsonObject.prettyPrice.replace(/\.00$/,""));if(this.jsonObject.type=="house"){template=template.replace(/{subhead}/gi,"<li>"+this.jsonObject.bedrooms+" Beds</li><li>"+this.jsonObject.washrooms+" Baths</li><li></li>");}else{if(this.jsonObject.type=="vacant"){template=template.replace(/{subhead}/gi,"<li>Vacant</li><li>"+this.jsonObject.days_on_market+" Days</li>");}else{template=template.replace(/{subhead}/gi,"<li>Commercial</li><li>"+this.jsonObject.days_on_market+" Days</li>");}}var lY=markerPositions.absolute.y;var lX=markerPositions.absolute.x;var mapwidth=$("#mapDiv").width();if(markerPositions.relative.x>$("#bubble-template").width()+20){lX=lX-$("#bubble-template").width()-20;template=template.replace(/bubble-beak/gi,"bubble-beak-right");bubbleBeakLeft=false;}Listing.counter++;gallery='<div class="gallery-wrapper"><button class="prev"><img src="/images/infoWindow/arrow_left_active.gif"></button>';gallery+='<div class="gallery-holder"><div class="gallery'+Listing.counter+'"><ul>';if(this.jsonObject.photos==null||this.jsonObject.photos.length==0){gallery+='<li title="No Photos"><img src="/images/nolistingphoto.jpg" alt="" width="170" height="150" ></li>';}else{for(i in this.jsonObject.photos){var photo=this.jsonObject.photos[i];var imgNo=parseInt(i)+1;gallery+='<li title="Image '+imgNo+" of "+this.jsonObject.photos.length+'"><img mls="'+this.jsonObject.mls+'" src="'+this.photoURL(photo)+'" alt="" width="170" height="150" ></li>';}}gallery+="</ul></div>";gallery+='</div><button class="next"><img src="/images/infoWindow/arrow_right_active.gif"></button>';gallery+='<div class="clr"></div></div>';template=template.replace(/{gallery}/gi,gallery);var iWindow=document.getElementById("marker-info-window");iWindow.style.top=(lY-90)+"px";iWindow.style.left=(lX+10)+"px";iWindow.innerHTML=template;iWindow.style.display="block";if(bubbleBeakLeft){$(".bubble-beak").attr("id","bubble-beak");}else{$(".bubble-beak-right").attr("id","bubble-beak");}if(this.jsonObject.photos==null||this.jsonObject.photos.length==0){$(".image-number").text("No Photos");}else{$(".image-number").text("Image 1 of "+this.jsonObject.photos.length);}$(".gallery"+Listing.counter).jCarouselLite({btnNext:".next",btnPrev:".prev",visible:1,afterEnd:function(a){$(".image-number").text(a.attr("title"));a.find("img").each(function(){var image=$(this).attr("src");var mls=$(this).attr("mls");image=image.replace(/\\/g,"/").replace(/.*\//,"");track("forSale image view",mls,image);});}});$(".view-list").click(function(){Listing.viewListing();});$("#bubble-beak").css("top",62);if($("#mapDiv").height()<markerPositions.relative.y+70){lY=lY-$("#marker-info-window").height()+5;$("#marker-info-window").css("top",lY);$("#bubble-beak").css("top",$("#marker-info-window").height()-34);}else{if($("#mapDiv").height()<markerPositions.relative.y+$("#marker-info-window").height()-30){var beakTop=parseInt($("#bubble-beak").css("top"));lY=lY-140;$("#marker-info-window").css("top",lY);$("#bubble-beak").css("top",beakTop+50);}else{if(markerPositions.relative.y<80){$("#marker-info-window").css("top",markerPositions.absolute.y-30);$("#bubble-beak").css("top",0);}}}$("#marker-info-window").show();};Listing.prototype.photoURL=function(photo){if(photo.match(/^http/)){return photo;}return"http://images.homezilla.ca"+photo;};Listing.prototype.show=function(){$("#"+this.liID()).show();if(!this.marker_){return;}if(!this.inBounds_){return;}this.showing=true;this.marker_.hidden=false;};Listing.prototype.hideMarker=function(){this.marker_.setMap(null);this.marker_.hidden=true;};Listing.prototype.showMarker=function(){this.marker_.setMap(map);this.marker_.hidden=false;};Listing.prototype.hide=function(){$("#"+this.liID()).hide();if(!this.showing){return;}this.showing=false;this.marker_.setMap(null);this.marker_.hidden=true;};Listing.prototype.liID=function(){return"li-"+this.limls();};Listing.prototype.limls=function(){return this.jsonObject.mls.replace(/ /g,"_");};Listing.prototype.liHTML=function(attr){return"<li class='listingli' id=\"li-"+this.limls()+"\" waterfrontyn='"+this.jsonObject.waterfrontyn+"' aidx='"+this.jsonObject.index+"'>"+this.html(attr)+"</li>";};Listing.prototype.fullAddress=function(){return this.jsonObject.address+", "+this.jsonObject.city+", "+this.jsonObject.province;};Listing.prototype.viewListing=function(){window.location=this.listingLink(true);};Listing.prototype.html=function(attr){var s="<div class='scaleWidth'><a href='"+this.listingLink(true)+"'>"+"<img class='smallListImg' "+attr+'="'+this.photo()+'" alt="'+this.fullAddress()+'" />'+"</a></div>";s+="<div><h2 class='listing'>";s+='<a href="'+this.listingLink(true)+'">'+this.jsonObject.address+"</a>";s+='<br/><a href="'+this.listingLink(true)+'">'+this.jsonObject.city+", "+this.jsonObject.province+"</a>";s+='</h2></div><p class="desc">';s+=this.jsonObject.prettyPrice+"<br/>"+this.beds()+" Bedroom, "+this.baths()+" Bath</p>";s+='<p class="realtor">'+this.brokerage()+", "+this.jsonObject.agent+"</p>";if(this.jsonObject.lat=="0"){s+='<span class="listingnote">Not shown on map</span>';}return s;};Listing.prototype.brokerage=function(){return this.jsonObject.brokerage;};Listing.prototype.listingLink=function(includeAddress){if(includeAddress){var address=this.goodAddress()+"_"+this.jsonObject.city+"_"+this.jsonObject.province;address=address.replace(/#/g,"").replace(/ /g,"_");return"/listing/"+escape(address)+"_"+this.jsonObject.mls;}else{return"/listing/"+this.jsonObject.mls;}};Listing.prototype.goodAddress=function(){return this.jsonObject.address.replace(/\//,"-").replace(/ /,"_").replace(/[#?]/,"").replace(/&/,"and");};Listing.prototype.photo=function(){if(this.photo_==null){if(this.jsonObject.photos==null||this.jsonObject.photos.length==0){this.photo_="/images/nolistingphoto.jpg";}else{this.photo_=this.photoURL(this.jsonObject.photos[0]);}}return this.photo_;};Listing.prototype.hasPhoto=function(){if(this.jsonObject.photos==null||this.jsonObject.photos.length==0){return false;}if(this.jsonObject.photos[i]=="/images/nolistingphoto.jpg"){return false;}return true;};Listing.prototype.price=function(){return parseFloat(this.jsonObject.price);};Listing.prototype.beds=function(){return parseInt(this.jsonObject.bedrooms);};Listing.prototype.baths=function(){return parseInt(this.jsonObject.washrooms);};Listing.prototype.days=function(){return parseInt(this.jsonObject.days_on_market);};Listing.prototype.meetThreshold=function(threshold){var beds=this.beds();var price=this.price();var baths=this.baths();var days=this.days();if(this.marker_){this.marker_.hidden=true;}if(beds<threshold.minBeds){return false;}if(beds>threshold.maxBeds){return false;}if(price<threshold.minPrice){return false;}if(price>threshold.maxPrice){return false;}if(baths<threshold.minBaths){return false;}if(baths>threshold.maxBaths){return false;}if(days<threshold.minDays){return false;}if(days>threshold.maxDays){return false;}if(!threshold.hasType(this.jsonObject.type)){return false;}if(this.marker_){this.marker_.hidden=false;}return true;};function Threshold(){this.minPrice=1000000000;this.maxPrice=-1;this.minBeds=1000;this.maxBeds=-1;this.minBaths=1000;this.maxBaths=-1;this.minDays=1000;this.maxDays=-1;this.hasMinPrice=false;this.hasMaxPrice=false;this.hasMinBeds=false;this.hasMaxBeds=false;this.hasMinBaths=false;this.hasMaxBaths=false;this.hasMinDays=false;this.hasMaxDays=false;this.typeList=new Array("house","vacant");}Threshold.prototype.asParams=function(){var params="";if(this.hasMinPrice){params+="&minprice="+this.minPrice;}if(this.hasMaxPrice){params+="&maxprice="+this.maxPrice;}if(this.hasMinBeds){params+="&minbeds="+this.minBeds;}if(this.hasMaxBeds){params+="&maxbeds="+this.maxBeds;}if(this.hasMinBaths){params+="&minbaths="+this.minBaths;}if(this.hasMaxBaths){params+="&maxbaths="+this.maxBaths;}if(this.hasMinDays){params+="&mindays="+this.minDays;}if(this.hasMaxDays){params+="&maxdays="+this.maxDays;}return params;};Threshold.prototype.hasType=function(type){for(var i=0;i<this.typeList.length;i++){if(type==this.typeList[i]){return true;}}return false;};Threshold.prototype.removeType=function(type){var foundIndex=-1;for(var i=0;i<this.typeList.length;i++){if(type==this.typeList[i]){foundIndex=i;i=this.typeList.length;}}if(foundIndex>=0){this.typeList.splice(foundIndex,1);}};Threshold.prototype.addtype=function(type){for(var i=0;i<this.typeList.length;i++){if(type==this.typeList[i]){return;}}this.typeList.push(type);};Threshold.prototype.zeroValues=function(){this.minPrice=0;this.maxPrice=0;this.minBeds=0;this.maxBeds=0;this.minBaths=0;this.maxBaths=0;this.minDays=0;this.maxDays=0;};Threshold.prototype.toString=function(){var s="[ price: "+(this.hasMinPrice?"<b>"+priceInK(this.minPrice)+"</b>":priceInK(this.minPrice));s+=" - "+(this.hasMaxPrice?"<b>"+priceInK(this.maxPrice)+"</b>":priceInK(this.maxPrice))+"; beds: ";s+=this.hasMinBeds?"<b>"+this.minBeds+"</b>":this.minBeds;s+=" - "+(this.hasMaxBeds?"<b>"+this.maxBeds+"</b>":this.maxBeds)+"; baths: ";s+=this.hasMinBaths?"<b>"+this.minBaths+"</b>":this.minBaths;s+=" - "+(this.hasMaxBaths?"<b>"+this.maxBaths+"</b>":this.maxBaths)+"; days: ";s+=this.hasMindays?"<b>"+this.minDays+"</b>":this.minDays;s+=" - "+(this.hasMaxDays?"<b>"+this.maxDays+"</b>":this.maxDays)+"; types: ";for(var i=0;i<this.typeList.length;i++){s+=" "+this.typeList[i];}s+=" ]";return s;};Threshold.prototype.userChangeValues=function(threshold){if(this.minPrice!=threshold.minPrice){var origMin=$("#filter-price").slider("option","min");if(threshold.minPrice==origMin){this.hasMinPrice=false;}else{this.hasMinPrice=true;}this.minPrice=threshold.minPrice;}if(this.maxPrice!=threshold.maxPrice){var origMax=parseInt($("#filter-price").slider("max"));if(threshold.maxPrice==origMax){this.hasMaxPrice=false;}else{this.hasMaxPrice=true;}this.maxPrice=threshold.maxPrice;}if(this.minBeds!=threshold.minBeds){var origMin=parseInt($("#filter-beds").slider("min"));if(threshold.minBeds==origMin){this.hasMinBeds=false;}else{this.hasMinBeds=true;}this.minBeds=threshold.minBeds;}if(this.maxBeds!=threshold.maxBeds){var origMax=parseInt($("#filter-beds").slider("max"));if(threshold.maxBeds==origMax){this.hasMaxBeds=false;}else{this.hasMaxBeds=true;}this.maxBeds=threshold.maxBeds;}if(this.minBaths!=threshold.minBaths){var origMin=parseInt($("#filter-bath").slider("min"));if(threshold.minBaths==origMin){this.hasMinBaths=false;}else{this.hasMinBaths=true;}this.minBaths=threshold.minBaths;}if(this.maxBaths!=threshold.maxBaths){var origMax=parseInt($("#filter-bath").slider("max"));if(threshold.maxBaths==origMax){this.hasMaxBaths=false;}else{this.hasMaxBaths=true;}this.maxBaths=threshold.maxBaths;}this.typeList=threshold.typeList;};Threshold.prototype.setFromHTML=function(){this.minPrice=$("#filter-price").slider("values",0);this.maxPrice=$("#filter-price").slider("values",1);this.minBeds=$("#filter-beds").slider("values",0);this.maxBeds=$("#filter-beds").slider("values",1);this.minBaths=$("#filter-bath").slider("values",0);this.maxBaths=$("#filter-bath").slider("values",1);this.typeList=new Array();if($("#li-residential").hasClass("checked")){this.typeList.push("house");}if($("#li-vacant").hasClass("checked")){this.typeList.push("vacant");}if($("#li-commercial").hasClass("checked")){this.typeList.push("commercial");}};Threshold.prototype.setMinPrice=function(price){if(price<this.minPrice){this.minPrice=parseInt(price/5000)*5000;}};Threshold.prototype.setMaxPrice=function(price){if(price>this.maxPrice){this.maxPrice=(parseInt(price/5000)+1)*5000;}};Threshold.prototype.setMinBeds=function(beds){if(beds<this.minBeds){this.minBeds=beds;}};Threshold.prototype.setMaxBeds=function(beds){if(beds>this.maxBeds){this.maxBeds=beds;}};Threshold.prototype.setMinBaths=function(baths){if(baths<this.minBaths){this.minBaths=baths;}};Threshold.prototype.setMaxBaths=function(baths){if(baths>this.maxBaths){this.maxBaths=baths;}};Threshold.prototype.setMinDays=function(days){if(days<this.minDays){this.minDays=days;}};Threshold.prototype.setMaxDays=function(days){if(days>this.maxDays){this.maxDays=days;}};Threshold.prototype.same=function(threshold){var sameTypes=true;if(this.typeList.length!=threshold.typeList.length){sameTypes=false;}else{for(var i=0;i<this.typeList.length;i++){if(!threshold.hasType(this.typeList[i])){sameTypes=false;i=this.typeList.length;}}}return sameTypes&&(this.minPrice==threshold.minPrice&&this.maxPrice==threshold.maxPrice&&this.minBeds==threshold.minBeds&&this.maxBeds==threshold.maxBeds&&this.minBaths==threshold.minBaths&&this.maxBaths==threshold.maxBaths&&this.minDays==threshold.minDays&&this.maxDays==threshold.maxDays);};Threshold.prototype.setHTMLfromThreshold=function(){if(!this.hasMinPrice){$("#filter-price").slider("option","min",this.minPrice);}if(!this.hasMaxPrice){$("#filter-price").slider("option","max",this.maxPrice);}if(!this.hasMinBeds){$("#filter-beds").slider("option","min",this.minBeds);}if(!this.hasMaxBeds){$("#filter-beds").slider("option","max",this.maxBeds);}if(!this.hasMinBaths){$("#filter-bath").slider("option","min",this.minBaths);}if(!this.hasMaxBaths){$("#filter-bath").slider("option","max",this.maxBaths);}$("#filter-price").slider("option","values",[this.minPrice,this.maxPrice]);$("#filter-beds").slider("option","values",[this.minBeds,this.maxBeds]);$("#filter-bath").slider("option","values",[this.minBaths,this.maxBaths]);};Threshold.prototype.initHTMLfromThreshold=function(){$("#filter-price").slider({range:true,min:this.minPrice,max:this.maxPrice,step:5000,values:[this.minPrice,this.maxPrice],slide:function(event,ui){$("#price-amount").val(priceInK(ui.values[0])+" - "+priceInK(ui.values[1]));}});$("#filter-beds").slider({range:true,min:this.minBeds,max:this.maxBeds,values:[this.minBeds,this.maxBeds],slide:function(event,ui){$("#beds-amount").val(ui.values[0]+" - "+ui.values[1]);}});$("#filter-bath").slider({range:true,min:this.minBaths,max:this.maxBaths,values:[this.minBaths,this.maxBaths],slide:function(event,ui){$("#bath-amount").val(ui.values[0]+" - "+ui.values[1]);}});$("#price-amount").val(priceInK(this.minPrice)+" - "+priceInK(this.maxPrice));$("#beds-amount").val(""+this.minBeds+" - "+this.maxBeds);$("#bath-amount").val(""+this.minBaths+" - "+this.maxBaths);$("#days-amount").val(""+this.minDays+" - "+this.maxDays);};function priceInK(price){return"$"+parseInt(price/1000)+"K";}function infoWindowClose(){}function ClusterMarker(point){this.point_=point;}function ClusterManager(map,infoText){this._map=map;this.latClusters=8;this.lngClusters=8;this.infoText=infoText;this.points=new Array();this.initCluster();}ClusterManager.prototype.report=function(){var totalPoints=0;for(var i=0;i<8;i++){for(var j=0;j<8;j++){var cp=this.clusterPoints[i][j];if(cp!=null){totalPoints+=cp.report();}else{}}}};ClusterManager.prototype.addPoint=function(point){this.points.push(point);};ClusterManager.prototype.getLatSection=function(lat){return Math.floor((lat-this.sw.lat())/this.latPerSection);};ClusterManager.prototype.getLngSection=function(lng){return Math.floor((lng-this.sw.lng())/this.lngPerSection);};ClusterManager.prototype.hide=function(){for(var i=0;i<8;i++){for(var j=0;j<8;j++){var cp=this.clusterPoints[i][j];if(cp!=null){cp.hide();}}}};ClusterManager.prototype.show=function(){this.initCluster();this.cluster();for(var i=0;i<8;i++){for(var j=0;j<8;j++){var cp=this.clusterPoints[i][j];if(cp!=null){cp.show();}}}};ClusterManager.prototype.empty=function(){for(var i=0;i<8;i++){for(var j=0;j<8;j++){var cp=this.clusterPoints[i][j];if(cp!=null){cp.empty();}this.clusterPoints[i][j]=null;}}var numPoints=this.points.length;for(var i=0;i<numPoints;i++){this.points.pop();}};ClusterManager.prototype.getClusterPoint=function(cp){var lat=this.sw.lat()+cp.latSection*this.latPerSection+this.latPerSection/2;var lng=this.sw.lng()+cp.lngSection*this.lngPerSection+this.lngPerSection/2;return new google.maps.LatLng(lat,lng);};ClusterManager.prototype.initCluster=function(){var bounds=map.getBounds();this.sw=bounds.getSouthWest();this.ne=bounds.getNorthEast();latDiff=this.ne.lat()-this.sw.lat();lngDiff=this.ne.lng()-this.sw.lng();this.latPerSection=latDiff/this.latClusters;this.lngPerSection=lngDiff/this.lngClusters;this.clusterPoints=new Array(8);for(var i=0;i<8;i++){this.clusterPoints[i]=Array(8);for(var j=0;j<8;j++){this.clusterPoints[i][j]=null;}}};ClusterManager.prototype.recluster=function(){for(var i=0;i<8;i++){for(var j=0;j<8;j++){var cp=this.clusterPoints[i][j];if(cp!=null){cp.recluster();}}}};ClusterManager.prototype.cluster=function(){var numPoints=this.points.length;for(var i=0;i<numPoints;i++){var marker=this.points[i];var point=marker.getPosition();var latSection=this.getLatSection(point.lat());var lngSection=this.getLngSection(point.lng());if(this.sectionInBounds(latSection,lngSection)){marker.listingObject.inBounds_=true;if(this.clusterPoints[latSection][lngSection]==null){this.clusterPoints[latSection][lngSection]=new ClusterPoint(latSection,lngSection,this.infoText);}this.clusterPoints[latSection][lngSection].addPoint(marker);}else{marker.listingObject.inBounds_=false;}}};ClusterManager.prototype.sectionInBounds=function(latSection,lngSection){if(latSection<0||lngSection<0){return false;}if(latSection>=8||lngSection>=8){return false;}return true;};function ClusterPoint(latSection,lngSection,infoText){this.latSection=latSection;this.lngSection=lngSection;this.clustered=false;this.clusterMarker=null;this.points=new Array();this.point=null;this.infoText=infoText;}ClusterPoint.CLUSTER_POINT_AMOUNT=5;ClusterPoint.markerClusterPoint=null;ClusterPoint.prototype.report=function(){return this.points.length;};ClusterPoint.prototype.setCentre=function(){if(zoom<10){zoom=10;}else{zoom++;}map.setCenter(this.point);map.setZoom(zoom);};ClusterPoint.prototype.addPoint=function(point){if(this.points==null){this.points=array();}this.points.push(point);};ClusterPoint.prototype.recluster=function(){if(this.clustered){if(ClusterPoint.CLUSTER_POINT_AMOUNT>=this.numShowing()){this.hide();this.show();}}else{if(ClusterPoint.CLUSTER_POINT_AMOUNT<this.numShowing()){this.hide();this.show();}else{for(var i=0;i<this.points.length;i++){if(this.points[i].hidden){this.points[i].listingObject.hide();}else{this.points[i].listingObject.showMarker();}}}}if(this.clustered){}};ClusterPoint.prototype.hide=function(){if(this.clustered){if(this.point.marker!=null){this.point.marker.setMap(null);this.point=null;}}else{for(var i=0;i<this.points.length;i++){this.points[i].listingObject.hideMarker();}}this.clustered=false;};ClusterPoint.prototype.empty=function(){this.clustered=false;var numPoints=this.points.length;for(var i=0;i<numPoints;i++){this.points.pop();}};ClusterPoint.prototype.getClusterPoint=function(){if(this.point==null){var latTotal=0;var lngTotal=0;for(var i=0;i<this.points.length;i++){var pos=this.points[i].getPosition();latTotal+=pos.lat();lngTotal+=pos.lng();}this.point=new google.maps.LatLng(latTotal/this.points.length,lngTotal/this.points.length);}return this.point;};ClusterPoint.prototype.numShowing=function(){var count=0;if(this.points.length>=ClusterPoint.CLUSTER_POINT_AMOUNT){for(var i=0;i<this.points.length;i++){if(this.points[i].listingObject.showing){count++;}}}return count;};ClusterPoint.closeInfoWindow=function(){$("#cmarker-info-label").hide();ClusterPoint.markerClusterPoint=null;};ClusterPoint.closeSpecificInfoWindow=function(latSection,lngSection){if(ClusterPoint.markerClusterPoint!=null){var cp=ClusterPoint.markerClusterPoint;if(cp.latSection==latSection&&cp.lngSection==lngSection){$("#cmarker-info-label").hide();ClusterPoint.markerClusterPoint=null;}}};ClusterPoint.prototype.infoWindow=function(){Listing.closeInfoWindow();var innerHTML=this.infoText.replace("%count",this.numShowing()).replace("%latSection",this.latSection).replace("%lngSection",this.lngSection);var iWindow=document.getElementById("cmarker-info-label");var marker=this.point.marker;var lY=cmarkerOverlay.getProjection().fromLatLngToDivPixel(marker.getPosition()).y;var lX=cmarkerOverlay.getProjection().fromLatLngToDivPixel(marker.getPosition()).x;iWindow.innerHTML=innerHTML;var left=lX+20;var mapWidth=$("#mapDiv").width();var labelWidth=$("#cmarker-info-label").width();if((left+labelWidth)>mapWidth){left=lX-30-adrWidth;}iWindow.style.top=(lY-40)+"px";iWindow.style.left=left+"px";iWindow.style.display="block";ClusterPoint.markerClusterPoint=this;setTimeout("ClusterPoint.closeSpecificInfoWindow("+this.latSection+","+this.lngSection+")",5000);};ClusterPoint.iconImage=new google.maps.MarkerImage("/images/icons/icon_listing_big.png",new google.maps.Size(32,48),new google.maps.Point(0,0),new google.maps.Point(0,32));ClusterPoint.prototype.show=function(){if(this.numShowing()>=ClusterPoint.CLUSTER_POINT_AMOUNT){this.getClusterPoint();var marker=new google.maps.Marker({position:this.point,map:map,icon:ClusterPoint.iconImage,title:this.infoText});marker.clusterPoint=this;this.point.marker=marker;marker.setMap(map);this.clustered=true;google.maps.event.addListener(marker,"click",function(){marker.clusterPoint.infoWindow();});for(var i=0;i<this.points.length;i++){this.points[i].listingObject.hideMarker();this.points[i].listingObject.clustered=true;}}else{this.clustered=false;for(var i=0;i<this.points.length;i++){if(this.points[i].listingObject.showing){this.points[i].listingObject.showMarker();this.points[i].listingObject.clustered=false;}}}Listing.reClustered();};function initHTML(){$("#adjustable-map a.collapse").click(function(){$("#adjustable-map").animate({width:"80px"},900);$("#home-listings").animate({width:"672px"},1200);});$("#adjustable-map a.expand").click(function(){$("#adjustable-map").animate({width:"557px"},1200);$("#home-listings").animate({width:"201px"},900);});$("#home-listings a.expand").click(function(){if($(this).hasClass("expanded")){$("#home-listings").animate({width:"201px"},900);$("#adjustable-map").animate({width:"557px"},1200);$(this).removeClass("expanded");$("#listlist").removeClass("large");$("#listlist").addClass("small");$("#listlist").children().removeClass("wide");$("#listlist").children().each(function(){var image=$(this).find("img");image.lazyload();image.removeClass("largeListImg");var imageSrc=image.attr("src");if(imageSrc.indexOf("nolistingphoto.jpg")==-1){image.attr("src",imageSrc.substring(0,imageSrc.indexOf(".jpg"))+"_thumb_170.jpg");}$(this).find("p.desc").removeClass("wide");});}else{$(this).addClass("expanded");$("#home-listings").animate({width:"672px"},1200);$("#adjustable-map").animate({width:"80px"},900);$("#listlist").removeClass("small");$("#listlist").addClass("large");$("#home-listings #listingState").html("Expand List of Homes");$("#listlist").children().addClass("wide");$("#listlist").children().each(function(){var image=$(this).find("img");var imageSrc=image.attr("src");if(imageSrc.indexOf("nolistingphoto.jpg")==-1){image.attr("src",imageSrc.substring(0,imageSrc.indexOf("_thumb"))+imageSrc.substring(imageSrc.indexOf("_thumb_170")+6));image.addClass("largeListImg");}$(this).find("p.desc").addClass("wide");});}});$("#filter-title-price").click(function(){$("div#price-wrapper").toggle("slow");if($("#filter-title-price").hasClass("arrow-down")){$("#filter-title-price").removeClass("arrow-down").addClass("arrow-up");}else{$("#filter-title-price").removeClass("arrow-up").addClass("arrow-down");}});$("#filter-title-beds").click(function(){$("div#beds-wrapper").toggle("slow");if($("#filter-title-beds").hasClass("arrow-down")){$("#filter-title-beds").removeClass("arrow-down").addClass("arrow-up");}else{$("#filter-title-beds").removeClass("arrow-up").addClass("arrow-down");}});$("#filter-title-baths").click(function(){$("div#bath-wrapper").toggle("slow");if($("#filter-title-baths").hasClass("arrow-down")){$("#filter-title-baths").removeClass("arrow-down").addClass("arrow-up");}else{$("#filter-title-baths").removeClass("arrow-up").addClass("arrow-down");}});$("#filter-title-days").click(function(){$("div#days-wrapper").toggle("slow");if($("#filter-title-days").hasClass("arrow-down")){$("#filter-title-days").removeClass("arrow-down").addClass("arrow-up");}else{$("#filter-title-days").removeClass("arrow-up").addClass("arrow-down");}});$("#filter-title-typehomes").click(function(){$("div#typehomes-wrapper").toggle("slow");if($("#filter-title-typehomes").hasClass("arrow-down")){$("#filter-title-typehomes").removeClass("arrow-down").addClass("arrow-up");}else{$("#filter-title-typehomes").removeClass("arrow-up").addClass("arrow-down");}});}function setCentre(latSection,lngSection){cm.clusterPoints[latSection][lngSection].setCentre();}ListingMarkerOverlay=function(){};ListingMarkerOverlay.prototype=new google.maps.OverlayView();ListingMarkerOverlay.prototype.layer=null;ListingMarkerOverlay.prototype.overlayProjection=null;ListingMarkerOverlay.prototype.onAdd=function(){this.layer=document.createElement("DIV");this.getPanes().floatPane.appendChild(this.layer);};ListingMarkerOverlay.prototype.onRemove=function(){};ListingMarkerOverlay.prototype.draw=function(){if(document.getElementById("marker-info-label")!=null){var iWindow=document.getElementById("marker-info-label");}else{var iWindow=document.createElement("div");iWindow.setAttribute("id","marker-info-label");iWindow.style.display="none";this.layer.appendChild(iWindow);}if(document.getElementById("marker-info-window")!=null){var iWindow=document.getElementById("marker-info-window");}else{var iWindow=document.createElement("div");iWindow.setAttribute("id","marker-info-window");iWindow.style.display="none";this.layer.appendChild(iWindow);}};ClusterMarkerOverlay=function(){};ClusterMarkerOverlay.prototype=new google.maps.OverlayView();ClusterMarkerOverlay.prototype.layer=null;ClusterMarkerOverlay.prototype.overlayProjection=null;ClusterMarkerOverlay.prototype.onAdd=function(){this.layer=document.createElement("DIV");this.getPanes().floatPane.appendChild(this.layer);};ClusterMarkerOverlay.prototype.onRemove=function(){};ClusterMarkerOverlay.prototype.draw=function(){if(document.getElementById("cmarker-info-label")!=null){var iWindow=document.getElementById("cmarker-info-label");}else{var iWindow=document.createElement("div");iWindow.setAttribute("id","cmarker-info-label");iWindow.style.display="none";this.layer.appendChild(iWindow);}if(document.getElementById("cmarker-info-window")!=null){var iWindow=document.getElementById("cmarker-info-window");}else{var iWindow=document.createElement("div");iWindow.setAttribute("id","cmarker-info-window");iWindow.style.display="none";this.layer.appendChild(iWindow);}};StaticOverlay.prototype=new google.maps.OverlayView();StaticOverlay.prototype.onAdd=function(){};StaticOverlay.prototype.onRemove=function(){};StaticOverlay.prototype.draw=function(){};StaticOverlay.staticOverlay=null;StaticOverlay.staticProjection=null;function StaticOverlay(map){this.setMap(map);}function xyPositions(position){if(StaticOverlay.staticOverlay!=null){StaticOverlay.staticOverlay.setMap(null);}StaticOverlay.staticOverlay=new StaticOverlay(map);StaticOverlay.staticProjection=StaticOverlay.staticOverlay.getProjection();var pos=StaticOverlay.staticProjection.fromLatLngToDivPixel(position);var pos2=StaticOverlay.staticProjection.fromLatLngToContainerPixel(position);return{relative:{x:pos2.x,y:pos2.y},absolute:{x:pos.x,y:pos.y}};}
