var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(a){for(var b="",c,d,e,g,i,h,j=0,a=Base64._utf8_encode(a);j<a.length;)c=a.charCodeAt(j++),d=a.charCodeAt(j++),e=a.charCodeAt(j++),g=c>>2,c=(c&3)<<4|d>>4,i=(d&15)<<2|e>>6,h=e&63,isNaN(d)?i=h=64:isNaN(e)&&(h=64),b=b+this._keyStr.charAt(g)+this._keyStr.charAt(c)+this._keyStr.charAt(i)+this._keyStr.charAt(h);return b},decode:function(a){for(var b="",c,d,e,g,i,h=0,a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");h<
a.length;)c=this._keyStr.indexOf(a.charAt(h++)),d=this._keyStr.indexOf(a.charAt(h++)),g=this._keyStr.indexOf(a.charAt(h++)),i=this._keyStr.indexOf(a.charAt(h++)),c=c<<2|d>>4,d=(d&15)<<4|g>>2,e=(g&3)<<6|i,b+=String.fromCharCode(c),64!=g&&(b+=String.fromCharCode(d)),64!=i&&(b+=String.fromCharCode(e));return b=Base64._utf8_decode(b)},_utf8_encode:function(a){for(var a=a.replace(/\r\n/g,"\n"),b="",c=0;c<a.length;c++){var d=a.charCodeAt(c);128>d?b+=String.fromCharCode(d):(127<d&&2048>d?b+=String.fromCharCode(d>>
6|192):(b+=String.fromCharCode(d>>12|224),b+=String.fromCharCode(d>>6&63|128)),b+=String.fromCharCode(d&63|128))}return b},_utf8_decode:function(a){for(var b="",c=0,d=c1=c2=0;c<a.length;)d=a.charCodeAt(c),128>d?(b+=String.fromCharCode(d),c++):191<d&&224>d?(c2=a.charCodeAt(c+1),b+=String.fromCharCode((d&31)<<6|c2&63),c+=2):(c2=a.charCodeAt(c+1),c3=a.charCodeAt(c+2),b+=String.fromCharCode((d&15)<<12|(c2&63)<<6|c3&63),c+=3);return b}};var JSON;JSON||(JSON={});
(function(){function a(a){return 10>a?"0"+a:a}function b(a){e.lastIndex=0;return e.test(a)?'"'+a.replace(e,function(a){var b=h[a];return"string"===typeof b?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function c(a,d){var e,m,l,h,n=g,k,f=d[a];f&&"object"===typeof f&&"function"===typeof f.toJSON&&(f=f.toJSON(a));"function"===typeof j&&(f=j.call(d,a,f));switch(typeof f){case "string":return b(f);case "number":return isFinite(f)?""+f:"null";case "boolean":case "null":return""+f;
case "object":if(!f)return"null";g+=i;k=[];if("[object Array]"===Object.prototype.toString.apply(f)){h=f.length;for(e=0;e<h;e+=1)k[e]=c(e,f)||"null";l=0===k.length?"[]":g?"[\n"+g+k.join(",\n"+g)+"\n"+n+"]":"["+k.join(",")+"]";g=n;return l}if(j&&"object"===typeof j){h=j.length;for(e=0;e<h;e+=1)"string"===typeof j[e]&&(m=j[e],(l=c(m,f))&&k.push(b(m)+(g?": ":":")+l))}else for(m in f)Object.prototype.hasOwnProperty.call(f,m)&&(l=c(m,f))&&k.push(b(m)+(g?": ":":")+l);l=0===k.length?"{}":g?"{\n"+g+k.join(",\n"+
g)+"\n"+n+"}":"{"+k.join(",")+"}";g=n;return l}}if("function"!==typeof Date.prototype.toJSON)Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+a(this.getUTCMonth()+1)+"-"+a(this.getUTCDate())+"T"+a(this.getUTCHours())+":"+a(this.getUTCMinutes())+":"+a(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()};var d=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
e=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,g,i,h={"\u0008":"\\b","\t":"\\t","\n":"\\n","\u000c":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},j;if("function"!==typeof JSON.stringify)JSON.stringify=function(a,b,d){var e;i=g="";if("number"===typeof d)for(e=0;e<d;e+=1)i+=" ";else"string"===typeof d&&(i=d);if((j=b)&&"function"!==typeof b&&("object"!==typeof b||"number"!==typeof b.length))throw Error("JSON.stringify");return c("",
{"":a})};if("function"!==typeof JSON.parse)JSON.parse=function(a,b){function c(a,e){var d,g,f=a[e];if(f&&"object"===typeof f)for(d in f)Object.prototype.hasOwnProperty.call(f,d)&&(g=c(f,d),void 0!==g?f[d]=g:delete f[d]);return b.call(a,e,f)}var e,a=""+a;d.lastIndex=0;d.test(a)&&(a=a.replace(d,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return e=eval("("+a+")"),"function"===typeof b?c({"":e},""):e;throw new SyntaxError("JSON.parse");}})();if("undefined"===typeof Rl)var Rl={};Rl.isArray=function(a){return-1<Object.prototype.toString.call(a).indexOf("Array")};Rl.isDebug=function(){return-1!==document.URL.indexOf("__rldebug=1")};Rl.isNull=function(a){return"undefined"===typeof a||null===a};Rl.log=function(a){Rl.isNull(window.console)||console.log("RareLogic: %s",a)};function RlAttribute(a,b,c){this.family=a;this.name=b;this.value=c}RlAttribute.prototype.toId=function(){return this.family+"."+this.name};RlAttribute.prototype.toJSON=function(){return this.value};
function RlGroup(a){this.name=a;this.events=[]}RlGroup.prototype.createEvent=function(){var a=new RlEvent;this.events.push(a);return a};RlGroup.prototype.toJSON=function(){return this.events};function RlEvent(a,b,c){this.profile=a;this.attributes={};this.recorded=!1;this.rlaDomain="d.rare.io";this.rlaPort="";this.uuid=b;this.domain=c}RlEvent.prototype.createGroup=function(a){var b=new RlGroup(a);return this.attributes[a]=b};RlEvent.prototype.setCookieDomain=function(a){this.domain=a};
RlEvent.prototype.set=function(a,b,c){Rl.isDebug()&&Rl.log("Adding attribute '"+a+"."+b+"' with value: "+c);a=new RlAttribute(a,b,c);this.attributes[a.toId()]=a};RlEvent.prototype.sets=function(a){for(var b=a.length,c=0;c<b;c++)this.attributes[a[c].toId()]=a[c]};RlEvent.prototype.reset=function(){this.recorded=!1;this.attributes=[]};RlEvent.prototype.toJSON=function(){return this.attributes};
RlEvent.prototype.record=function(){if(Rl.isNull(this.profile)||""===this.profile)Rl.isDebug()&&Rl.log("No profile specified, skipping record.");else if(!0!==this.recorded)if(0===this.attributes.length)Rl.isDebug()&&Rl.log("No event attributes found, skipping record.");else{var a=this.uuid;Rl.isNull(a)&&(a=this._RLUUID());if(!Rl.isNull(a)){this._isSet("rl","url")||this.set("rl","url",document.URL);this._isSet("rl","ref")||this.set("rl","ref",document.referrer);this._isSet("rl","useragent")||this.set("rl",
"ref",document.referrer);this.set("rl","x",(new Date).getTime());var b=JSON.stringify([this.toJSON()]),b=Base64.encode(b);Rl.isDebug()&&Rl.log("Recording event");var c=new Image;c.src=("https:"==document.location.protocol?"https://":"http://")+this.rlaDomain+(""!=this.rlaPort?":"+this.rlaPort:"")+"/store/"+this.profile+"/"+a+"/cg.gif?v=1.0&data="+b;Rl.isDebug()&&Rl.log("Image api request => "+c.src);this.recorded=!0}}};
RlEvent.prototype._isSet=function(a,b){return!Rl.isNull(this.attributes[a+"."+b])};
RlEvent.prototype._RLUUID=function(){if(0===document.cookie.length||-1===document.cookie.indexOf("RLUU=")){var a=new Date,b=a.getTime();a.setTime(31536E6+b);b=b+"-"+Math.random().toString().substr(3,64);a="RLUU="+escape(b)+";expires="+a.toGMTString()+";";Rl.isNull(this.domain)||(a+="domain="+this.domain);document.cookie=a;return!document.cookie||0===document.cookie.length?(Rl.log("Error, could not persist cookie."),null):b}a=document.cookie.indexOf("RLUU=")+5;b=document.cookie.indexOf(";",a);if(-1===
b)b=document.cookie.length;return unescape(document.cookie.substring(a,b))};RlEvent.prototype.pageView=function(a,b){this.set("action","name","View");this.set("content","type","Page");this.set("content","name",a);this.set("content","group",b)};RlEvent.prototype.postView=function(a,b){this.set("action","name","View");this.set("content","type","Post");this.set("content","name",a);this.set("content","group",b)};RlEvent.prototype.categoryView=function(a){this.set("action","name","View");this.set("content","type","Category");this.set("content","group",a)};
RlEvent.prototype.setTags=function(a){Rl.isArray(a)&&this.set("tag","name",a)};RlEvent.prototype.productView=function(a,b){this.set("action","name","View");this.set("content","type","Product");this.set("content","name",b);this.set("commerce","productid",a)};RlEvent.prototype.productCatalogView=function(a){this.set("action","name","View");this.set("content","type","Catalog");this.set("content","name",a)};
RlEvent.prototype.cartProductSnapshot=function(a,b,c,d){if(!this._cart)this._cart=this.createGroup("cart");var e=this._cart.createEvent();e.set("content","type","Product");e.set("commerce","productid",a);e.set("content","name",b);e.set("commerce","added",c);e.set("commerce","value",d)};RlEvent.prototype.cartPurchase=function(){event.set("action","name","Purchase")};RlEvent.prototype.addAgent=function(a,b,c,d){"undefined"===typeof this._agents&&(this._agents=this.createGroup("agents"));var e=this._agents.createEvent();e.set("realEstateAgent","id",a);e.set("office","id",b);e.set("brokerageOwner","id",c);e.set("franchisor","id",d)};

