function PropertyListHandler(){this.myId;this.myView;this.container;this.isSubView=false;this.propertyHeading;this.myName;this.viewType;this.sortField="property_createddate";this.myView=new PropertyList();this.init()}PropertyListHandler.prototype.loadView=function(c,a,b){this.myId=c;this.viewContainer=a;this.subViewContainer=b;if(!reapfield.G_API.isBackEvent){this.currentPage=1}if(this.myName=="propertylist"){this.propertyHeading="Latest Properties";this.viewType="open"}else{if(this.myName=="propertysoldlist"){this.propertyHeading="Sold Properties";this.viewType="sold"}else{if(this.myName=="agentCurrentList"){this.propertyHeading="Agent's Current Listings";this.viewType="agentopen"}else{if(this.myName=="agentPastList"){this.propertyHeading="Agent's Sold Listings";this.viewType="agentsold"}}}}this.myView.showView(this.callbackHandlerFn,this.viewContainer,this.subViewContainer,this.isSubView,this,this.propertyHeading);if(reapfield.G_ViewMgr.activeModule.myName!=this.myName){return}if(this.viewType=="open"||this.viewType=="sold"){reapfield.G_API.getPropertyListData(this.viewType,this.currentPage,this.rowsPerPage,this.sortField)}};PropertyListHandler.prototype.loadDetailData=function(a){if(this.viewType=="agentopen"||this.viewType=="agentsold"){this.infoObj=a;reapfield.G_API.getPropertyListDataForAgent(this.viewType,this.currentPage,this.rowsPerPage,this.sortField,this.infoObj.id)}};PropertyListHandler.prototype.init=function(){this.currentPage=1;this.rowsPerPage=10;this.totalRecords;this.totalPages;reapfield.G_EventMgr.registerEvent("propertyListData",this,"propertyListDataListener");reapfield.G_EventMgr.registerEvent("propertyListDataForAgent",this,"propertyListDataListener")};PropertyListHandler.prototype.propertyListDataListener=function(b){if(reapfield.G_ViewMgr.activeModule.myName!=this.myName){return}var a=b.data;if(a.properties.length<=0){this.myView.createNoData();return}this.currentPage=a.page;this.totalRecords=a.records;this.totalPages=a.total;this.myView.displayMainViewData(a);if(this.currentPage==1){this.myView.createOptions();this.myView.addSortDropDown();this.myView.addPagerDropDown(this.getPagerData(this.totalPages),this.currentPage,this.totalPages)}else{this.myView.updatePagerDropDown(this.currentPage,this.totalPages)}reapfield.G_ViewMgr.fixFooterHeight()};PropertyListHandler.prototype.getPagerData=function(c){var d=[];for(var b=0;b<c;b++){var a=(b+1);d.push({id:a,text:"Page "+a+" of "+c})}return d};PropertyListHandler.prototype.callbackHandlerFn=function(e,d,a,c){if(e=="moreInfoClick"){reapfield.G_API.nRecord=c;var b={moduleId:"42",detailId:d};reapfield.G_EventMgr.fireEvent("loadModuleEvent",b)}else{if(e=="pageChangeEvent"){a.currentPage=d;if(a.viewType=="open"||a.viewType=="sold"){reapfield.G_API.getPropertyListData(a.viewType,a.currentPage,a.rowsPerPage,a.sortField)}else{if(a.viewType=="agentopen"||a.viewType=="agentsold"){reapfield.G_API.getPropertyListDataForAgent(a.viewType,a.currentPage,a.rowsPerPage,a.sortField,a.infoObj.id)}}}else{if(e=="sortChangeEvent"){if(d==0){a.sortField=""}else{a.sortField=d}if(a.viewType=="open"||a.viewType=="sold"){reapfield.G_API.getPropertyListData(a.viewType,a.currentPage,a.rowsPerPage,a.sortField)}else{if(a.viewType=="agentopen"||a.viewType=="agentsold"){reapfield.G_API.getPropertyListDataForAgent(a.viewType,a.currentPage,a.rowsPerPage,a.sortField,a.infoObj.id)}}}else{if(e=="pageNavigateEvent"){if(d=="prev"){a.currentPage--}else{if(d=="next"){a.currentPage++}}if(a.viewType=="open"||a.viewType=="sold"){reapfield.G_API.getPropertyListData(a.viewType,a.currentPage,a.rowsPerPage,a.sortField)}else{if(a.viewType=="agentopen"||a.viewType=="agentsold"){reapfield.G_API.getPropertyListDataForAgent(a.viewType,a.currentPage,a.rowsPerPage,a.sortField,a.infoObj.id)}}}}}}};function PropertyList(){}PropertyList.prototype.showView=function(c,f,b,d,a,e){this.viewParentObj=f||document.body;this.subViewParentObj=b||document.body;this.owner=a;this.isSubView=d;this.callbackFn=c;this.propertyLocationId="propertyLocation";this.propertyList="propertyList";this.bathNumberId="bathNum";this.bedNumberId="bedNum";this.headingText=e;this.moreInfo="propertyListingMoreInfo";this.carNumberId="carNum";this.titleId="listingTitle";this.propertyDescritptionId="propertyDescription";this.propertyAddressId="propertyAddress";this.propertyPriceId="propertyPrice";this.contactAddress="contactAddress";this.topPagerId="pageListSpanTop";this.topPagerListId="pageSelectListTop";this.bottomPagerId="pageListSpanBottom";this.bottomPagerListId="pageSelectListBottom";this.topSortList="topSortList";this.bottomSortList="bottomSortList";this.topSortListId="topSortListId";this.bottomSortListId="bottomSortListId";this.topPrevBtnId="topPrevNavButton";this.topNextBtnId="topNextNavButton";this.botPrevBtnId="bottomPrevNavButton";this.botNextBtnId="bottomNextNavButton";this.propertyImageId="reapFieldPropertyImage";this.propertyImageDivId="reapFieldPropertyImageDiv";this.reapFieldAgentPhotoImageId="reapFieldAgentPhotoImageId";this.createMainView();if(this.isSubView){this.createSubMainView()}else{this.clearSubMainView()}};PropertyList.prototype.createMainView=function(){var a='<div class="contentTitle">'+this.headingText+'</div>					<div class="reapPropertySearch" id="topNavSection"></div>					<div id="'+this.propertyList+'" class="reapFieldAgentProfile"></div>					<div class="reapPropetyLowerlist" id="botNavSection"></div>';this.viewParentObj.innerHTML=a};PropertyList.prototype.createSubMainView=function(){};PropertyList.prototype.createNoData=function(){document.getElementById(this.propertyList).innerHTML="<span>There is no result in this category.</span>"};PropertyList.prototype.createOptions=function(){document.getElementById("topNavSection").innerHTML='<span id="'+this.topSortList+'" style="float:left"></span>						<input type="button" id="'+this.topPrevBtnId+'" value="<<" disabled="true" />						<span id="'+this.topPagerId+'"></span>						<input type="button" id="'+this.topNextBtnId+'" value=">>" disabled="true" />';document.getElementById("botNavSection").innerHTML='<span id="'+this.bottomSortList+'" style="float:left"></span>						<input type="button" id="'+this.botPrevBtnId+'" value="<<" disabled="true" />						<span id="'+this.bottomPagerId+'"></span>						<input type="button" id="'+this.botNextBtnId+'" value=">>" disabled="true" />';this.topPrevBtn=document.getElementById(this.topPrevBtnId);this.topNextBtn=document.getElementById(this.topNextBtnId);this.botPrevBtn=document.getElementById(this.botPrevBtnId);this.botNextBtn=document.getElementById(this.botNextBtnId);this.eventHandler(this.topPrevBtn,"click","prev",this.callbackFn,this.owner);this.eventHandler(this.topNextBtn,"click","next",this.callbackFn,this.owner);this.eventHandler(this.botPrevBtn,"click","prev",this.callbackFn,this.owner);this.eventHandler(this.botNextBtn,"click","next",this.callbackFn,this.owner)};PropertyList.prototype.clearSubMainView=function(){var a="";this.subViewParentObj.innerHTML=a};PropertyList.prototype.displayMainViewData=function(q){var n="",a="",f=q.properties;for(var g=0;g<f.length;g++){var h=f[g],k=parseInt(h.property_saleorrenttypeid),p=h.property_salepricetype||"",t=h.property_rentpricetype||"",d="";if(h.property_showprice==1){if(k==1){d="Sale: "+p+" "+(h.property_finalsaleprice||"")}else{if(k==2){d="Rent: "+t+" "+(h.property_finalrentprice||"")}else{if(k==3){d="Sale: "+p+" "+(h.property_finalsaleprice||"")+" Rent: "+t+" "+(h.property_finalrentprice||"")}}}}var s="",c=(h.property_propertysubtype||""),e=(h.property_builtupareasize+" sqft"||""),r=(h.property_inclusiontype||""),o=this.createDateFormat(h.property_createddate||"");if(o){o="Posted Date: "+o}if(h.property_development){s+=h.property_development+", "}if(h.property_suburbtype){s+=h.property_suburbtype+", "}if(h.property_town){s+=h.property_town+", "}if(h.property_statename){s+=h.property_statename}if(g%2){a+='<div class="reapPropertyRow">'}else{a+='<div class="reapPropertyRowColor">'}a+='<div id="'+this.propertyImageDivId+g+'" class="reapFieldAgentPhoto linkItem" style="height:135px;">							<img src="" id="'+this.propertyImageId+g+'"></div>						<div id="agentDescription" class="reapFiledProfileDesscription" style="width:440px;">							<div class="reapFieldAgentName">							<div class="reapPropertyLeftRow">								<span id="'+this.titleId+g+'" class="spanPaddingWithBold linkItem">'+s+'</span></div>							<div class="reapPropertyRightRow">';if(h.property_noofbedroom>0){a+='<span class="reapPropertyFeature">BED '+h.property_noofbedroom+"</span>"}if(h.property_noofbathroom>0){a+='<span class="reapPropertyFeature">BATH '+h.property_noofbathroom+"</span>"}if(h.property_noofcarparking>0){a+="<span>CAR "+h.property_noofcarparking+"</span>"}a+='</div></div>							<div class="reapFieldAgentDescription listPrice">								<span class="spanPadding">'+reapfield.addCommas(d)+'</span></div>							<div class="reapFieldAgentDescription">								<span class="spanPadding">Type: '+c+"</span></div>";if(h.property_builtupareasize&&h.property_builtupareasize!=0){a+='<div class="reapFieldAgentDescription">								<span class="spanPadding">Built Up: '+e+"</span>							</div>"}a+='<div class="reapFieldAgentDescription">								<span class="spanPadding">Finishing: '+r+'</span></div>							<div class="reapFieldAgentDescription">								<span class="spanPadding">'+o+'</span></div>							</div>							<div  class="reapPropertyRightRow"><span>								<input type="button" value="More Info" class="moreInfoBtn reapFieldCommonBtn" id="'+this.moreInfo+g+'" /></span></div>						</div></div></div>'}var j=document.getElementById(this.propertyList);j.innerHTML=a;for(var g=0;g<f.length;g++){var l="";var b=q.properties[g].images;for(var m=0;m<b.length;m++){if(b[m].pictureurl){l=b[m].pictureurl;break}else{l="data/property/NoImage.jpg"}}reapfield.ChangePhoto(l,this.propertyImageId+g,155,135)}for(var g=0;g<f.length;g++){var h=f[g];this.eventHandler(document.getElementById(this.moreInfo+g),"click",h.property_propertyid,this.callbackFn,this.owner,g);this.eventHandler(document.getElementById(this.propertyImageDivId+g),"click",h.property_propertyid,this.callbackFn,this.owner,g);this.eventHandler(document.getElementById(this.titleId+g),"click",h.property_propertyid,this.callbackFn,this.owner,g)}};PropertyList.prototype.createDateFormat=function(c){if(c){var a=new DateTimeHandler(),b=c.split(" ")[0];return a.createDate(b,"dMy")}else{return""}};PropertyList.prototype.displaySubViewData=function(a){};PropertyList.prototype.selectDropDownList=function(a,c){for(var b=0;b<a.options.length;b++){if(a.options[b].value==c){a.selectedIndex=b}}};PropertyList.prototype.createDropDownList=function(b,j,d,c,g){var e='<select name="'+c+'" id="'+c+'" class="quickSearchFields">';for(var i=0;i<b.length;i++){var a=b[i],h=a[j],f=(a[d]||"");e+='<option  value="'+h+'"';if(h==g){e+=" selected"}e+=">"+f+"</option>"}e+="</select> ";return e};PropertyList.prototype.updatePagerDropDown=function(c,d){var b=document.getElementById(this.topPagerListId),a=document.getElementById(this.bottomPagerListId);if(!b&&!a){this.createOptions();this.addSortDropDown();this.addPagerDropDown(this.owner.getPagerData(d),c,d);b=document.getElementById(this.topPagerListId);a=document.getElementById(this.bottomPagerListId)}this.selectDropDownList(b,c);this.selectDropDownList(a,c);if(c==d){this.disableNextButtons(true)}else{this.disableNextButtons(false)}this.disablePrevButtons(false)};PropertyList.prototype.addSortDropDown=function(){var b=[];b.push({id:0,sortname:"Sort By"});b.push({id:"property_saleprice",sortname:"Price"});b.push({id:"property_createddate",sortname:"Latest Entry"});b.push({id:"property_builtupareasize",sortname:"Land/builtUp Area"});var c=document.getElementById(this.topSortList);c.innerHTML=this.createDropDownList(b,"id","sortname",this.topSortListId);var a=document.getElementById(this.bottomSortList);a.innerHTML=this.createDropDownList(b,"id","sortname",this.bottomSortListId);this.eventHandler(document.getElementById(this.topSortListId),"change","",this.callbackFn,this.owner);this.eventHandler(document.getElementById(this.bottomSortListId),"change","",this.callbackFn,this.owner)};PropertyList.prototype.addPagerDropDown=function(c,b,d){var e=document.getElementById(this.topPagerId);e.innerHTML=this.createDropDownList(c,"id","text",this.topPagerListId,b);var a=document.getElementById(this.bottomPagerId);a.innerHTML=this.createDropDownList(c,"id","text",this.bottomPagerListId,b);this.eventHandler(document.getElementById(this.topPagerListId),"change","",this.callbackFn,this.owner);this.eventHandler(document.getElementById(this.bottomPagerListId),"change","",this.callbackFn,this.owner);if(b!=d){this.disableNextButtons(false)}this.disablePrevButtons(true)};PropertyList.prototype.disableNextButtons=function(a){this.topNextBtn.disabled=a;this.botNextBtn.disabled=a};PropertyList.prototype.disablePrevButtons=function(a){this.topPrevBtn.disabled=a;this.botPrevBtn.disabled=a};PropertyList.prototype.eventHandler=function(f,d,e,h,a,c){var g=this;function b(){if(f.id.indexOf(g.propertyImageDivId)>=0||f.id.indexOf(g.titleId)>=0||f.id.indexOf(g.moreInfo)>=0){h("moreInfoClick",e,a,c)}else{if(f.id==g.topPagerListId){h("pageChangeEvent",f.value,a)}else{if(f.id==g.bottomPagerListId){h("pageChangeEvent",f.value,a)}else{if(f.id==g.topSortListId){h("sortChangeEvent",f.value,a)}else{if(f.id==g.bottomSortListId){h("sortChangeEvent",f.value,a)}else{if(f.id==g.topPrevBtnId||f.id==g.topNextBtnId||f.id==g.botPrevBtnId||f.id==g.botNextBtnId){h("pageNavigateEvent",e,a)}}}}}}}reapfield.AttachEvent(f,d,b,false)};