var SavePropertyUtility=new function(){function n(n,i){if(typeof i=="undefined"&&(i=""),typeof redsso!="undefined"&&typeof window.redsso.settings!="undefined"&&window.redsso.settings.mozaic)return getAppRoot()+"/account/savepropertymozaic.html?listingId="+n+"&listingNumber="+i+"&onresize=WidgetLoginUtility.resizeoverlay";var r=t.refreshParent?"1":"0";return getAppRoot()+"/account/saveproperty.aspx?overlay=1&listingId="+n+"&onresize=WidgetLoginUtility.resizeoverlay&refreshParent="+r}var t=this;this.refreshParent=!0;this.launchOverlay=function(t,i){if($("#hiddenLink").length===0&&($("body").append("<a id='hiddenLink' class='iframe' style='display:none;'><\/a>"),console.log($("#hiddenLink").length)),$("#hiddenLink").colorbox({width:570,height:320,opacity:.7,close:"<span><\/span>",iframe:!0,scrollbars:!1,speed:0,transition:"none"}),typeof i=="undefined"&&(i=""),rbw.context.isLoggedIn()||rbw.utils.isAdminSite())$("#hiddenLink").attr("href",n(t,i)),$("#hiddenLink").click();else{if(typeof snaCreate!="undefined")return snaCreate("SavePropertyUtility.launchOverlay("+t+",'"+i+"');");WidgetLoginUtility.setSavePropertyKeys(t,i);typeof rbw.ui!="undefined"&&typeof rbw.ui.LoginSupport!="undefined"&&typeof rbw.ui.LoginSupport.loginForSaveProperty=="function"?rbw.ui.LoginSupport.loginForSaveProperty():($("#hiddenLink").attr("href",WidgetLoginUtility.getHref("login")),$("#hiddenLink").click())}};this.showSavePropertyBSModal=function(n){$("#saveproperty-modal-content").html('<iframe src="'+n+'" />');$("#modal-save-property-id").modal("show")};this.launchBootStrapOverlay=function(t,i){var u,r;if(WidgetLoginUtility._useBootstrapModal=!0,typeof i=="undefined"&&(i=""),rbw.context.isLoggedIn()||rbw.utils.isAdminSite())u=n(t,i),this.showSavePropertyBSModal(u);else{if(typeof snaCreate!="undefined")return snaCreate("SavePropertyUtility.launchBootstrapOverlay("+t+",'"+i+"');");WidgetLoginUtility.setSavePropertyKeys(t,i);typeof rbw.ui!="undefined"&&typeof rbw.ui.LoginSupport!="undefined"&&typeof rbw.ui.LoginSupport.loginForSaveProperty=="function"?rbw.ui.LoginSupport.loginForSaveProperty():(r=WidgetLoginUtility.getHref("login"),rbw.ui.ListingSearchVersion==3&&rbw.Utils.SecureHostHeader==""?this.showSavePropertyBSModal(r):window.location.href=r)}};this.saveOrUnsaveproperty=function(n,t,i,r){if(r.hasClass("active")){if(typeof i=="undefined")return;$.ajax({type:"GET",url:Utils.AppPath+"/include/ajax/api.aspx",data:"op=RemoveSavedProperty&customerListingId="+i,dataType:"json",contentType:"application/json; charset=utf-8"}).done(function(n){n!=undefined&&n.IsSuccess&&(r.removeClass("active"),r.find("span").text("Save"),$("#account-savedlistinglist").length&&location.reload())})}else this.launchBootStrapOverlay(n,t)}},SaveSearchUtility=new function(){function t(t,i,r){return getAppRoot()+"/account/savesearch.aspx?overlay=1&expandcb="+(t?1:0)+"&listing="+(i?i:"")+"&displayMode="+(r?r:"")+(n.contains("ListingSearch")?"&ListingSearchID="+n.get("ListingSearch"):"")+(n.contains("ListingSearchID")?"&ListingSearchID="+n.get("ListingSearchID"):"")+"&onresize=CustomerLogin.resizeoverlay"+(n.contains("perid")==!0&&isAdminApp()==!0?"&perid="+n.get("perid"):"")}var i=this,n;this.refreshParent=!0;n=new Querystring;this.launchOverlay=function(n,i){if($("#hiddenLink").length===0&&$("body").append("<a id='hiddenLink' class='iframe'><\/a>"),$("#hiddenLink").colorbox({width:570,height:320,opacity:.7,close:"<span><\/span>",iframe:!0,scrollbars:!1,speed:0,transition:"none"}),rbw.context.isLoggedIn()||rbw.utils.isAdminSite())$("#hiddenLink").attr("href",t(!1,n,i)),$("#hiddenLink").click();else{if(typeof snaCreate!="undefined")return snaCreate("SaveSearchUtility.launchOverlay("+n+',"'+i+'")');WidgetLoginUtility.setSaveSearchKeys(n,i);$("#hiddenLink").attr("href",WidgetLoginUtility.getHref("login"));$("#hiddenLink").click()}}},WidgetLoginUtility=new function(){function l(){return window.location.href.toString().toLowerCase().indexOf("brokeroffice.admin")>=0}var f=this,e,r,n,u,o,s,h,c,t,i=null;this.getLoginAction=function(){return i};this.setRatingKeys=function(i,f,e,o){t="rating";r=i;n=f;u=e;s=o};this.setNotesKeys=function(i,f,s,c,l,a){t="notes";e=i;r=f;n=s;o=c;h=l;u=a};this.setInrixKeys=function(){t="inrix"};this.setInrixKeys=function(n){t="inrix";i=n};this.setSavePropertyKeys=function(r,u){t="saveproperty";n=r;i="saveproperty-"+r;this._useBootstrapModal&&(i="saveproperty-bmodal-"+r);typeof u!="undefined"&&u.length&&(i+="-"+u)};this.setSaveSearchKeys=function(r,u){t="savesearch";n=r;c=u;i="savesearch"};this.loginRedirect=function(i){var f=!0,l;switch(t){case"rating":$(document.body).trigger("SetRatingAfterRedirect",[{listingNumber:r,listingId:n,customerListingId:u,ratingValue:s}]);break;case"notes":f=!1;l=new rbw.ui.HistoryNotes;l.saveNote(e,n,o,0,r,h).done(function(){parent.window.location.href=window.location.href});break;case"inrix":$(document.body).trigger("SetInrixAfterRedirect",[]);break;case"saveproperty":f=!1;this._useBootstrapModal?SavePropertyUtility.launchBootStrapOverlay(n,r):SavePropertyUtility.launchOverlay(n);break;case"savesearch":f=!1;SaveSearchUtility.launchOverlay(n,c)}typeof Search!="undefined"?($(document).trigger("loginupdate",[{isLoggedIn:!0,loginName:i,canReloadView:!0}]),$(".iframe").colorbox.close()):typeof redirectToOnSuccessPage!="undefined"&&typeof redirectToOnSuccessPage=="function"?redirectToOnSuccessPage():f&&(parent.window.location.href=window.location.href)};this.register=function(){$("#hiddenLink").attr("href",WidgetLoginUtility.getHref("signup"));$("#hiddenLink").click()};this.signin=function(){$("#hiddenLink").attr("href",WidgetLoginUtility.getHref("login"));$("#hiddenLink").click()};this.getAppRoot=function(){return l()?"/brokeroffice.admin/agent/public":rbw.context.siteUrl};this.getHref=function(n){return this.getAppRoot()+"/account/"+n+".aspx?formtype="+n+"&onregister=WidgetLoginUtility.register&onsignin=WidgetLoginUtility.signin&onresize=WidgetLoginUtility.resizeoverlay&onloginsuccess=WidgetLoginUtility.loginRedirect&onsuccess="+this.getOnSuccess(!0)};this.resizeoverlay=function(n,t){$("#cboxIframe").css("width",n+"px");$("#cboxIframe").css("height",t+"px");$("#cboxLoadedContent").css("width",n+"px");$("#cboxLoadedContent").css("height",t+"px");$("#hiddenLink").colorbox.resize({innerWidth:n,innerHeight:t});f.overlayTopPosition&&setTimeout(function(){$("#colorbox").css("top",parseInt(f.overlayTopPosition)+"px")},10)};this.getOnSuccess=function(n){var t=CurrentUrl.getRedirectParams(i);return n?encodeURIComponent(encodeURIComponent(window.location.href)+t):window.location.href+decodeURIComponent(decodeURIComponent(t))}},CustomerLogin=new function(){function p(){return h===null&&(h=window.location.href.toLowerCase().indexOf("savesearch.aspx")>=0),h}function u(n,i){var r="CustomerLogin.showlogininfo";return i&&(r="CustomerLogin.closeOverlay"),getAppRoot()+"/account/"+n+".aspx?formtype="+n+"&onregister=CustomerLogin.register&onsignin=CustomerLogin.signin&onresize=CustomerLogin.resizeoverlay&onloginsuccess="+r+(t.contains("embed")?"&embed="+t.get("embed"):"")+"&onsuccess="+a(!0)}function a(t){var i=CurrentUrl.getRedirectParams(n);return t?encodeURIComponent(encodeURIComponent(window.location.href)+i):window.location.href+decodeURIComponent(decodeURIComponent(i))}function f(){return typeof r!="undefined"&&typeof r.firstName!="undefined"&&r.firstName!=""?!0:!1}function o(){return isAdminApp()&&readCookie("rBW-ListingSearch")!=""?!0:!1}function s(n){return getAppRoot()+"/account/savesearch.aspx?overlay=1&expandcb="+(n?1:0)+(t.contains("ListingSearch")?"&ListingSearchID="+t.get("ListingSearch"):"")+(t.contains("ListingSearchID")?"&ListingSearchID="+t.get("ListingSearchID"):"")+"&onresize=CustomerLogin.resizeoverlay"+(t.contains("perid")==!0&&isAdminApp()==!0?"&perid="+t.get("perid"):"")+(t.contains("savedSearchTypeId")?"&savedSearchTypeId="+t.get("savedSearchTypeId"):"")}function l(n,i){return(typeof i=="undefined"&&(i=""),typeof redsso!="undefined"&&typeof window.redsso.settings!="undefined"&&window.redsso.settings.mozaic)?getAppRoot()+"/account/savepropertymozaic.html?listingId="+n+"&listingNumber="+i+"&onresize=CustomerLogin.resizeoverlay":getAppRoot()+"/account/saveproperty.aspx?overlay=1&listingId="+n+"&listingNumber="+i+"&onresize=CustomerLogin.resizeoverlay"+(t.contains("perid")==!0&&isAdminApp()==!0?"&perid="+t.get("perid"):"")+"&refreshParent=1"}function v(){var i,f;if(n!=null){if(i=function(){var n=function(){$("#hiddenLink").click()};if(c){$(document).one("cbox_closed",n);$("#cboxContent #cboxClose").length>0&&$("#cboxContent #cboxClose").click()}else n()},n.toLowerCase()==="savesearchv3")$(document).on("init-search-options-modal",function(){CustomerLogin.saveSearch()});if(n.toLowerCase()==="launchsearchcriteriabox")$(document).one("maploaded",InrixDriveTimeUtility.launchSearchcriteriaBox);if(n.toLowerCase()=="savesearch"&&($("#hiddenLink").attr("href",s(!1)),i()),n.toLowerCase()=="getalerts"&&($("#hiddenLink").attr("href",s(!0)),i()),n.toLowerCase().indexOf("saveproperty-bmodal")!==-1){var t=n.split("-"),u=t[2],r="";t.length>3&&(r=t[3]);f=l(u,r);SavePropertyUtility.showSavePropertyBSModal(f)}else if(n.toLowerCase().indexOf("saveproperty")!==-1){var t=n.split("-"),u=t[1],r="";t.length>2&&(r=t[2]);$("#hiddenLink").attr("href",l(u,r));i()}n=null}}function w(n,t,i){$(".modal:visible").modal("hide");t||(n=!0);n?window.location.reload():t&&(window.location.href=i)}function b(){return}function y(){}function k(n){var f=$(window).height()-50,i=$(n),e=$(i.find("html")),r=$(i.find("body")),o=$(i.find("#Master_Viewport")),s=$("> .popupContainer",r),t=Math.max(e.outerHeight(),r.outerHeight(),o.outerHeight(),s.outerHeight())+18,u=Math.max(e.outerWidth(),r.outerWidth(),o.outerWidth(),s.outerWidth())+18;t>f&&(t=f);$("#colorbox").height(t+153);$("#cboxWrapper").height(t+100);$("#cboxContent, #cboxMiddleLeft, #cboxMiddleRight").height(t+50);$(".cboxiframe, #cboxLoadedContent").height(t);$("#colorbox, #cboxWrapper").css({minWidth:u+50});$(".cboxIframe, #cboxContent, #cboxTopCenter, #cboxBottomCenter, #cboxLoadedContent").css({minWidth:u});$(".cboxIframe").colorbox.resize({innerWidth:u,innerHeight:t})}function d(s){var l,a;$(window).resize(y);$(document).bind("cbox_complete",function(){document.location.href.contains("recolorado")||y()});var h=$('[data-loginoverlaytype="fixed"]'),w=h.length>0,k=h.length>0?h.attr("data-loginoverlaytop"):!1;r=s;l=!0;$("#customer-login").length===0&&(l=!1,$("body").append("<div id='customer-login' style='display:none'><\/div>"));$("#hidden-link").length===0&&$("#customer-login").append('<a id="hiddenLink" class="iframe"><\/a>');$("#customer-login-register").length===0&&$("#customer-login").append('<a id="customer-login-register" href="#" class="iframe"><\/a>');$("#customer-login-sigin").length===0&&$("#customer-login").append('<a id="customer-login-signin" href="#" class="iframe"><\/a>');$(document).bind("cbox_open",function(){c=!0;$("body").css("overflow","hidden")});$(document).bind("cbox_closed",function(){c=!1;$("body").css("overflow","auto")});$(document).bind("loginupdate",function(t,i){if(!i.reloadPage||typeof customLoggedinAction=="function"||window.location.reload(),i.isLoggedIn){if(r.firstName=i.loginName,$("#customer-login .welcome h2 span").html(i.loginName),e.TargetAreaSearch&&(e.TargetAreaSearch.isTargetArea||e.TargetAreaSearch.enrolledInMarketWatch)?($(".customerLoggedIn").hide(),$(".customerLoggedOff").hide(),$(".customerTargetAreaSearch").show()):($(".customerLoggedIn").show(),$(".customerLoggedOff").hide(),$(".customerTargetAreaSearch").hide()),$("a[href*='/Account/CustomerLogout.aspx']").show(),$("div[role='navigation']").attr("class")!=undefined){var u=$("div[role='navigation']").attr("class").split(" ")[0];$("div[role='navigation']").load(location.href+" ."+u)}typeof customLoggedinAction=="function"&&customLoggedinAction(i.loginName);n?v():$(".iframe").colorbox.close()}else r.firstName="",$("#customer-login .welcome h2 span").html(""),$(".customerLoggedIn").hide(),$(".customerLoggedOff").show(),$(".customerTargetAreaSearch").hide(),$("a[href*='/Account/CustomerLogout.aspx']").hide()});$(window).resize(function(){b()});$("#mapsearch-left-customer").css("height","auto");$("#customerLoginSpinner").fadeOut();$(".customer-login-spinner").fadeOut();f()?i.showlogininfo(r.firstName):o()?(i.hideLoginInfo(),$("#customer-login-welcome").hide(),$(".secondary-nav").hide()):i.hideLoginInfo();l&&$("#customer-login").show();$("#customer-login-register").attr("href",u("signup"));$("#customer-login-signin").attr("href",u("login"));$(".iframe").colorbox({width:"400",height:"200",iframe:!0,close:"",fixed:w,top:k});$().bind("cbox_load",function(){$("#cboxIframe").attr("scrolling","yes");setTimeout(function(){$("#cboxClose span").css("display","block")},1e3)});$().bind("cbox_complete",function(){});a=!1;$(document).bind("criteriachange",function(n,i){a||(e.load(i.activeTab),t.contains("ListingSearch")&&$("#search-summary h2").after("<p class='saved-search-info'>You are viewing a saved search<\/p>").hide().show("fast"),a=!0)});p()&&($("#customer-login-signout").hide(),$("#save-search-link").hide(),$("#email-alert-link").hide());f()&&t.contains("nextaction")&&(n=t.get("nextaction"),v())}var i=this,r,n=null,h=null,c=!1,t=new Querystring,e=new SearchSummary;this.SearchSummary=e;this.savedSearchWindowName=null;this.overlayTopPosition=null;this.test=function(){alert("inside")};this.getHref=u;this.isLoggedIn=f;this.isProxyLoggedIn=o;this.getLoginAction=function(){return n};this.redirectToSucessPage=w;this.showlogininfo=function(n,t){$(document).trigger("loginupdate",[{isLoggedIn:!0,loginName:n,canReloadView:!0,reloadPage:t}])};this.closeOverlay=function(){this.showlogininfo();$("#search-options-modal .close").click()};this.hideLoginInfo=function(){var n=typeof vowStatusId!="undefined"&&(window.vowStatusId===1||window.vowStatusId===4);$(document).trigger("loginupdate",[{isLoggedIn:!1,canReloadView:!0,reloadPage:n}])};this.saveSearch=function(){function t(){var n=$(".search-numresults-number:first").text()||$(".mapsearch-count-total:first").text()||$(".mapsearch-results-paging-properties:first").text();return n!==""?parseInt(n.replace(/,/g,"")):0}var i=t();if(i>1e5){alert("Your search returned too many properties and can not be saved. Please filter your search to narrow your results.");return}if(f()||o())$("#hiddenLink").attr("href",s(!1)),$("#hiddenLink").click();else{if(typeof snaCreate!="undefined")return snaCreate("CustomerLogin.saveSearch();");n="SaveSearch";typeof rbw.ui!="undefined"&&typeof rbw.ui.LoginSupport!="undefined"&&typeof rbw.ui.LoginSupport.loginForSaveSearch=="function"?rbw.ui.LoginSupport.loginForSaveSearch({onSuccess:a(!1)}):($("#hiddenLink").attr("href",u("login")),$("#hiddenLink").click())}};this.saveProperty=function(t,i){if(typeof i=="undefined"&&(i=""),f()||o())$("#hiddenLink").attr("href",l(t,i)),$("#hiddenLink").click();else{if(typeof snaCreate!="undefined")return snaCreate("CustomerLogin.saveProperty("+t+",'"+i+"');");n="SaveProperty-"+t+(i.length>0?"-"+i:"");$("#hiddenLink").attr("href",u("login"));$("#hiddenLink").click()}};this.getEmailAlerts=function(){f()||o()?($("#hiddenLink").attr("href",s(!0)),$("#hiddenLink").click()):(n="GetAlerts",$("#hiddenLink").attr("href",u("login")),$("#hiddenLink").click())};this.myDashboard=function(){window.location.href="/account/customerhome.aspx"};this.mySavedSearches=function(){var n=getAppRoot()+"/account/savedsearchlist.aspx";typeof i.savedSearchWindowName!="undefined"&&i.savedSearchWindowName?window.open(n,i.savedSearchWindowName):window.location.href=n};this.mySavedProperties=function(){window.location.href=getAppRoot()+"/account/savedlistinglist.aspx"};this.register=function(){rbw.ui.ListingSearchVersion!=3&&$("#customer-login-register").click()};this.signin=function(t,i,r){if(t&&t.gotoBrokerSignInPage&&rbw.context.siteUrl&&rbw.context.siteUrl.indexOf("http")>-1){var f=t.referer?t.referer:"";location.href=rbw.context.siteUrl+"/account/customerlogin.aspx?referer="+encodeURIComponent(f)}else rbw.ui.ListingSearchVersion==3?($("#hiddenLink").attr("href",u("login",r)),$("#hiddenLink").click()):(typeof i!="undefined"&&(n=i),$("#customer-login-signin").click())};this.load=function(n){d(n)};this.signOut=function(){$("#customer-login iframe").length==0&&$("#customer-login").append("<iframe name='customerLogoffFrame' style='display:none' onload='CustomerLogin.hideLoginInfo();' />");window.open(getAppRoot()+"/account/customerlogout.aspx","customerLogoffFrame")};this.resizeoverlay=function(){return};this.repositionOverlay=function(){i.overlayTopPosition&&setTimeout(function(){$("#colorbox").css("top",parseInt(i.overlayTopPosition)+"px")},10)};this.resizeModal=function(n){typeof sm3!="undefined"&&$(".modal-body iframe[src*='login'], .modal-body iframe[src*='signup']").length?sm3.resizeModalByIframe(n):k(n)}}