function reapfieldAPI(){this.webServiceURL="http://www.reapfield.com/webservice/";this.propertyTypeList=[];this.propertySubTypeList=[];this.directionTypeList=[];this.menus=[];this.subMenus=[];this.nRecord;this.maxRecords;this.maxPages;this.queryType="";this.searchQuery="";this.curView="";this.curPage="";this.maxRows="";this.sortField="";this.isBackEvent=true}reapfieldAPI.prototype.getBackgroundImage=function(){var a=this.webServiceURL+"getbackgroundimage?callback=reapfield.G_API.getBackgroundImageCallback";this.JSONscriptRequest(a)};reapfieldAPI.prototype.getBackgroundImageCallback=function(a){reapfield.G_EventMgr.fireEvent("backGroundImage",a.response)};reapfieldAPI.prototype.getMenus=function(){var a=this.webServiceURL+"listexternalmenuitems?callback=reapfield.G_API.menuItemsCallback";this.JSONscriptRequest(a)};reapfieldAPI.prototype.menuItemsCallback=function(a){if(a.success){this.menus=a.response.menus;this.subMenus=a.response.submenus;reapfield.G_EventMgr.fireEvent("menuItemList",true)}};reapfieldAPI.prototype.getAllStateList=function(b){var c=1;var a=this.webServiceURL+"liststates?country_countryid="+c+"&callback=reapfield.G_API.statesAllListCallback";this.JSONscriptRequest(a)};reapfieldAPI.prototype.statesAllListCallback=function(a){if(a.response){reapfield.G_EventMgr.fireEvent("allStatesListArrived",a.response)}};reapfieldAPI.prototype.getAllCallByPropertySuburbList=function(b){var a=this.webServiceURL+"listsuburbs?state_stateid="+b+"&callback=reapfield.G_API.suburbAllForPropertyListCallback";this.JSONscriptRequest(a)};reapfieldAPI.prototype.suburbAllForPropertyListCallback=function(a){if(a.response){reapfield.G_EventMgr.fireEvent("allSuburbListForpropertyArrived",a.response)}};reapfieldAPI.prototype.emailToFriend=function(d,c,b){var a=this.webServiceURL+"sendemail?callback=reapfield.G_API.emailToFriendCallback&emailto="+c+"&emailfrom="+d+"&emailcontent="+b;this.JSONscriptRequest(a)};reapfieldAPI.prototype.emailToFriendCallback=function(a){reapfield.G_EventMgr.fireEvent("mailSent",a.response)};reapfieldAPI.prototype.authorizeUser=function(){var a=[{id:"1",name:"Add Group"},{id:"2",name:"Edit Group Rights"},{id:"3",name:"Add User"},{id:"4",name:"Edit User"},{id:"5",name:"Add Property"},{id:"6",name:"Archive Property"},{id:"11",name:"Add Contact"}];this.userRights=a;return true};reapfieldAPI.prototype.loginDefaultUser=function(){var a=this.webServiceURL+"login?user_emailid=externaluser@reapfield.com&user_password=123&callback=reapfield.G_API.loginCallback";this.JSONscriptRequest(a)};reapfieldAPI.prototype.loginCallback=function(a){if(!this.parseError(a)){this.getMenus();this.getAllPropertyTypesList();this.getlistallpropertysubtypes()}};reapfieldAPI.prototype.getUserProfileData=function(c,a){var b=this.webServiceURL+"getmemberforexternal?user_userid="+c+"&callback=reapfield.G_API.userProfileCallback";this.JSONscriptRequest(b)};reapfieldAPI.prototype.userProfileCallback=function(a){reapfield.G_EventMgr.fireEvent("userProfileData",a.response)};reapfieldAPI.prototype.getPropertyListData=function(d,e,b,a){this.queryType="listing";this.curView=d;this.curPage=e;this.maxRows=b;this.sortField=a;var c=this.webServiceURL+"listpropertiesforexternal?callback=reapfield.G_API.propertyListCallback"+this.createListingQuery(false);this.JSONscriptRequest(c)};reapfieldAPI.prototype.propertyListCallback=function(a){if(a.response){reapfield.G_API.maxRecords=a.response.records;reapfield.G_API.maxPages=a.response.total;reapfield.G_EventMgr.fireEvent("propertyListData",a.response)}};reapfieldAPI.prototype.getPropertySearchResultListData=function(b){this.queryType="search";this.searchQuery=b;this.curPage=b.page;this.maxRows=b.rows;this.sortField=b.sidx;var a=this.webServiceURL+"searchpropertiesforexternal?callback=reapfield.G_API.getPropertySearchResultListDataCallback";a+=this.createSearchQuery(this.searchQuery);this.JSONscriptRequest(a)};reapfieldAPI.prototype.getPropertySearchResultListDataCallback=function(a){if(a.response){reapfield.G_API.maxRecords=a.response.records;reapfield.G_API.maxPages=a.response.total;reapfield.G_EventMgr.fireEvent("getPropertySearchResultListDataArrived",a.response)}};reapfieldAPI.prototype.getPropertyDetailData=function(c,a){var b=this.webServiceURL+"getpropertyforexternal?property_propertyid="+c+"&callback=reapfield.G_API.propertyDetailCallback";if(a){var d=this.getPropertyQueryInfo();b+="&nav="+a+"&querytype="+this.queryType+d}this.JSONscriptRequest(b)};reapfieldAPI.prototype.propertyDetailCallback=function(a){reapfield.G_EventMgr.fireEvent("propertyDetailData",a.response)};reapfieldAPI.prototype.getPropertyListDataForAgent=function(e,f,c,b,a){this.queryType="agentlisting";this.curView=e;this.curPage=f;this.maxRows=c;this.sortField=b;this.agentId=a;var d=this.webServiceURL+"listpropertiesofagentforexternal?callback=reapfield.G_API.propertyListForAgentCallback"+this.createListingQuery(true);this.JSONscriptRequest(d)};reapfieldAPI.prototype.propertyListForAgentCallback=function(a){if(a.response){reapfield.G_API.maxRecords=a.response.records;reapfield.G_API.maxPages=a.response.total;reapfield.G_EventMgr.fireEvent("propertyListDataForAgent",a.response)}};reapfieldAPI.prototype.createListingQuery=function(a){var b="&listingtype="+this.curView+this.getPageAndSortInfo();if(a){b+="&userid="+this.agentId}return b};reapfieldAPI.prototype.createSearchQuery=function(b){var a="";if(b.searchOption){a+="&saleorrenttypeid="+b.searchOption}if(b.locationKeyword){a+="&location="+b.locationKeyword}if(b.propertyType){a+="&propertytypeid="+b.propertyType}if(b.propertySubType){a+="&propertysubtypeid="+b.propertySubType}if(parseInt(b.searchPriceFrom)>0){a+="&pricefrom="+b.searchPriceFrom}if(parseInt(b.searchPriceTo)>0){a+="&priceto="+b.searchPriceTo}if(b.directiontype){a+="&directiontypeid="+b.directiontype}if(b.noOfBed){a+="&noofbedroom="+b.noOfBed}if(b.noOfBath){a+="&noofbathroom="+b.noOfBath}if(b.builtUpArea){a+="&builtupareasize="+b.builtUpArea}if(b.stateId){a+="&stateid="+b.stateId}if(b.statesuburbId){a+="&suburbid="+b.statesuburbId}a+=this.getPageAndSortInfo();return a};reapfieldAPI.prototype.getPageAndSortInfo=function(){var a="";if(this.curPage&&this.maxRows){a="&page="+this.curPage+"&rows="+this.maxRows}if(this.sortField){a+="&sidx="+this.sortField+"&sord=DESC"}return a};reapfieldAPI.prototype.getPropertyQueryInfo=function(){var a="";if(this.queryType=="listing"){a=this.createListingQuery(false)}else{if(this.queryType=="agentlisting"){a=this.createListingQuery(true)}else{if(this.queryType=="search"){a=this.createSearchQuery(this.searchQuery)}}}return a};reapfieldAPI.prototype.getNewPropertiesListData=function(c,a){var b=this.webServiceURL+"getdevelopment?page="+c+"&rows="+a+"&callback=reapfield.G_API.newPropertyListCallback";this.JSONscriptRequest(b)};reapfieldAPI.prototype.newPropertyListCallback=function(a){reapfield.G_EventMgr.fireEvent("NewPropertiesListData",a.response)};reapfieldAPI.prototype.getNewPropertyDetailData=function(b){var a=this.webServiceURL+"getdevelopment?develpoment_developmentid="+b+"&callback=reapfield.G_API.newPropertyDetailCallback";this.JSONscriptRequest(a)};reapfieldAPI.prototype.newPropertyDetailCallback=function(a){reapfield.G_EventMgr.fireEvent("NewPropertyDetailData",a.response)};reapfieldAPI.prototype.getAllDirectionTypesList=function(){var a=this.webServiceURL+"listdirectiontypes?callback=reapfield.G_API.directionTypesAllListCallback";this.JSONscriptRequest(a)};reapfieldAPI.prototype.directionTypesAllListCallback=function(a){if(a.response){this.directionTypeList=a.response}reapfield.G_EventMgr.fireEvent("allDirectionTypesListArrived",a.response)};reapfieldAPI.prototype.getAreaListData=function(){var a=this.webServiceURL+"listallsuburbs?callback=reapfield.G_API.allSuburbListCallback";this.JSONscriptRequest(a)};reapfieldAPI.prototype.allSuburbListCallback=function(a){reapfield.G_EventMgr.fireEvent("AreaListData",a.response)};reapfieldAPI.prototype.getPropertyTypeListData=function(){var a=this.webServiceURL+"listallsuburbs?callback=reapfield.G_API.getPropertyTypeListDataCallback";this.JSONscriptRequest(a)};reapfieldAPI.prototype.getPropertyTypeListDataCallback=function(a){if(a.response){this.propertyTypeList=a.response}reapfield.G_EventMgr.fireEvent("getPropertyTypeListDataEvents",a.response)};reapfieldAPI.prototype.getlistallpropertysubtypes=function(){var a=this.webServiceURL+"listallpropertysubtypes?callback=reapfield.G_API.listallpropertysubtypesCallback";this.JSONscriptRequest(a)};reapfieldAPI.prototype.listallpropertysubtypesCallback=function(a){if(a.response){this.propertySubTypeList=a.response}reapfield.G_EventMgr.fireEvent("getPropertySubTypeListDataEvents",a.response)};reapfieldAPI.prototype.getAllPropertyTypesList=function(){var a=this.webServiceURL+"listpropertytypes?callback=reapfield.G_API.propertyTypesAllListCallback";this.JSONscriptRequest(a)};reapfieldAPI.prototype.propertyTypesAllListCallback=function(a){reapfield.G_EventMgr.fireEvent("allPropertyTypesListArrived",a.response)};reapfieldAPI.prototype.listPropertySubTypes=function(b){var a=this.webServiceURL+"listpropertysubtypes?propertytype_propertytypeid="+b+"&callback=reapfield.G_API.propertySubTypesListCallback";this.JSONscriptRequest(a)};reapfieldAPI.prototype.propertySubTypesListCallback=function(a){reapfield.G_EventMgr.fireEvent("propertySubTypesListArrived",a.response)};reapfieldAPI.prototype.getOfficeListData=function(){var a=this.webServiceURL+"listbranches?callback=reapfield.G_API.OfficeListCallback";this.JSONscriptRequest(a)};reapfieldAPI.prototype.OfficeListCallback=function(a){if(a.response){reapfield.G_EventMgr.fireEvent("OfficeListData",a.response)}};reapfieldAPI.prototype.searchAgent=function(b){var a=this.webServiceURL+"searchnegotiatorsforexternal?"+b.searchField+"="+b.searchValue+"&page="+b.curPage+"&rows="+b.noRows+"&callback=reapfield.G_API.getSearchedAgentCallback";this.JSONscriptRequest(a)};reapfieldAPI.prototype.getSearchedAgentCallback=function(a){reapfield.G_EventMgr.fireEvent("AgentListData",a.response)};reapfieldAPI.prototype.getAgentListData=function(){var a=this.webServiceURL+"listmembersforexternal?&callback=reapfield.G_API.AgentListCallback";this.JSONscriptRequest(a)};reapfieldAPI.prototype.AgentListCallback=function(a){reapfield.G_EventMgr.fireEvent("AgentListData",a.response)};reapfieldAPI.prototype.getPageContent=function(a){var b=this.webServiceURL+"getcmsdata?callback=reapfield.G_API.getPageContentCallback&cmsdata_cmsdataid="+a;this.JSONscriptRequest(b)};reapfieldAPI.prototype.getPageContentCallback=function(a){reapfield.G_EventMgr.fireEvent("pageContentArrived",a.response)};reapfieldAPI.prototype.parseError=function(a){if(!a.success){return true}return false};reapfieldAPI.prototype.JSONscriptRequest=function(a){var b="&noCacheIE="+(new Date()).getTime();headLoc=document.getElementsByTagName("head").item(0);scriptObj=document.createElement("script");scriptObj.setAttribute("type","text/javascript");scriptObj.setAttribute("charset","utf-8");scriptObj.setAttribute("src",a+b);headLoc.appendChild(scriptObj)};