﻿function RioTrackingManager(){this.guestCellCode=-1;this.eac=-1;this.wid=-1;this.vn=-1;this.fn=-1;this.uniqueActionTagCode="null";this.isExtendedDataTag=true;this.testMode=false;this.fireCrsImpressionTags=true;this.isWtCookieSet=false;this.cellCodeCookieKey="RioTracking.CellCode.ClientSide";this.endActionCodeCookieKey="RioTracking.EndActionCode.ClientSide";this.permIdCookieKey="RioTracking.PermId.ClientSide";this.finalTagUatCookieKey="RioTracking.CompletionUatc";this.wtCookieKey="R";this.baseAtlasUrlNotExtended=document.location.protocol+"//view.atdmt.com/jaction/{0}";this.baseAtlasUrl=document.location.protocol+"//view.atdmt.com/jaction/{0}/v3/ato.-1/atc1.{1}/atc2.{2}/atc3.{3}";this.baseOnvAtlasUrl=document.location.protocol+"//view.atdmt.com/jaction/mrtity_RIOOnNetworkVideo_1/v3/ato.-1/atc1.{0}/atc2.{1}/atc3.{2}/atc4.{3}";this.baseCrsImpressionUrl=document.location.protocol+"//www.microsoft.com/click/services/Tracking/Impression.ashx";this.baseCrsClickUrl=document.location.protocol+"//www.microsoft.com/click/services/Tracking/Click.ashx";this.baseOnvEventUrl=document.location.protocol+"//www.microsoft.com/click/services/Tracking/RichMedia.ashx?pid=1&cc={0}&eid={1}&vid=3&eac={2}&uid={3}";this.AddHandler(window,"load",this.CreateDelegate(this,this.init))}RioTrackingManager.prototype.init=function(){this.setCellCode();this.setUserId();this.wid=escape(this.queryStringParamSafeValue("wid",true,this.wid));this.vn=escape(this.queryStringParamSafeValue("vn",true,this.vn));this.fn=escape(this.queryStringParamSafeValue("fn",true,this.fn));this.fireImpressionTags()};RioTrackingManager.prototype.setCellCode=function(){this.crcc=escape(this.queryStringParamSafeValue("CR_CC",true,this.guestCellCode));if(this.crcc==this.guestCellCode){var a=this.getCookie(this.cellCodeCookieKey);if(a!=null&&a.toString().length>0&&a.split(".")[1]=="1")this.crcc=parseInt(a.split(".")[0])}document.cookie=this.cellCodeCookieKey+"="+this.crcc+"."+(this.crcc==this.guestCellCode?"0":"1")};RioTrackingManager.prototype.setUserId=function(){this.crid=escape(this.queryStringParamSafeValue("CR_ID",true,-1));if(this.crid==-1){var a=this.getCookie(this.permIdCookieKey);if(a!=null&&a.toString().length>0)this.crid=a}document.cookie=this.permIdCookieKey+"="+this.crid};RioTrackingManager.prototype.fireImpressionTags=function(){if(this.uniqueActionTagCode!="null")this.fireAtlasImpressionTag();if(this.crcc!="-1"&&this.fireCrsImpressionTags)this.fireCrsImpressionTag()};RioTrackingManager.prototype.click=function(a,c){this.fireAtlasClickTag(c,a);this.fireCrsClickTag(a);var d=new Date,b=null;do b=new Date;while(b-d<500);return true};RioTrackingManager.prototype.atlasTrack=function(b){atlasUrl=this.baseAtlasUrlNotExtended.format(b);this.fireTag(atlasUrl,true);var c=new Date,a=null;do a=new Date;while(a-c<500);return true};RioTrackingManager.prototype.clickNoWait=function(a,b){this.fireAtlasClickTag(b,a);this.fireCrsClickTag(a)};RioTrackingManager.prototype.trackVideoEvent=function(c,d){var e=this.baseOnvAtlasUrl.format(this.crid,this.crcc,c,d),b=this.baseOnvEventUrl.format(this.crcc,d.toString(),c.toString(),this.crid);b+="&r="+escape(document.referrer);var a=new Date;b+="&rnd="+Math.ceil(Math.random()*99999999)+""+a.getUTCFullYear()+a.getUTCMonth()+a.getUTCDate()+a.getUTCHours()+a.getUTCMinutes()+a.getUTCSeconds()+a.getUTCMilliseconds();this.fireTag(e,false);this.fireTag(b,true)};RioTrackingManager.prototype.fireAtlasImpressionTag=function(){var a;if(this.isExtendedDataTag)a=this.baseAtlasUrl.format(this.uniqueActionTagCode,this.crid,this.crcc,this.eac);else a=this.baseAtlasUrlNotExtended.format(this.uniqueActionTagCode);this.fireTag(a,false)};RioTrackingManager.prototype.fireCrsImpressionTag=function(){var a=this.baseCrsImpressionUrl+"?CR_CC="+this.crcc;if(this.vn!=-1&&this.fn!=-1)a+="&vn="+this.vn.toString()+"&fn="+this.fn.toString();else if(this.wid!=-1)a+="&wid="+this.wid.toString();else if(!this.isWtCookieSet)this.setWtCookie();if(this.crid!=-1)a+="&CR_ID="+this.crid.toString();if(this.eac!=-1)a+="&CR_EAC="+this.eac.toString();if(this.testMode)a+="&test=1";if(this.crcc==this.guestCellCode)a+="&o=1";else a+="&o=0";a+="&r="+escape(document.referrer);this.fireTag(a,false)};RioTrackingManager.prototype.fireAtlasClickTag=function(b,a){var c=this.baseAtlasUrl.format(b,this.crid,this.crcc,a);this.fireTag(c,true)};RioTrackingManager.prototype.fireCrsClickTag=function(c){document.cookie=this.endActionCodeCookieKey+"="+c.toString();var b=this.baseCrsClickUrl;b+="?CR_EAC="+c.toString();if(this.testMode)b+="&test=1";b+="&r="+escape(document.referrer);var a=new Date;b+="&rnd="+Math.ceil(Math.random()*99999999)+""+a.getUTCFullYear()+a.getUTCMonth()+a.getUTCDate()+a.getUTCHours()+a.getUTCMinutes()+a.getUTCSeconds()+a.getUTCMilliseconds();this.fireTag(b,true)};function wt_GetCurrentCellCode(){var b=RioTracking.getCookie(RioTracking.wtCookieKey),a=escape(RioTracking.queryStringParamSafeValue("CR_CC",true,RioTracking.guestCellCode));if(this.uniqueActionTagCode=="null"||a==-1||this.wid!=-1||this.vn!=-1&&this.fn!=-1)return b;return RioTracking.setWtCookie()}RioTrackingManager.prototype.setWtCookie=function(){var h=this.getCookie(this.wtCookieKey),a;if(h!="")a=this.getCookie(this.wtCookieKey).split("|");else a=[];var c=escape(RioTracking.queryStringParamSafeValue("CR_CC",true,RioTracking.guestCellCode)),d=this.ArrayIndexOf(a,c);if(d>-1)a.splice(d,1);var f=c+"-"+RioTracking.getCurrentDateTime();a=this.ArrayAdd(a,0,f);var g=a.length>1?this.ArrayJoin(a,3,"|"):a,b=new Date;b.setDate(b.getFullYear()+20);var e=this.wtCookieKey+"="+g+";expires="+b.toGMTString()+";domain=microsoft.com;path=/";document.cookie=e;this.isWtCookieSet=true;return e};RioTrackingManager.prototype.AddHandler=function(a,b,c){if(a.addEventListener)a.addEventListener(b,c,false);else a.attachEvent("on"+b,c)};RioTrackingManager.prototype.CreateDelegate=function(b,a){return function(){return a.apply(b,arguments)}};RioTrackingManager.prototype.fireTag=function(b){var a=document.createElement("script");a.type="text/javascript";a.src=b;document.getElementsByTagName("head")[0].appendChild(a)};RioTrackingManager.prototype.queryStringParamSafeValue=function(a,e,c){a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var f="[?&]"+a+"=([^&#]*)",d="";if(e)d+="i";var g=new RegExp(f,d),b=g.exec(window.location.href.toString());if(!b&&c)return c;else if(!b)return null;else return b[1]};RioTrackingManager.prototype.getCookie=function(f){var d=document.cookie.split(";"),a="",b="",e="",c=false;for(i=0;i<d.length;i++){a=d[i].split("=");b=a[0].replace(/^\s+|\s+$/g,"");if(b==f){c=true;if(a.length>1)e=unescape(a[1].replace(/^\s+|\s+$/g,""));return e;break}a=null;b=""}if(!c)return ""};String.prototype.format=function(){var a=/\{\d+\}/g,b=arguments;return this.replace(a,function(a){return b[a.match(/\d+/)]})};RioTrackingManager.prototype.ArrayIndexOf=function(b,c){var a=b.length;while(a--)if(b[a].match(c+"-"))return a;return -1};RioTrackingManager.prototype.ArrayJoin=function(a,d,e){var c="",b=d>a.length?a.length:d;for(_index=0;_index<b;_index++)c+=a[_index]+(_index<b-1?e:"");return c};RioTrackingManager.prototype.ArrayAdd=function(a,b,c){for(_index=a.length;_index>b;_index--)a[_index]=a[_index-1];a[b]=c;return a};RioTrackingManager.prototype.getCurrentDateTime=function(){var a=new Date,e=a.getMonth()+1,g=a.getDate(),f=a.getFullYear(),d=a.getHours(),b=a.getMinutes(),c=a.getSeconds();if(b<10)b="0"+b;if(c<10)c="0"+c;return e+"/"+g+"/"+f+" "+d+":"+b+":"+c};var RioTracking=new RioTrackingManager
