Type.registerNamespace("Masahati.Search");Masahati.Search.SearchView=function(a){Masahati.Search.SearchView.initializeBase(this,[a]);this._resultsSummaryId=null;this._siteUrl="";this._editMode=false;this._propertyInfoId=null;this._properties=[];this._currentProperty=null;this._firstSearch=true;this._alerts=[]};Masahati.Search.SearchView.prototype={initalize:function(){Masahati.Search.SearchView.callBaseMethod(this,"initalize")},loadAlerts:function(){if(this._editMode){this._alerts=[];Masahati.Services.PropertyService.GetAlerts(this.succeededCallback,this.failedCallback,this)}},listProperty:function(b){if(this._editMode){var a=Sys.CultureInfo.CurrentCulture.name.substring(0,2);Masahati.Services.PropertyService.GetProperty(b,a,this.succeededCallback,this.failedCallback,this)}},checkStatus:function(a){if(this.isListed(a)||this.isListingDeactived(a))Masahati.Services.PropertyService.ListDelistProperty(a.Id,this.succeededCallback,this.failedCallback,this);else window.location=this._siteUrl+"clients/management/listproperty.aspx?property_id="+a.PropertyData.Id},succeededCallback:function(b,a,c){switch(c){case"GetAlerts":a.setAlerts(b);break;case"GetProperty":a.checkStatus(b);break;case"ListDelistProperty":a.updateProperty(b);break;case"GetUnitSummary":case"GetVacantUnitSummary":a.setUnitSummary(b)}},failedCallback:function(){},getUnitSummary:function(a){if(this._editMode)Masahati.Services.PropertyService.GetUnitSummary(a,this.succeededCallback,this.failedCallback,this);else Masahati.Services.PropertyService.GetVacantUnitSummary(a,this.succeededCallback,this.failedCallback,this)},getUnitSummaryHTML:function(c){for(var a="",b=0;b<c.length;b++){a+="<div class='unit-summary-container'><div class='unit-summary-price'>";if(c[b].DisplayPrice){if(c[b].MinPrice>0||c[b].MaxPrice>0)a+=c[b].PriceRange;a+="</div><div class='unit-summary-area'>";if(c[b].MinArea>0||c[b].MaxArea>0){a+="<strong>"+Masahati.Globalisation.SquareMetres+"</strong>: ";a+=c[b].MinArea;if(c[b].IsMinAreaTheSameAsMaxArea)a+=" ";else a+=" - "+c[b].MaxArea}}else a+=Masahati.Globalisation.PriceUponRequest;a+="</div>";a+="<div class='unit-summary-bedrooms'>";if(c[b].Bedrooms>0)a+="<strong>"+Masahati.Globalisation.Bedrooms+"</strong>: "+c[b].Bedrooms+" ";a+="</div>";a+="</div>"}return a},setAlerts:function(a){if(this._editMode)this._alerts=a},getAlertSummary:function(f){for(var d=false,e=false,c=0,g=this._alerts.length,b=0;b<g;b++)if(this._alerts[b].PropertyId==f)switch(this._alerts[b].AlertType){case 0:d=true;break;case 1:c++;break;case 2:e=true}var a="";if(d)a=Masahati.Globalisation.ListingDueToExpire;if(e){if(a)a+="<br />";a+=Masahati.Globalisation.ListingExpired}if(c){if(a)a+="<br />";a+=Masahati.Globalisation.TenantsContractsDueToExpiry.replace("[NumberOfTenants]",c)}return a},hasAlerts:function(b){for(var c=this._alerts.length,a=0;a<c;a++)if(this._alerts[a].PropertyId==b)return true;return false},viewFullInformation:function(a){this._currentProperty=this.getPropertyById(a);this._currentProperty&&this._addRecentlyViewedProperty(a);$find(this._propertyInfoId).showInfo(a)},getPropertyById:function(b){for(var c=this._properties.length,a=0;a<c;a++)if(this._properties[a].Id==b)return this._properties[a];return null},_addRecentlyViewedProperty:function(c){var a=Sys.Services.ProfileService.properties.RecentlyViewedPropertyIds;a[a.length]=c;for(var b=0;b<a.length-1;b++)a[b]==c&&a.splice(b,1);a.length>20&&a.splice(0,a.length-1);Sys.Services.ProfileService.properties.RecentlyViewedPropertyIds=a;Sys.Services.ProfileService.save(["RecentlyViewedPropertyIds"]);$find(this._clipboardId)&&$find(this._clipboardId).refreshProperties()},saveProperty:function(a){Masahati.Search.PropertySearch.saveProperty(a);$find(this._clipboardId)&&$find(this._clipboardId).refreshProperties();$find(this._confirmationControlId).setMessage(Masahati.Globalisation.PropertySaved);$find(this._confirmationControlId).showConfirmation()},showResults:function(a){this._properties=a;if(a.length)this.displayResults();else{$find(this._confirmationControlId).setMessage(Masahati.Globalisation.NoResultsFound);$find(this._confirmationControlId).showConfirmation()}},clearResults:function(){if($find(this._propertyInfoId)&&!this._firstSearch)$find(this._propertyInfoId).closePanel();else if(this._firstSearch)this._firstSearch=false;this._properties=[]},getSaleTypeName:function(a){switch(a){case 1:return Masahati.Globalisation.Sale;case 2:return Masahati.Globalisation.Rent;case 3:return Masahati.Globalisation.Personal;default:return""}},isListed:function(a){var b=a.PropertyData.LastListedDate;return b&&a.PropertyData.IsListingActive&&a.IsListed?true:false},isListingDeactived:function(a){var b=a.PropertyData.LastListedDate;return b&&!a.PropertyData.IsListingActive&&a.IsListed?true:false},isOccupied:function(a){return a.PropertyData.IsOccupied},isVacant:function(a){return!this.isOccupied(a)},isPersonal:function(a){return a.SaleType==3},isEmptyBuilding:function(a){return a.SubPropertyType!=0&&a.PropertyData.NoOfUnits==0},getImageCss:function(a){if(this._editMode){if(this.isPersonal(a.PropertyData))return"personal-image-border";else if(this.isListed(a))return"listed-image-border";else if(this.isEmptyBuilding(a))return"empty-image-border";else if(this.isVacant(a))return"vacant-image-border";else if(this.isOccupied(a))return"occupied-image-border"}else return"occupied-highlight";return""},getTitleCss:function(a){if(this._editMode){if(this.isPersonal(a.PropertyData))return"personal-highlight";else if(this.isListed(a))return"listed-highlight";else if(this.isEmptyBuilding(a))return"empty-highlight";else if(this.isVacant(a))return"vacant-highlight";else if(this.isOccupied(a))return"occupied-highlight"}else return"occupied-highlight";return""},getViewPropertyLink:function(a){return this._editMode?this._siteUrl+"clients/management/editproperty.aspx?property_id="+a:"javascript: $find( '"+this._id+"' ).viewFullInformation( "+a+" );"},getOrderBy:function(){return 1},getOrderDirection:function(){return 0},getPrice:function(a){return a.PriceRange},set_resultsSummaryId:function(a){this._resultsSummaryId=a},get_resultsSummaryId:function(){return this._resultsSummaryId},set_siteUrl:function(a){this._siteUrl=a},get_siteUrl:function(){return this._siteUrl},set_editMode:function(a){this._editMode=a},get_editMode:function(){return this._editMode},get_propertyInfoId:function(){return this._propertyInfoId},set_propertyInfoId:function(a){this._propertyInfoId=a},set_clipboardId:function(a){this._clipboardId=a},get_clipboardId:function(){return this._clipboardId},get_confirmationControlId:function(){return this._confirmationControlId},set_confirmationControlId:function(a){this._confirmationControlId=a},dispose:function(){this._resultsSummaryId=null;this._siteUrl="";this._editMode=false;this._propertyInfoId=null;this._properties=[];Masahati.Search.SearchView.callBaseMethod(this,"dispose")}};Masahati.Search.SearchView.registerClass("Masahati.Search.SearchView",Sys.Component,Sys.IDisposable,Masahati.Search.IResultView);
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();