if(!MlsSettings)var MlsSettings={AUTH:{LoginURI:"CLAW.Security.AuthServer",TokenAPI:"token",LoginContactAPI:"/Dashboards",LoginAgentAPI:"/Signin/login",CookieDomain:"themls.com",CookiePath:"/",Mode:2,Legacy:!0,Social:!1,WithCredentials:!0,InhibitRefresh:!1,ClientId:"",UserKey:"USERNAME",AuthKey:"MLS-AUTH",ExpKey:"MLS-EXP",IdentityKey:"MLS-IDENTITY",LoginKey:"MLS-LOGIN",AccountKey:"MLS-ACCT",DashKey:"MLS-DASH",IdentityAgent:"agent",IdentityContact:"contact",SessionCheckInterval:1e3,PublicList:["VestaPlusHelp","Survey","Forms","Caravan"],EnvNameList:["dev","sprint2","sprint","qa","demo"],EnvUrlList:["www.dev.themls.com","www.sprint2.themls.com","www.sprint.themls.com","www.qa.themls.com","www.demo.themls.com"],RootUrl:"www.themls.com",PollAuthInterval:5,InhibitRedirectHeader:"inhibit_redirect_unauthorized"},EVENT:{loginRequired:"auth-login-required",loginConfirmed:"auth-login-confirmed",loginCancelled:"auth-login-cancelled",windowRegister:"win-child-register",windowUnregister:"win-child-unregister",windowClose:"win-close",sessionTimeout:"session-timeout",sessionTerminated:"mlsauthlogoutsession"},MLS:{CLAW:{Name:"CLAW",Login:"/"},PS:{Name:"PS",Login:"/loginPalmSprings/"},ICAOR:{Name:"IMPERIAL",Login:"/loginICAOR/"}},IsAuthModeToken:function(){return 1===this.AUTH.Mode},IsAuthModeCookie:function(){return 2===this.AUTH.Mode}}; if(!MlsTools)var MlsTools=function(){var e={};return{SendRequest:function(e,t,n,i,o){var r=new XMLHttpRequest;"function"==typeof o&&(r.onreadystatechange=o),i?r.open(e,t):r.open(e,t,!1),r.withCredentials=!0,r.setRequestHeader("Access-Control-Allow-Origin","*"),n?(r.setRequestHeader("Content-Type","application/json; charset=utf-8"),r.send(JSON.stringify(n))):r.send()},PostForm:function(e,t,n){n=n||"post";var i=document.createElement("form");for(var o in i.setAttribute("method",n),i.setAttribute("action",e),t)if(t.hasOwnProperty(o)){var r=document.createElement("input");r.setAttribute("type","hidden"),r.setAttribute("name",o),r.setAttribute("value",t[o]),i.appendChild(r)}document.body.appendChild(i),i.submit()},IsModule:function(e){if(angular)try{return angular.module(e),!0}catch(e){}return!1},DefineModule:function(e){angular&&!this.IsModule(e)&&angular.module(e,[])},EnableLogger:function(t){t||(t="log"),e[t]&&(window.console[t]=e[t],delete e[t])},DisableLogger:function(t){t||(t="log"),e[t]=console[t],window.console[t]=function(){}},GetAppElement:function(e){return angular&&e?angular.element($("[ng-app]")):window.document.querySelector("[ng-app]")},GetAppAttribute:function(e){var t=this.GetAppElement();return t?t.getAttribute(e):null},GetAppName:function(e){var t=this.GetAppElement(e);return 1==t.length?t[0].getAttribute("ng-app"):""},GetOS:function(){var e="Unknown OS";return-1!=navigator.appVersion.indexOf("Win")?e="Windows":-1!=navigator.appVersion.indexOf("Mac")?e="MacOS":-1!=navigator.appVersion.indexOf("X11")?e="UNIX":-1!=navigator.appVersion.indexOf("Linux")&&(e="Linux"),e},GetBrowser:function(){var e,t,n,i=navigator.appVersion,o=navigator.appName,r=navigator.userAgent,a=o,s=""+parseFloat(i),c=parseInt(i,10);return-1!=(t=r.indexOf("Opera"))?(a="Opera",s=r.substring(t+6),-1!=(t=r.indexOf("Version"))&&(s=r.substring(t+8))):-1!=(t=r.indexOf("MSIE"))?(a="Microsoft Internet Explorer",s=r.substring(t+5)):-1!=(t=r.indexOf("Chrome"))?(a="Chrome",s=r.substring(t+7)):-1!=(t=r.indexOf("Safari"))?(a="Safari",s=r.substring(t+7),-1!=(t=r.indexOf("Version"))&&(s=r.substring(t+8))):-1!=(t=r.indexOf("Firefox"))?(a="Firefox",s=r.substring(t+8)):(e=r.lastIndexOf(" ")+1)<(t=r.lastIndexOf("/"))&&(a=r.substring(e,t),s=r.substring(t+1),a.toLowerCase()==a.toUpperCase()&&(a=o)),-1!=(n=s.indexOf(";"))&&(s=s.substring(0,n)),-1!=(n=s.indexOf(" "))&&(s=s.substring(0,n)),c=parseInt(""+s,10),isNaN(c)&&(s=""+parseFloat(i),c=parseInt(i,10)),{BrowserName:a,FullVersion:s,MajorVersion:c}},IsMobile:function(){var e=navigator.userAgent;return e.match(/Android/i)||e.match(/webOS/i)||e.match(/iPhone/i)||e.match(/iPad/i)||e.match(/iPod/i)||e.match(/BlackBerry/i)||e.match(/Windows Phone/i)},IsMobileDevice:function(){var e,t=!1;return e=navigator.userAgent||navigator.vendor||window.opera,(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,4)))&&(t=!0),t},MobileCheck:{IsPhone:function(){return navigator.userAgent.match(/Phone/i)},IsAndroid:function(){return navigator.userAgent.match(/Android/i)},IsBlackBerry:function(){return navigator.userAgent.match(/BlackBerry/i)},IsiOS:function(){return navigator.userAgent.match(/iPhone|iPad|iPod/i)},IsOpera:function(){return navigator.userAgent.match(/Opera Mini/i)},IsWindows:function(){return navigator.userAgent.match(/IEMobile/i)},IsAny:function(){return MlsTools.MobileCheck.IsAndroid()||MlsTools.MobileCheck.IsBlackBerry()||MlsTools.MobileCheck.IsiOS()||MlsTools.MobileCheck.IsOpera()||MlsTools.MobileCheck.IsWindows()}},ValidateEmail:function(e){return/^[_a-zA-Z0-9]+(\.[_a-zA-Z0-9]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,4})$/.test(e)},GetQueryString:function(e,t){e=e.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var n=new RegExp("[\\?&]"+e+"=([^&#]*)").exec(window.location.search);return null===n?"":decodeURIComponent(n[1].replace(/\+/g," "))},GetCookie:function(e){var t=window.document.cookie.match("(^|;)\\s*"+e+"\\s*=\\s*([^;]+)");return t?t.pop():""},SetCookie:function(e,t,n,i,o){o=";domain="+(o||".themls.com"),i=";path="+(i||"/");var r="";if(!isNaN(n)){var a=new Date;a.setTime(a.getTime()+60*n*1e3),r=";expires="+a.toUTCString()}var s=e+"="+encodeURIComponent(t)+o+i+r;window.document.cookie=s},EraseCookie:function(e,t,n){this.SetCookie(e,"",-10,t,n)},TryParseJson:function(e){try{return JSON.parse(e)}catch(e){return null}},Intercept:function(e,t,n,i){var o=e[t];Object.defineProperty(e,t,{get:function(){return i&&"function"==typeof n&&n(),o},set:function(e){return"function"==typeof n&&n(e,o),o=e}})},GetOpener:function(e,t){var n=null;try{e||(e=window),t||(t=MlsSettings.AUTH.CookieDomain),e.opener&&!e.opener.closed&&e.opener.location.origin.endsWith(t)&&(n=e.opener)}catch(e){n=null}return n},ResolveHostURL:function(e){var t=window.location.host;if(t.indexOf("local")<0){t=MlsSettings.AUTH.RootUrl;for(var n=0;n=0){t=MlsSettings.AUTH.EnvUrlList[n];break}}t=window.location.protocol+"//"+t,e=e||"/";try{return new URL(e,t)}catch(n){return-1!==t.indexOf("/",this.length-"/".length)?t+"/"+e:t+e}},ResolveURL:function(e,t){return e||(e="/"),e.startsWith("http")?e:(e.startsWith("/")||(e=`/${e}`),t?`${location.origin}${e}`:e)},JoinURL:function(e,t){if(!e)return t;if(!t||"/"===t)return e;if(/^http[s]?:\/\//i.test(t))return t;return e+(/\/$/.test(e)||/^\//.test(t)?"":"/")+t}}}(); if(!MlsUser)var MlsUser={FindLoginUrl:function(t){return this.GetLoginUrl(t)},GetLoginUrl:function(t){var e=window.localStorage.getItem(MlsSettings.AUTH.LoginKey),o=this.GetExpiration("LoginURL")||e;if(!o){var n=this.GetIdentity(null,!0);if(t||(t=n?n.IdentityType:window.authIdentityType),t===MlsSettings.AUTH.IdentityContact)o=MlsSettings.AUTH.LoginContactAPI;else switch(n&&n.Info?n.Info.MYMLS:""){case MlsSettings.MLS.PS.Name:o=MlsSettings.MLS.PS.Login;break;case MlsSettings.MLS.ICAOR.Name:o=MlsSettings.MLS.ICAOR.Login;break;default:o=MlsSettings.AUTH.LoginAgentAPI||MlsSettings.MLS.CLAW.Login}}return o!=e&&this.SetLoginUrl(o),o},SetLoginUrl:function(t){localStorage.setItem(MlsSettings.AUTH.LoginKey,t),MlsSettings.AUTH.LoginAgentAPI=t},GetLandingUrl:function(){return this.GetIdentity("LandingURL")},HasAuth:function(){return!!MlsTools.GetCookie(MlsSettings.AUTH.AuthKey)},ClearAuth:function(){MlsTools.EraseCookie(MlsSettings.AUTH.AuthKey,MlsSettings.AUTH.CookiePath,MlsSettings.AUTH.CookieDomain),MlsTools.EraseCookie(MlsSettings.AUTH.ExpKey,MlsSettings.AUTH.CookiePath,MlsSettings.AUTH.CookieDomain),console.log("Authentication data cleared")},IsAuthenticated:function(t){var e=this.GetIdentityType();return!((t?e!==t:!e)||e!==MlsSettings.AUTH.IdentityAgent&&!this.GetContactAccount())},IsAuthorized:function(t,e){var o=this.HasAuth(),n=this.IsAuthenticated(t);return!(!n||!o)||(e&&(n=this.IsAuthenticated())!=o&&this.Logout(!1,!0),!1)},Login:function(t,e,o){if(t||(t=window.authIdentityType),e&&(o||(o=this.GetLoginUrl(t)),this.Logout(!1,!0)),window.authIdentityType||!checkPublic())if(window.mainParentWindow)window.close();else{o||(o=MlsUser.GetLoginUrl(t));var n=this.ResolveHostURL(o);console.log("Login requested. Redirecting to ["+n+"] ..."),window.location.replace(n.href)}},Logout:function(t,e,o,n){var i=this.GetIdentityType(!0),s=this.GetLoginUrl(i);this.ClearAuth(),e&&(MlsTools.EraseCookie("ACCESS",MlsSettings.AUTH.CookiePath,MlsSettings.AUTH.CookieDomain),MlsTools.EraseCookie("ADMIN",MlsSettings.AUTH.CookiePath,MlsSettings.AUTH.CookieDomain),MlsTools.EraseCookie("SID",MlsSettings.AUTH.CookiePath,MlsSettings.AUTH.CookieDomain),MlsTools.EraseCookie("WS",MlsSettings.AUTH.CookiePath,MlsSettings.AUTH.CookieDomain),MlsTools.EraseCookie("USERNAME",MlsSettings.AUTH.CookiePath,MlsSettings.AUTH.CookieDomain),MlsTools.EraseCookie("AUSERNAME",MlsSettings.AUTH.CookiePath,MlsSettings.AUTH.CookieDomain),MlsTools.EraseCookie("FULLNAME",MlsSettings.AUTH.CookiePath,MlsSettings.AUTH.CookieDomain),MlsTools.EraseCookie("AFULLNAME",MlsSettings.AUTH.CookiePath,MlsSettings.AUTH.CookieDomain),MlsTools.EraseCookie("STATUS",MlsSettings.AUTH.CookiePath,MlsSettings.AUTH.CookieDomain),MlsTools.EraseCookie("MYMLS",MlsSettings.AUTH.CookiePath,MlsSettings.AUTH.CookieDomain),MlsTools.EraseCookie("DATA",MlsSettings.AUTH.CookiePath,MlsSettings.AUTH.CookieDomain),MlsTools.EraseCookie("CLASS",MlsSettings.AUTH.CookiePath,MlsSettings.AUTH.CookieDomain),MlsTools.EraseCookie("FIRMCODE",MlsSettings.AUTH.CookiePath,MlsSettings.AUTH.CookieDomain),MlsTools.EraseCookie("BOARD",MlsSettings.AUTH.CookiePath,MlsSettings.AUTH.CookieDomain),MlsTools.EraseCookie("DRE",MlsSettings.AUTH.CookiePath,MlsSettings.AUTH.CookieDomain),MlsTools.EraseCookie("ISASSISTANT",MlsSettings.AUTH.CookiePath,MlsSettings.AUTH.CookieDomain),MlsTools.EraseCookie("ISVESTAUSER",MlsSettings.AUTH.CookiePath,MlsSettings.AUTH.CookieDomain),MlsTools.EraseCookie("DIR",MlsSettings.AUTH.CookiePath,MlsSettings.AUTH.CookieDomain),MlsTools.EraseCookie("BETA",MlsSettings.AUTH.CookiePath,MlsSettings.AUTH.CookieDomain),MlsTools.EraseCookie("MAP_SEARCH",MlsSettings.AUTH.CookiePath,MlsSettings.AUTH.CookieDomain),MlsTools.EraseCookie("CARAVAN_TERM",MlsSettings.AUTH.CookiePath,MlsSettings.AUTH.CookieDomain),MlsTools.EraseCookie("MEMBEROFFICE",MlsSettings.AUTH.CookiePath,MlsSettings.AUTH.CookieDomain),MlsTools.EraseCookie("DASH_PA",MlsSettings.AUTH.CookiePath,MlsSettings.AUTH.CookieDomain)),n||window.localStorage.clear(),o||window.sessionStorage.clear(),t&&(window.closeChildren(),this.Login(i,!1,s))},ValidateIdentity:function(t,e){var o=isIdentityValid(t);if(o)return e&&e!=t.IdentityType?null:t;try{var n=JSON.parse(t);if(o=isIdentityValid(n))return e&&e!=n.IdentityType?null:n}catch(t){}return null},SetIdentity:function(t,e,o){try{var n=this.ValidateIdentity(t,e);if(n){if(o){var i=this.GetIdentity(null,!0);if(i&&i.AccountKey&&!n.AccountKey){var s=findAccount(n,i.AccountKey);s&&(n.AccountKey=s.AgentKey)}}adjustIdentity(n);var l=JSON.stringify(n);localStorage.setItem(MlsSettings.AUTH.IdentityKey,l),console.log("SetIdentity COMPLETED")}else console.log("SetIdentity INVALID");return console.log(n),n}catch(t){return null}},GetIdentity:function(t,e){try{var o=localStorage.getItem(MlsSettings.AUTH.IdentityKey),n=this.ValidateIdentity(o);if(n){if(n.IdentityType===MlsSettings.AUTH.IdentityAgent){var i=MlsTools.GetCookie(MlsSettings.AUTH.UserKey);i&&i.toUpperCase()!=n.Info.USERNAME.toUpperCase()&&(console.log(" IDENTITY OUTDATED! ["+n.Info.USERNAME+"] - ["+i+"]. Clearing..."),localStorage.removeItem(MlsSettings.AUTH.IdentityKey),e||(n=loadIdentity()))}adjustIdentity(n)}else localStorage.removeItem(MlsSettings.AUTH.IdentityKey),e||(n=loadIdentity());return n&&t?n[t]:n}catch(t){return null}},GetIdentityType:function(t){return this.GetIdentity("IdentityType",t)},GetAgentInfo:function(t,e){var o=this.GetIdentity("Info",e);if(o&&t){var n=o[t];return n?"string"==typeof n?n.toUpperCase():n:""}return o},GetAgentImpersonator:function(t,e){var o=this.GetIdentity("Impersonator",e);return o&&t?o[t]:o},GetAgentId:function(t){var e=this.GetAgentInfo(MlsSettings.AUTH.UserKey,t);return e||(e=this.GetContactAccount("Username",t)),e||"_"},GetContactAccount:function(t,e){var o=findAccount(this.GetIdentity(null,e));return o&&t?o[t]:o},SetContactAccount:function(t){var e=this.GetIdentity(null,!1);if(!e)return null;var o=t?findAccount(e,t):null;return o?e.AccountKey!==o.AgentKey&&e.AccountKey!==o.ContactKey&&(e.AccountKey=o.AgentKey,this.SetIdentity(e)):e.AccountKey&&(e.AccountKey=void 0,this.SetIdentity(e)),o},GetExpiration:function(t){try{var e=MlsTools.GetCookie(MlsSettings.AUTH.ExpKey);if(e){var o=decodeURIComponent(e),n=JSON.parse(o);if(n){var i=Number(n.Expiration),s=new Date(i),l=(s-new Date)/1e3/60,a=Number(n.Warning)||1,r={ExpirationStamp:s,ExpirationRemain:l,WarningStamp:new Date(i-60*a*1e3),WarningAdvance:a,LoginURL:n.LoginURL};return t?r[t]:r}}}catch(t){}return null},LoginSession:function(t,e,o){callAPI(this.ResolveHostURL(MlsSettings.AUTH.LoginURI+"/Account/LoginSession"),t,e,o)},ExtendSession:function(t,e,o){callAPI(this.ResolveHostURL(MlsSettings.AUTH.LoginURI+"/Account/Session?extendSession=true"),t,e,o)},SessionCheck:function(t,e,o){return this.ExtendSession(t,e,o)},StartAuthPoll:function(t){console.log("Starting auth cookie poll timer...");var e=this,o=setInterval(function(){e.HasAuth()||(clearInterval(o),o=null,console.log("Auth Cookie not found. Logging out ..."),window.mainParentWindow?window.top.close():e.Logout(!0))},1e3*t);return o},ResolveURL:function(t){return MlsTools.ResolveURL(t)},ResolveHostURL:function(t){return MlsTools.ResolveHostURL(t)},JoinURL:function(t,e){return MlsTools.JoinURL(t,e)}};function findAccount(t,e){var o=null;if(isIdentityValid(t)&&(e||(e=t.AccountKey),e&&t.Accounts)){var n=t.Accounts.filter(function(t){return t.AgentKey===e||t.ContactKey===e});o=n.length>0?n[0]:null}return o}function isIdentityValid(t,e){return!(!(t&&"object"==typeof t&&t.Id&&t.IdentityType)||e&&e!==t.IdentityType||!(t.IdentityType===MlsSettings.AUTH.IdentityContact&&t.Email&&t.Accounts&&t.Accounts.length>0||t.IdentityType===MlsSettings.AUTH.IdentityAgent&&t.Info&&t.Info.USERNAME))}function adjustIdentity(t){t.IdentityType==MlsSettings.AUTH.IdentityContact&&(t.Info||(t.Info=null))}function checkWindow(t){for(var e=null,o=MlsTools.GetOpener();o;)e=o,o=MlsTools.GetOpener(o);return e?(t&&(console.log("Registering with parent window ..."),e.top.postMessage({MessageType:"win-child-register"},"*")),e.top):null}function checkPublic(t){t||(t=window.location.href);var e=!1;return MlsSettings.AUTH.PublicList.forEach(function(o){t.indexOf(o)>=0&&(e=!0)}),e}function callAPI(t,e,o,n){MlsTools.SendRequest("GET",t,null,!0,function(){if(this.readyState===XMLHttpRequest.DONE){var t=this.response;200===this.status?"function"==typeof e&&e(t):"function"==typeof o&&o(this.status),console.log(t),"function"==typeof n&&n(this.status,t)}})}function loadIdentity(){var t=null;if(MlsUser.HasAuth()){var e=!1,o=MlsTools.ResolveHostURL(MlsSettings.AUTH.LoginURI+"/Account/User");for(console.log("Requesting User Identity (JS): ["+o+"]"),MlsTools.SendRequest("GET",o,null,!1,function(){this.readyState===XMLHttpRequest.DONE&&(200===this.status&&this.response&&(t=MlsUser.SetIdentity(this.response)),e=!0)});!e;)setTimeout(function(){},500)}return t}$(function(){console.log("Registering XMLHttpRequest interceptors ..."),$(document).ajaxSend(function(t,e,o){e.setRequestHeader(MlsSettings.AUTH.InhibitRedirectHeader,!0)}),$(document).ajaxError(function(t,e,o,n){401==e.status&&(console.log("401 - Unauthorized detected in MlsUser. Redirecting to login ..."),console.log(e),MlsUser.Logout(!0))})}),window.authIdentityType=MlsUser.IsAuthorized()?MlsUser.GetIdentityType(!0):null,window.mainParentWindow=checkWindow(!0),window.childWindows=window.childWindows||[],window.closeChildren=function(){window.childWindows.forEach(function(t,e){t.closed||t.top.closed||t.top.close()}),window.childWindows=[]},window.addEventListener("message",function(t){t.data&&t.data.MessageType&&t.data.MessageType===MlsSettings.EVENT.windowRegister&&window.childWindows.push(t.source)},!1),window.addEventListener("storage",function(t){if(t.key===MlsSettings.AUTH.IdentityKey&&!t.newValue){var e=JSON.parse(t.oldValue);MlsUser.Login(e.IdentityType)}}); if(!MlsSession)var MlsSession={SessionTimer:null,InitTimer:function(){var e=MlsUser.GetIdentity();return this.StartTimer(),e},StopTimer:function(){this.SessionTimer&&(clearInterval(this.SessionTimer),this.SessionTimer=null)},StartTimer:function(){return this.StopTimer(),this.SessionTimer=setTimeout(function(){var e=MlsUser.GetExpiration();e?e.WarningStamp.getTime()-(new Date).getTime()<0?MlsSession.DisplayWarning():MlsSession.StartTimer():(console.log("Expiration info not available"),MlsUser.Login(MlsSettings.AUTH.IdentityAgent,!1))},MlsSettings.AUTH.SessionCheckInterval),this.SessionTimer},DisplayWarning:function(){this.StopTimer();var e=MlsTools.ResolveHostURL("/MLSCommon/Home/SessionTimer"),n=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:screen.width,i=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:screen.height,t=n/window.screen.availWidth,s=(n-400)/2/t+(void 0!=window.screenLeft?window.screenLeft:window.screenX),o=(i-300)/2/t+(void 0!=window.screenTop?window.screenTop:window.screenY),r=window.open(e,"Session Warning","toolbar=no, location=no, directories=no, status=no, scrollbars=0, resizable=0, width="+400/t+", height="+300/t+", top="+o+", left="+s);window.focus&&r.focus();var l=setInterval(function(){r&&r.closed&&(clearInterval(l),l=null,expData=MlsUser.GetExpiration(),expData?MlsUser.ExtendSession(function(e){MlsSession.StartTimer()},function(e){MlsUser.Login(MlsSettings.AUTH.IdentityAgent,!1)}):MlsUser.Login(MlsSettings.AUTH.IdentityAgent,!1))},500)}},sessionListener=window.addEventListener("message",function(e){e.origin.indexOf(MlsSettings.AUTH.CookieDomain)&&e.data==MlsSettings.EVENT.sessionTerminated&&(console.log("Session Terminated"),MlsUser.Login(MlsSettings.AUTH.IdentityAgent,!1))}); if(!mlsTracking){!function(e,t){t.__SV}(document,window.mixpanel||[]);var mlsTracking=function(){if("undefined"!=typeof Storage){var e=localStorage.getItem("MLS-IDENTITY");try{JSON.parse(e)}catch(e){localStorage.removeItem("MLS-IDENTITY"),{Email:"",FullName:""}}}else({Email:"",FullName:""});return{setIdentity:function(e){},setPerson:function(e){},track:function(e,t,n,a){}}}()} if(!mlsMobileTracking){!function(e,n){n.__SV}(document,window.mixpanel||[]);var mlsMobileTracking=function(){function e(){if("undefined"!=typeof Storage){var e=localStorage.getItem("MLS-IDENTITY");try{JSON.parse(e)}catch(e){localStorage.removeItem("MLS-IDENTITY"),{Email:"",FullName:""}}}else({Email:"",FullName:""})}function n(e){}function t(e){}function i(e){}function o(){}return e(),$().ready(function(){}),{setIdentity:n,setPerson:t,registerAppName:i,track:function(e,n,t){},init:o}}()} if(!mlsVestaTracking){document,window.mixpanel;var mlsVestaTracking=function(){var e;function a(){if("undefined"!=typeof Storage){var a=localStorage.getItem("MLS-IDENTITY");try{e=JSON.parse(a)}catch(a){localStorage.removeItem("MLS-IDENTITY"),e={Email:"",FullName:""}}}else e={Email:"",FullName:""}}function n(a){mixpanel&&mixpanel.vestaTracking&&mixpanel.vestaTracking.identify&&"function"==typeof mixpanel.vestaTracking.identify&&(a=a||(e.Info&&e.Info.USERNAME?e.Info.USERNAME:e.Email),mixpanel.vestaTracking.identify(a))}function t(e){if(mixpanel&&mixpanel.vestaTracking&&mixpanel.vestaTracking.people){if(!e){var a=localStorage.getItem("MLS-IDENTITY");try{e=JSON.parse(a)}catch(e){return void localStorage.removeItem("MLS-IDENTITY")}}var n=e.FullName.split(" ");"contact"==e.IdentityType?mixpanel.vestaTracking.people.set({$first_name:n[0],$last_name:n[1],$email:e.Email,Id:e.AccountKey}):mixpanel.vestaTracking.people.set({$first_name:n[0],$last_name:n[1],$email:e.Email,member_class:e.Info.CLASS,mlsId:e.Info.MYMLS})}}function i(){var e=document.querySelector("[ng-app]");return function(e){switch(e){case"Agent":return"Dashboard-Agent";case"Client":return"Dashboard-Client";case"MlsListingSearch":return"ListingSearch";case"vestaApp":return"VestaplusMobile";case null:var a=window.location.pathname.split("/");return a.length>1?a[1]:"";default:return e}}(e?e.getAttribute("ng-app"):null)}function r(e){mixpanel&&mixpanel.vestaTracking&&mixpanel.vestaTracking.track&&"function"==typeof mixpanel.vestaTracking.register&&(void 0!==e&&""!=e||(e=i()),mixpanel.vestaTracking.register({appName:e}))}function l(){null!==e?(n(),t(),setTimeout(r(),500)):setTimeout(function(){a(),l()},500)}return a(),$().ready(function(){l()}),{setIdentity:n,setPerson:t,registerAppName:r,track:function(e,a,n){mixpanel&&mixpanel.vestaTracking&&mixpanel.vestaTracking.track&&"function"==typeof mixpanel.vestaTracking.track&&mixpanel.vestaTracking.track(e,a);var t=typeof n;"undefined"!=t&&"function"==t&&n()},init:l}}()} if(!vestaplusTracking){!function(e,t){if(!t.__SV){var n,a,l=window;try{var i,o,s,r=l.location,p=r.hash;i=function(e,t){return(o=e.match(RegExp(t+"=([^&]*)")))?o[1]:null},p&&i(p,"state")&&("mpeditor"===(s=JSON.parse(decodeURIComponent(i(p,"state")))).action&&(l.sessionStorage.setItem("_mpcehash",p),history.replaceState(s.desiredHash||"",e.title,r.pathname+r.search)))}catch(e){}window.mixpanel=t,t._i=[],t.init=function(e,l,i){function o(e,t){var n=t.split(".");2==n.length&&(e=e[n[0]],t=n[1]),e[t]=function(){e.push([t].concat(Array.prototype.slice.call(arguments,0)))}}var s=t;for(void 0!==i?s=t[i]=[]:i="mixpanel",s.people=s.people||[],s.toString=function(e){var t="mixpanel";return"mixpanel"!==i&&(t+="."+i),e||(t+=" (stub)"),t},s.people.toString=function(){return s.toString(1)+".people (stub)"},n="disable time_event track track_pageview track_links track_forms track_with_groups add_group set_group remove_group register register_once alias unregister identify name_tag set_config reset opt_in_tracking opt_out_tracking has_opted_in_tracking has_opted_out_tracking clear_opt_in_out_tracking people.set people.set_once people.unset people.increment people.append people.union people.track_charge people.clear_charges people.delete_user people.remove".split(" "),a=0;a1?t[1]:"";default:return e}}(e?e.getAttribute("ng-app"):null)}function i(e){mixpanel&&mixpanel.VestaPlus&&mixpanel.VestaPlus.track&&"function"==typeof mixpanel.VestaPlus.register&&(void 0!==e&&""!=e||(e=l()),mixpanel.VestaPlus.register({appName:e}))}function o(){null!==e?(n(),a(),setTimeout(i(),500)):setTimeout(function(){t(),o()},500)}return t(),$().ready(function(){o()}),{setIdentity:n,setPerson:a,registerAppName:i,track:function(e,t,n){mixpanel&&mixpanel.VestaPlus&&mixpanel.VestaPlus.track&&"function"==typeof mixpanel.VestaPlus.track&&mixpanel.VestaPlus.track(e,t);var a=typeof n;"undefined"!=a&&"function"==a&&n()},init:o}}()}