function SerialiseLocationPreferences(n,t){var i="";return $("#LocationsDetailHiddenContainer"+n+" .selectedLocationDetailItemHidden").each(function(t,r){i+="SL["+t+"].Distance="+$("#locationDistanceTextbox"+n,r).val()+"&";i+="SL["+t+"].Name="+encodeURIComponent($("#locationAreaTextbox"+n,r).val())+"&";i+="SL["+t+"].Latitude="+$("#locationLatitudeTextbox"+n,r).val()+"&";i+="SL["+t+"].Longitude="+$("#locationLongitudeTextbox"+n,r).val()+"&"}),i+="PreferedLocationName="+encodeURIComponent($("#PreferedLocationName"+n).val())+"&",i+="PreferedLocationDistance="+$("#PreferedLocationDistance"+n).val(),i+="&DisplayMode="+$("#LocationPreferenceDisplayModeHidden"+n).val(),i+="&Prefix="+$("#LocationPreferencePrefixHidden"+n).val(),i+="&SearchInAreaOnly="+$("#LocationPreferenceSearchInAreaOnlyHidden"+n).val(),$("#LocationCoordinateHidden"+n).length!=0&&(i+="&PreferedLocationCoordinates="+$("#LocationCoordinateHidden"+n).val()),t==!0&&(i+="&AddNewLocation=true"),i}var myToDoList=function(){var n=function(){propertySearch&&propertySearch.panel&&$.isFunction(propertySearch.panel.hidePanel)&&propertySearch.panel.hidePanel()};return{listExists:function(){return $(".myToDoList").length>0},isListVisible:function(){return $(".myToDoList :visible").length>0},showList:function(){myToDoList.listExists()||myToDoList.loadList();n();$(".myToDoList").stop().slideDown()},hideList:function(){$(".myToDoList").stop().slideUp()},loadList:function(){callServerWithOptions({url:"/MyToDoList/GetLoggedInMyToDoList",success:function(n){var t=$.parseHTML(n);$(t).hide().insertBefore("div#BodyContainer");$("#CloseToDoList").click(function(){myToDoList.isListVisible()&&myToDoList.hideList()});myToDoList.showList()},error:function(){$("#errorModal").modal("show")},preventAppendLastUpdateValues:!0})}}}(),locationPreferenceEdited,AbritasLocationPreference,propertySearch;$(document).ready(function(){$("#NavitemToDo").click(function(){return myToDoList.isListVisible()?myToDoList.hideList():myToDoList.showList(),!1})});locationPreferenceEdited=!1;AbritasLocationPreference=function(){var n=function(n){return $("#LocationsDetailHiddenContainer"+n+" .selectedLocationDetailItemHidden").length>0},t=function(n){return $("#LocationsDetailHiddenContainer"+n).length>0};return{getLocationSuccess:function(n){locationPreferenceEdited==!0&&($("#LocationSearchPreferenceSummaryContainer"+n).empty(),$("#LocationsSummaryHiddenContainer"+n).empty(),$("#LocationsDetailHiddenContainer"+n).empty(),locationPreferenceEdited=!1)},SetupPlugin:function(i){$('div[id^="LocationsSummaryHiddenContainer"]').hide();$("#LocationCoordinateHidden"+i).val(null);$("#ValidationMessages"+i).empty();t(i)&&!n(i)&&$("#LocationPreferenceContainer_"+i).siblings(".search-actions").hide();$(".SummaryDetailHover").popover({animation:!0,html:!0,placement:"right",trigger:"hover",title:$("#LocationsSummaryHiddenContainer"+i).data("title"),content:$("#LocationsSummaryHiddenContainer"+i).html()});$("body").off(".LocationPreference");$("body").on("click.LocationPreference",".EditSearchLocationPreference",function(n){n.preventDefault();AbritasLocationPreference.editLocations($(n.target).data("prefix"))});$("body").on("click.LocationPreference","#MultipleLocationResultsContainer .locationPreferenceRow",function(n){n.preventDefault();AbritasLocationPreference.selectFromMultipleLocation($(n.target).data("prefix"),$(n.target))});$("body").on("click.LocationPreference",'INPUT[id^="LocationPreferenceSubmitButton"]',function(n){n.preventDefault();AbritasLocationPreference.getLocationData($(n.target).data("prefix"),!0)});$("body").on("click.LocationPreference","a.removePreferedLocationLink",function(n){n.preventDefault();AbritasLocationPreference.removedPreferedLocation($(n.target).data("prefix"),$(this))});$("body").on("change.LocationPreference",'SELECT[id^="SelectedLocationDistance_"]',function(n){n.preventDefault();AbritasLocationPreference.updateDistance($(n.target).parents(".locationDistance").data("prefix"),$(this),$(this).parents(".locationEditPreferenceRow").data("key"))})},editLocations:function(n){var t=SerialiseLocationPreferences(n);callServer("/LocationPreference/EditLocationDetails",t,function(n){var t=$($.parseHTML(n));$("#TempModalBodyClass").append(t);$(".EditLocationModalClose").click(function(n){n.preventDefault();AbritasLocationPreference.editLocationModalClose($(n.target).data("prefix"))})},function(){$("#errorModal").modal("show")},"GET")},editLocationModalClose:function(n){locationPreferenceEdited==!0&&($("#PreferedLocationName"+n).val(null),$("#LocationCoordinateHidden"+n).val(null),AbritasLocationPreference.getLocationData(n))},removedPreferedLocation:function(n,t){locationPreferenceEdited=!0;$("div[data-key='"+$(t).data("key")+"']").each(function(){$(this).remove()});$("#NationalMXLocationDetailsEditContainer .locationEditPreferenceRow").length==0&&($("#DialogContainerId").modal("hide"),AbritasLocationPreference.editLocationModalClose(n))},selectFromMultipleLocation:function(n,t){$("#LocationCoordinateHidden"+n).val($(t).data("locationcoordinate"));$("#DialogContainerId").modal("hide");AbritasLocationPreference.getLocationData(n)},updateDistance:function(n,t,i){$("div[data-key='"+i+"'] #locationDistanceTextbox"+n).val(t.val());locationPreferenceEdited=!0},getLocationData:function(n,t){var i=SerialiseLocationPreferences(n,t);callServer("/LocationPreference/GetLocation",i,function(t){var i=$($.parseHTML(t)),r;$(i).find("#MultipleLocationResultsContainer").length?($("#TempModalBodyClass").append(i),$("#DialogContainerId").modal("show")):(AbritasLocationPreference.getLocationSuccess(),$("#LocationPreferenceResultContainer"+n).replaceWith(i),$(".search-actions").slideDown(),r=$('INPUT[id^="PreferedLocationNameFormMode"]'),r.length>0&&r.focus());AbritasLocationPreference.SetupPlugin(n)},function(){$("#errorModal").modal("show")},"GET")}}}();$(document).ready(function(){AbritasLocationPreference.SetupPlugin("FormMode")});propertySearch=function(){var t=!1,i={searchTabLink:"searchTabLink",searchTabContainer:"searchTabContainer",tabContentContainer:"tab-content",searchContentContainer:"searchContentContainer",activeTab:"active"},n={propertySearchPanelLink:"SearchPanelLink",closeSearchPanel:"closeSearchPanel",searchForm:"SearchForm",searchPanelContent:"SearchPanelContentContainer"},f=function(n){return n.data("url")},r=function(n){return n.data("searchtab")},u=!1;return{localSearch:{setMultipleLocationFocus:function(){if(!u){$("#DialogContainerId").on("hidden",function(){$('INPUT[id^="PreferedLocationNameSearchMode"]:visible').length?$('INPUT[id^="PreferedLocationNameSearchMode"]').focus():$('#LocationBar INPUT[id^="AttemptedLocationName"]:visible').length?$('#LocationBar INPUT[id^="AttemptedLocationName"]').focus():$("#AttemptedLocationName").focus()});u=!0}},setupLocalSearchTab:function(n){$("form#propertySearchSearchForm",n).submit(function(){return propertySearch.localSearch.performSearch()});$("#MultipleLocationResultsContainer_SearchMode .locationPreferenceRow",n).click(function(n){n.preventDefault();var t=$(n.target);$("#AttemptedLocationName").val(t.text());$("input[name='AttemptedLocationLongitude']").val(t.data("locationlongitude"));$("input[name='AttemptedLocationLatitude']").val(t.data("locationlatitude"));$("#DialogContainerId").modal("hide");$("#AttemptedLocationName").focus()});propertySearch.localSearch.setMultipleLocationFocus()},performSearch:function(){$("form#propertySearchSearchForm input.btnSubmit").attr("disabled","disabled");var t=$("form#propertySearchSearchForm").serialize();return callServer("/PropertySearch/Results",t,function(t){var i=$($.parseHTML(t)),r,u;i.find("form#propertySearchSearchForm").length&&(propertySearch.localSearch.setupLocalSearchTab(i),$("#PropertySearch"+n.searchPanelContent).replaceWith(i),r=$("#MultipleLocationResultsContainer_SearchMode",$("#PropertySearch"+n.searchPanelContent)),r.length>0&&(r.appendTo($("#TempModalBodyClass")),$("#DialogContainerId").modal("show")),$("form#propertySearchSearchForm input.btnSubmit").removeAttr("disabled"),u=$('INPUT[id^="AttemptedLocationName"]'),u.length>0&&u.focus())},function(){$("form#propertySearch"+n.searchForm+" input.btnSubmit").removeAttr("disabled");$("#errorModal").modal("show")},"GET"),!1}},recentLetsSearch:{setup:function(){$("body").on("click",'li.lettingCycle a[id^="LettingCycle"]',function(n){return $("#RecentLetsOfferDateRange\\.FromDate_Day").val($(n.target).data("fromday")),$("#RecentLetsOfferDateRange\\.FromDate_Month").val($(n.target).data("frommonth")),$("#RecentLetsOfferDateRange\\.FromDate_Year").val($(n.target).data("fromyear")),$("#RecentLetsOfferDateRange\\.ToDate_Day").val($(n.target).data("today")),$("#RecentLetsOfferDateRange\\.ToDate_Month").val($(n.target).data("tomonth")),$("#RecentLetsOfferDateRange\\.ToDate_Year").val($(n.target).data("toyear")),$("#DialogContainerId").modal("hide"),!1})},setupRecentLetsSearchTab:function(n){$("form#recentLetsSearchForm",n).submit(function(){return propertySearch.recentLetsSearch.performSearch()})},performSearch:function(){$("form#recentLetsSearchForm input.btnSubmit").attr("disabled","disabled");var t=$("form#recentLetsSearchForm").serialize();return callServer("/RecentLets/Results",t,function(t){var i=$($.parseHTML(t));$(i).find("form#recentLetsSearchForm").length&&(propertySearch.recentLetsSearch.setupRecentLetsSearchTab(i),$("#RecentLets"+n.searchPanelContent).replaceWith(i),$("form#recentLets"+n.searchForm+" input.btnSubmit").removeAttr("disabled"))},function(){$("form#recentLets"+n.searchForm+" input.btnSubmit").removeAttr("disabled");$("#errorModal").modal("show")},"GET"),!1}},nationalMXSearch:{setupNationalMXSearchTab:function(t){$("form#nationalMX"+n.searchForm,t).submit(function(){return propertySearch.nationalMXSearch.performSearch()});$("#RemoveSearchFromSessionLink",t).click(function(n){n.preventDefault();propertySearch.nationalMXSearch.resetNationalMXTabContent($('a[data-searchtab="NationalMX"]'))});AbritasLocationPreference.SetupPlugin()},resetNationalMXTabContent:function(t){var i="/NationalMX/ResetSearchValues";i!=null&&callServer(i,null,function(i){var r=$($.parseHTML(i));propertySearch.tabs.setupTab(t,r);$("#NationalMX"+n.searchPanelContent).replaceWith(r);propertySearch.tabs.postLoad(t)},function(){$("#errorModal").modal("show")})},performSearch:function(){$("form#nationalMXSearchForm input.btnSubmit").attr("disabled","disabled");var t=$("form#nationalMXSearchForm").serialize();return callServer("/NationalMX/SearchResults",t,function(t){var i=$($.parseHTML(t));i.find("form#nationalMXSearchForm").length&&(propertySearch.nationalMXSearch.setupNationalMXSearchTab(i),$("#NationalMX"+n.searchPanelContent).replaceWith(i),$("form#nationalMXSearchForm input.btnSubmit").removeAttr("disabled"),AbritasLocationPreference.SetupPlugin())},function(){$("form#nationalMXSearchForm input.btnSubmit").removeAttr("disabled");$("#errorModal").modal("show")},"GET"),!1}},panel:{setupPanel:function(t){$("div#"+n.closeSearchPanel+" > a",t).click(propertySearch.panel.togglePanel).show();$("form.propertySearchPanel",t).removeAttr("action");$('a.searchTabLink[data-toggle="tab"]',t).on("show",propertySearch.tabs.getTabContent)},togglePanel:function(){return t==!1&&$("div#PanelSearchAndToDo").children().length==0?(t=!0,callServerWithOptions({url:"/Search/PropertySearchPanel/",success:function(n){var t=$($.parseHTML(n));propertySearch.panel.hideMyToDoListIfRequired();$("div#PanelSearchAndToDo",t).collapse("show");propertySearch.panel.setupPanel(t);t.insertBefore("div#BodyContainer");$("li."+i.activeTab+' a.searchTabLink[data-toggle="tab"]',t).trigger("show")},error:function(){$("#errorModal").modal("show");t=!1},preventAppendLastUpdateValues:!0})):(propertySearch.panel.hideMyToDoListIfRequired(),$("div#PanelSearchAndToDo").stop().collapse("toggle")),!1},hideMyToDoListIfRequired:function(){myToDoList&&$.isFunction(myToDoList.hideList)&&myToDoList.hideList()},hidePanel:function(){var n=$("div#PanelSearchAndToDo");n.is(":visible")&&n.height()>0&&$("div#PanelSearchAndToDo").stop().collapse("hide")}},tabs:{getTabContent:function(n){var t=$(n.target),e=r(t),u=$("#"+e),i;u.html()||(i=f(t),i!=null&&callServerWithOptions({url:i,success:function(n){var i=$($.parseHTML(n));propertySearch.tabs.setupTab(t,i);u.html(i);propertySearch.tabs.postLoad(t);$(".detect-browser-ie-legacy #PageContainer").addClass("forceiepaint").removeClass("forceiepaint")},error:function(){$("#errorModal").modal("show")},preventAppendLastUpdateValues:!0}))},setupTab:function(n,t){switch(n.data("searchtab")){case"AdvertisedProperty":propertySearch.localSearch.setupLocalSearchTab(t);break;case"RecentLets":propertySearch.recentLetsSearch.setupRecentLetsSearchTab(t);break;case"NationalMX":propertySearch.nationalMXSearch.setupNationalMXSearchTab(t)}},postLoad:function(n){var t=r(n);switch(t){case"NationalMX":AbritasLocationPreference.SetupPlugin("SearchMode")}}},setup:function(){$("a#"+n.propertySearchPanelLink).click(function(n){n.preventDefault();propertySearch.panel.togglePanel()});$("#PanelSearchAndToDo").each(function(){propertySearch.panel.setupPanel($(this))});var r=$("#PropertySearch");r.length>0&&(t=!0,propertySearch.panel.setupPanel(r),$("li."+i.activeTab+' a.searchTabLink[data-toggle="tab"]').trigger("show"));this.recentLetsSearch.setup()}}}();$(document).ready(function(){propertySearch.setup()})