function SearchAgentListHandler(){this.myId;this.myView;this.container;this.isSubView=false;this.currentPage=1;this.rowsOnPage=10;this.totalPages=0;this.totalRecords=0;this.myView=new SearchAgentList(this.callbackHandlerFn,this);this.init()}SearchAgentListHandler.prototype.loadView=function(c,a,b){this.myId=c;this.viewContainer=a;this.subViewContainer=b;this.myView.initialize(this.viewContainer,this.subViewContainer,this.isSubView,this);reapfield.G_API.getAreaListData();reapfield.G_API.getOfficeListData()};SearchAgentListHandler.prototype.init=function(){reapfield.G_EventMgr.registerEvent("AreaListData",this,"AreaListDataListener");reapfield.G_EventMgr.registerEvent("OfficeListData",this,"OfficeListDataListener");reapfield.G_EventMgr.registerEvent("AgentListData",this,"AgentListDataListener")};SearchAgentListHandler.prototype.AreaListDataListener=function(b){var a=b.data;a.splice(0,0,{suburb_suburbid:"0",suburb_suburbtype:"Search By Area"});document.getElementById(this.myView.areaListDiv).innerHTML=this.myView.createDropDownList(a,"suburb_suburbid","suburb_suburbtype",this.myView.areaSearchCombo,0)};SearchAgentListHandler.prototype.OfficeListDataListener=function(b){var a=b.data;a.splice(0,0,{branch_branchid:"0",branch_branchname:"Search By Office"});document.getElementById(this.myView.officeListDiv).innerHTML=this.myView.createDropDownList(a,"branch_branchid","branch_branchname",this.myView.officeSearchCombo,0)};SearchAgentListHandler.prototype.AgentListDataListener=function(b){this.currentPage=b.data.page;this.totalPages=b.data.total;this.totalRecords=b.data.records;var a=b.data.agents;if(a.length>0){this.myView.displayMainViewData(a);this.myView.displaySubViewData(a);if(this.currentPage==1){this.myView.createPagers(this.getPagetData(this.totalPages),this.currentPage,this.totalPages)}else{this.myView.updatePagerDropDown(this.currentPage,this.totalPages)}}else{this.myView.displayNotFoundMessage();this.myView.removePagers()}reapfield.G_ViewMgr.fixFooterHeight()};SearchAgentListHandler.prototype.getPagetData=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};SearchAgentListHandler.prototype.loadDetailData=function(a){};SearchAgentListHandler.prototype.callbackHandlerFn=function(d,c,a){if(d=="moreInfoClick"){var b={moduleId:"41",detailId:c};reapfield.G_EventMgr.fireEvent("loadModuleEvent",b)}else{if(d=="pageChangeEvent"){a.currentPage=c;reapfield.G_API.searchAgent(a.getQueryObject())}else{if(d=="pageNavigateEvent"){if(c=="prev"){a.currentPage--}else{if(c=="next"){a.currentPage++}}reapfield.G_API.searchAgent(a.getQueryObject())}else{a.setQueryObject(d,c);reapfield.G_API.searchAgent(a.getQueryObject())}}}};SearchAgentListHandler.prototype.getQueryObject=function(){this.queryObj.curPage=this.currentPage;this.queryObj.noRows=this.rowsOnPage;return this.queryObj};SearchAgentListHandler.prototype.setQueryObject=function(b,a){this.queryObj={};if(b=="namesearchclick"){this.queryObj.searchField="user_username"}else{if(b=="areasearchclick"){this.queryObj.searchField="user_suburbid"}else{if(b=="officesearchclick"){this.queryObj.searchField="user_branchid"}}}this.currentPage=1;this.queryObj.searchValue=a};function SearchAgentList(b,a){this.owner=a;this.callbackFn=b}SearchAgentList.prototype.initialize=function(d,b,c,a){this.viewParentObj=d||document.body;this.subViewParentObj=b||document.body;this.isSubView=c;this.nameSearchText="namesearchText";this.officeListDiv="officeListDiv";this.areaListDiv="areaListDiv";this.nameSearch="nameSearch";this.areaSearch="areaSearch";this.officeSearch="officeSearch";this.areaSearchCombo="areaSearchCombo";this.officeSearchCombo="officeSearchCombo";this.AgentList="AgentList";this.moreUserInfo="moreUserInfo";this.formAgentId="formAgentId";this.formSuburbId="formSuburbId";this.formBranchId="formBranchId";this.topPagerDivId="agentTopPagerDiv";this.topPagerListId="agentTopPagerList";this.topPrevBtnId="agentTopPreviousBtn";this.topNextBtnId="agentTopNextBtn";this.botPagerDivId="agentBottomPagerDiv";this.botPagerListId="agentBottomPagerList";this.botPrevBtnId="agentBottomPreviousBtn";this.botNextBtnId="agentBottomNextBtn";this.topPagerId="topPager";this.botPagerId="bottomPager";this.reapFieldAgentPhotoImageList="reapFieldAgentPhotoImageList";this.reapFieldAgentPhotoImageId="reapFieldAgentPhotoImageId";this.createMainView();if(this.isSubView){this.createSubMainView()}else{this.clearSubMainView()}};SearchAgentList.prototype.createMainView=function(){var a='<!--div class="contentTitle">Find negotiator search results</div-->					<div class="contentTitle reapFieldSearchField">Find a sales agent</div>                    <div class="reapFieldSearchField"><form name="'+this.formAgentId+'" id="'+this.formAgentId+'"><input class="quickSearchFields reapFieldSearchText"   type="text" id="'+this.nameSearchText+'"/><input type="submit" id="'+this.nameSearch+'" class="reapFieldCommonBtn reapFieldSearchBtn"  value="go" /></form></div>                    <div class="reapFieldSearchField"><form name="'+this.formSuburbId+'" id="'+this.formSuburbId+'"><div id="'+this.areaListDiv+'" class="reapFieldAgentSearch" style="vertical-align:middle;"><select name="areaSearchCombo" id="areaSearchCombo" ><option value="">-- Please Select --</option></select></div><div class="reapFieldAgentSearch"><input type="submit" id="'+this.areaSearch+'" class="reapFieldCommonBtn reapFieldSearchBtn"  value="go" /></div></form></div>                    <div class="reapFieldSearchField" style="clear:both"><form name="'+this.formBranchId+'" id="'+this.formBranchId+'"><div id="'+this.officeListDiv+'" class="reapFieldAgentSearch"><select name="officeSearchCombo" id="officeSearchCombo" style="width:auto !important"><option value="">-- Please Select --</option></select></div><div style="float:left;"><input type="submit" id="'+this.officeSearch+'" class="reapFieldCommonBtn reapFieldSearchBtn"  value="go" /></div></form></div>					<div id="'+this.topPagerDivId+'" class="pagerDiv reapPropertySearch"></div>					<div id="'+this.AgentList+'" class="reapFieldAgentProfile"></div>					<div id="'+this.botPagerDivId+'" class="pagerDiv"></div>					<div class="reapPropetyLowerlist">                                        </div>';this.viewParentObj.innerHTML=a;reapfield.G_ViewMgr.fixFooterHeight();this.eventHandler(document.getElementById(this.formAgentId),"","submit",this.callbackFn,this.owner,this.nameSearch);this.eventHandler(document.getElementById(this.formSuburbId),"","submit",this.callbackFn,this.owner,this.areaSearch);this.eventHandler(document.getElementById(this.formBranchId),"","submit",this.callbackFn,this.owner,this.officeSearch)};SearchAgentList.prototype.createPagers=function(d,c,e){var a='	<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(this.topPagerDivId).innerHTML=a;var f='	<input type="button" id="'+this.botPrevBtnId+'" value="<<" disabled="true" />						<span id="'+this.botPagerId+'"></span>						<input type="button" id="'+this.botNextBtnId+'" value=">>" disabled="true" />';document.getElementById(this.botPagerDivId).innerHTML=f;var g=document.getElementById(this.topPagerId);g.innerHTML=this.createDropDownList(d,"id","text",this.topPagerListId,c);var b=document.getElementById(this.botPagerId);b.innerHTML=this.createDropDownList(d,"id","text",this.botPagerListId,c);this.eventHandler(document.getElementById(this.topPagerListId),"","change",this.callbackFn,this.owner);this.eventHandler(document.getElementById(this.botPagerListId),"","change",this.callbackFn,this.owner);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,"prev","click",this.callbackFn,this.owner);this.eventHandler(this.topNextBtn,"next","click",this.callbackFn,this.owner);this.eventHandler(this.botPrevBtn,"prev","click",this.callbackFn,this.owner);this.eventHandler(this.botNextBtn,"next","click",this.callbackFn,this.owner);if(c!=e){this.disableNextButtons(false)}this.disablePrevButtons(true)};SearchAgentList.prototype.updatePagerDropDown=function(a,b){this.selectDropDownList(document.getElementById(this.topPagerListId),a);this.selectDropDownList(document.getElementById(this.botPagerListId),a);if(a==b){this.disableNextButtons(true)}else{this.disableNextButtons(false)}this.disablePrevButtons(false)};SearchAgentList.prototype.disableNextButtons=function(a){this.topNextBtn.disabled=a;this.botNextBtn.disabled=a};SearchAgentList.prototype.disablePrevButtons=function(a){this.topPrevBtn.disabled=a;this.botPrevBtn.disabled=a};SearchAgentList.prototype.removePagers=function(){document.getElementById(this.topPagerDivId).innerHTML="";document.getElementById(this.botPagerDivId).innerHTML=""};SearchAgentList.prototype.createSubMainView=function(){};SearchAgentList.prototype.clearSubMainView=function(){var a="";this.subViewParentObj.innerHTML=a};SearchAgentList.prototype.displayMainViewData=function(d){var f="";for(var c=0;c<d.length;c++){if(c%2){f+='<div class="reapPropertyRow">'}else{f+='<div class="reapPropertyRowColor">'}f+='<div id="'+this.reapFieldAgentPhotoImageList+c+'" class="reapFieldAgentPhoto linkItem" style="height:135px;">';f+='<img src="" id="'+this.reapFieldAgentPhotoImageId+c+'"></div>';f+='<div id="agentDescription" class="reapFiledProfileDesscription" style="width:440px;">		<div class="reapFieldAgentName">		<span  class="reapPropertyLocation">'+(d[c].user_fname||"")+" "+(d[c].user_lname||"")+'</span>		</div>		<div class="reapFiledResidence" style="width:160px;">'+(d[c].user_town||"")+'</div>		<div class="reapFieldAgentDescription agentDescription">'+(d[c].user_aboutme||"")+'		</div>		<div class="reapAgentMoreinfo">		<span><input type="button" value="More Info" class="moreInfoBtn reapFieldCommonBtn" id='+this.moreUserInfo+c+" /></span>		</div></div></div>"}var g=document.getElementById(this.AgentList);g.innerHTML=f;for(var c=0;c<d.length;c++){var e=d[c].user_picturelocation||"";if(!e){e="data/user/noimage.jpg"}this.ChangePhoto(e,this.reapFieldAgentPhotoImageId+c,155,145)}for(var c=0;c<d.length;c++){var b=d[c].user_emailid.split("@");var a=b[0];this.eventHandler(document.getElementById(this.moreUserInfo+c),a,"click",this.callbackFn,this.owner,this.moreUserInfo);this.eventHandler(document.getElementById(this.reapFieldAgentPhotoImageList+c),a,"click",this.callbackFn,this.owner,this.reapFieldAgentPhotoImageList)}};SearchAgentList.prototype.createDropDownList=function(b,j,d,c,h){var e='<select name="'+c+'" id="'+c+'" class="findNegList">';for(var i=0;i<b.length;i++){var a=b[i],g=a[j],f=(a[d]||"");e+='<option  value="'+g+'"';if(g==h){e+=" selected"}e+=">"+f+"</option>"}e+="</select> ";return e};SearchAgentList.prototype.selectDropDownList=function(a,c){for(var b=0;b<a.options.length;b++){if(a.options[b].value==c){a.selectedIndex=b}}};SearchAgentList.prototype.displayNotFoundMessage=function(){var a=document.getElementById(this.AgentList);a.innerHTML="<span class='noresultMessage'>There were no negotiators that met your search criteria.</span><br><span class='noresultMessage'>Please refine your search and try again.</span>"};SearchAgentList.prototype.displaySubViewData=function(a){};SearchAgentList.prototype.eventHandler=function(f,e,c,h,a,b){var g=this;function d(i){if(f.id==g.formAgentId){e=document.getElementById(g.nameSearchText).value;if(e.length>=3){h("namesearchclick",e,a)}else{f.innerHTML+="<span>Please enter at least 3 characters.</span>"}}else{if(f.id==g.formSuburbId){e=document.getElementById(g.areaSearchCombo).value;h("areasearchclick",e,a)}else{if(f.id==g.formBranchId){e=document.getElementById(g.officeSearchCombo).value;h("officesearchclick",e,a)}else{if(b==g.moreUserInfo||b==g.reapFieldAgentPhotoImageList){h("moreInfoClick",e,a)}else{if(f.id==g.topPagerListId||f.id==g.botPagerListId){h("pageChangeEvent",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)}}}}}}if(i.preventDefault){i.preventDefault()}i.returnValue=false}reapfield.AttachEvent(f,c,d,false)};SearchAgentList.prototype.ChangePhoto=function(c,b,e,d){if(!c||c==""){document.getElementById(b).parentNode.innerHTML="";return}var a=document.createElement("img");a.onload=function(){var h=a.width,g=a.height;var k=(e?e:100);var j=(d?d:100);if(h>=g){var f=g*k/h;if(f<=j){j=f}else{k=h*j/g}}else{tmpx=h*j/g;if(tmpx<=k){k=tmpx}else{j=g*k/h}}var i=document.getElementById(b);i.src=a.src;i.style.height=j+"px";i.style.width=k+"px";i.parentNode.style.backgroundColor="transparent"};a.src=reapfield.G_API.webServiceURL+c};