Type.registerNamespace("Alterian.WA");Alterian.WA.Version="2.1.8";Alterian.WA.EventType=function(){};Alterian.WA.EventType.prototype={PageLoad:1,PageUnload:2,Blur:3,Focus:4,Click:5,DoubleClick:6,KeyPress:7,KeyDown:8,KeyUp:9,MouseOver:10,MouseOut:11,Resize:12,Viewed:13,Hidden:14,Select:15,Submit:16,Purchase:17};Alterian.WA.EventType.registerEnum("Alterian.WA.EventType",false);Alterian.WA.AssetToTrack=function(b,a){this._elementName=b;this._asset=a};Alterian.WA.AssetToTrack.prototype={get_asset:function(){return this._asset},set_asset:function(a){this._asset=a},get_elementName:function(){return this._elementName},set_elementName:function(a){this._elementName=a},get_altId:function(){return this._altid},set_altId:function(a){this._altid=a}};Alterian.WA.AssetToTrack.registerClass("Alterian.WA.AssetToTrack");Alterian.WA.ClientTracker=function(){this._token=null;this._session=null;this._clientID=null;this._tokenCookieName=null;this._sessionCookieName=null;this._assetsToTrack=null;this._elementsToTrack=null;this._pageName=null;this._eventsToSubmitList=new Array();this._eventSubmitTimerID=null;this._eventSubmitMonitorTimerID=null;this._jsonObjGetToken=null;this._jsonObjSubmitSession=null;this._jsonObjSubmitEvent=null;this._jsonObjSubmitUser=null;this._trackingServerDomain=null;this._trackingServerURL=null;this._userName="";this._hasUserNameBeenSubmitted=false;this._assetDelimiter="|";this._numofEventsinaSubmit=25;this._submitDurationinmillisec=4000;this._siteTobeTracked="";this._sessionDurationInMinutes=15};Alterian.WA.ClientTracker.prototype={get_token:function(){return this._token},set_token:function(a){this._token=a},get_session:function(){return this._session},set_session:function(a){this._session=a},get_clientID:function(){return this._clientID},set_clientID:function(a){this._clientID=a},get_assetDelimiter:function(){return this._assetDelimiter},get_assetsToTrack:function(){return this._assetsToTrack},set_assetsToTrack:function(a){this._assetsToTrack=a},get_elementsToTrack:function(){return this._elementsToTrack},set_elementsToTrack:function(a){this._elementsToTrack=a},get_userName:function(){return this._userName},set_userName:function(a){this._userName=a;if((this.get_session()!==null)&&(this.get_session().length>0)){this.submitUser()}},get_pageName:function(){return this._pageName},set_pageName:function(b){if(b.length>0){this._pageName=encodeURI(b)}else{var c=document.URL;var a=c.indexOf("?",0);if(a>0){c=c.substr(0,a)}this._pageName=encodeURI(c)}},get_eventSubmitTimerID:function(){return this._eventSubmitTimerID},set_eventSubmitTimerID:function(a){this._eventSubmitTimerID=a},get_eventSubmitMonitorTimerID:function(){return this._eventSubmitMonitorTimerID},set_eventSubmitMonitorTimerID:function(a){this._eventSubmitMonitorTimerID=a},get_tokenCookieName:function(){return this._tokenCookieName},set_tokenCookieName:function(a){this._tokenCookieName=a},get_sessionCookieName:function(){return this._sessionCookieName},set_sessionCookieName:function(a){this._sessionCookieName=a},get_jsonObjGetToken:function(){return this._jsonObjGetToken},set_jsonObjGetToken:function(a){this._jsonObjGetToken=a},get_jsonObjSubmitSession:function(){return this._jsonObjSubmitSession},set_jsonObjSubmitSession:function(a){this._jsonObjSubmitSession=a},get_jsonObjSubmitEvent:function(){return this._jsonObjSubmitEvent},set_jsonObjSubmitEvent:function(a){this._jsonObjSubmitEvent=a},get_jsonObjSubmitUser:function(){return this._jsonObjSubmitUser},set_jsonObjSubmitUser:function(a){this._jsonObjSubmitUser=a},get_sessionDurationInMinutes:function(){return this._sessionDurationInMinutes},set_sessionDurationInMinutes:function(a){this._sessionDurationInMinutes=a},get_numofEventsinaSubmit:function(){return this._numofEventsinaSubmit},set_numofEventsinaSubmit:function(a){this._numofEventsinaSubmit=a},get_submitDurationinmillisec:function(){return this._submitDurationinmillisec},set_submitDurationinmillisec:function(a){this._submitDurationinmillisec=a},get_trackingServerDomain:function(){return this._trackingServerDomain},set_trackingServerDomain:function(a){this._trackingServerDomain=a},get_siteTobeTracked:function(){return this._siteTobeTracked},set_siteTobeTracked:function(a){this._siteTobeTracked=a},get_trackingServerURL:function(){return this._trackingServerURL},set_trackingServerURL:function(a){this.set_trackingServerDomain(a);this.set_tokenCookieName(this.get_trackingServerDomain()+".alt.token");this.set_sessionCookieName(this.get_trackingServerDomain()+".alt.session");jQuery("#debugtext").prepend("Token Cookie:"+this.get_tokenCookieName()+"<br/>");jQuery("#debugtext").prepend("Session Cookie:"+this.get_sessionCookieName()+"<br/>");this._trackingServerURL=a+"/tracking.aspx"},calcTrackingServerURL:function(a){if(a.length>0){this.set_trackingServerURL(a)}jQuery("#debugtext").prepend(this.get_trackingServerURL()+"<br/>")},get_eventsToSubmitList:function(){return this._eventsToSubmitList},add_customevent:function(b,a,c,d){if(!a){a=""}if(!d){d=""}c=this.get_pageName()+this._assetDelimiter+a+this._assetDelimiter+c;this.addto_eventsList(b,c,d)},addto_eventsToSubmitList:function(a,b){this.addto_eventsList(a,b,"")},addto_eventsList:function(a,c,d){var b=new Date();jQuery("#debugtext").prepend(c+" : "+a+" Total Events: "+this.get_eventsToSubmitList().length+"<br/>");Array.add(this._eventsToSubmitList,'{"EventID":"'+a+'","EventTime":"/Date('+b.valueOf()+')/","Asset":"'+c+'","Value":"'+d+'"}');if(this.get_eventsToSubmitList().length>this.get_numofEventsinaSubmit()){this.submitEventsToWS()}},clear_eventsToSubmitList:function(){Array.clear(this._eventsToSubmitList)},pageLoadEvent:function(a){this.addto_eventsToSubmitList(Alterian.WA.EventType.PageLoad,this.get_pageName()+this._assetDelimiter+a)},pageUnloadEvent:function(a){this.addto_eventsToSubmitList(Alterian.WA.EventType.PageUnLoad,this.get_pageName()+this._assetDelimiter+a);this.submitEventsToWS()},blurEvent:function(b,a){this.addto_eventsToSubmitList(Alterian.WA.EventType.Blur,this.get_pageName()+this._assetDelimiter+a)},focusEvent:function(b,a){this.addto_eventsToSubmitList(Alterian.WA.EventType.Focus,this.get_pageName()+this._assetDelimiter+a)},clickEvent:function(b,a){this.addto_eventsToSubmitList(Alterian.WA.EventType.Click,this.get_pageName()+this._assetDelimiter+a);this.submitEventsToWS()},doubleClickEvent:function(b,a){this.addto_eventsToSubmitList(Alterian.WA.EventType.DoubleClick,this.get_pageName()+this._assetDelimiter+a);this.submitEventsToWS()},keyPressEvent:function(b,a,c){this.addto_eventsToSubmitList(Alterian.WA.EventType.KeyPress,this.get_pageName()+this._assetDelimiter+a)},keyDownEvent:function(b,a,c){this.addto_eventsToSubmitList(Alterian.WA.EventType.KeyDown,this.get_pageName()+this._assetDelimiter+a)},keyUpEvent:function(b,a,c){this.addto_eventsToSubmitList(Alterian.WA.EventType.KeyUp,this.get_pageName()+this._assetDelimiter+a)},mouseOverEvent:function(b,a){this.addto_eventsToSubmitList(Alterian.WA.EventType.MouseOver,this.get_pageName()+this._assetDelimiter+a)},mouseOutEvent:function(b,a){this.addto_eventsToSubmitList(Alterian.WA.EventType.MouseOut,this.get_pageName()+this._assetDelimiter+a)},resizeEvent:function(b,a){this.addto_eventsToSubmitList(Alterian.WA.EventType.Resize,this.get_pageName()+this._assetDelimiter+a)},selectEvent:function(b,a){this.addto_eventsToSubmitList(Alterian.WA.EventType.Select,this.get_pageName()+this._assetDelimiter+a)},submitEvent:function(b,a){this.addto_eventsToSubmitList(Alterian.WA.EventType.Submit,this.get_pageName()+this._assetDelimiter+a);this.submitEventsToWS()},getScreenSize:function(){var a="Unknown",c="Unknown";if(parseInt(navigator.appVersion)>3){a=screen.width;c=screen.height}else{if(navigator.appName=="Netscape"&&parseInt(navigator.appVersion)==3&&navigator.javaEnabled()){var b=java.awt.Toolkit.getDefaultToolkit();var d=b.getScreenSize();a=d.width;c=d.height}}return a+" x "+c},isScrolledIntoView:function(c){var d=jQuery(window).scrollTop();var b=d+jQuery(window).height();var e=jQuery(c).offset().top;var a=e+jQuery(c).height();return((a>=d)&&(e<=b)&&(a<=b)&&(e>=d))},checkElementVisibility:function(a){if(this.isScrolledIntoView(a)){if(!a._flag){a._flag=true;this.addto_eventsToSubmitList(Alterian.WA.EventType.Viewed,a._context)}}else{if(a._flag){this.addto_eventsToSubmitList(Alterian.WA.EventType.Hidden,a._context);a._flag=false}}},scrollEvent:function(){for(var a=0;a<this.get_elementsToTrack().length;a++){this.checkElementVisibility(this.get_elementsToTrack()[a])}},bindEvents:function(){var e=[];var d=0;if(this.get_assetsToTrack()!=undefined&&this.get_assetsToTrack()!=null){do{try{var f=this.get_assetsToTrack()[d].get_elementName();var a=$get(f);var g=this.get_assetsToTrack()[d].get_altId();if(!a){a=jQuery('[altid="'+g+'"]')[0]}if(a){e.push(a);var b=this.get_assetsToTrack()[d].get_asset();a._context=this.get_pageName()+this._assetDelimiter+b;a._flag=false}}catch(c){}}while(++d<this.get_assetsToTrack().length)}this.set_elementsToTrack(e);var h=Function.createDelegate(this,this.scrollEvent);window.onscroll=h},unbindEvents:function(){var a=0;if(!this.get_assetsToTrack()&&this.get_assetsToTrack().length>0){do{try{var e=this.get_assetsToTrack()[a].get_elementName();var d=$get(e);var c=this.get_assetsToTrack()[a].get_altId();if(!d){d=jQuery('[altid="'+c+'"]')[0]}$clearHandlers(d)}catch(b){}}while(++a<this.get_assetsToTrack().length)}},onReceiveToken:function(a){this.set_token(a.Token);this.set_clientID(a.ClientID);this.get_jsonObjGetToken().removeScriptTag();this.set_cookie(this.get_tokenCookieName(),a.Token,730*24*60,null,null,null);this.initSession()},getToken:function(){var a=this.get_trackingServerURL()+"/gettoken/?callback=this.altTracker.onReceiveToken";this.set_jsonObjGetToken(new JSONscriptRequest(a));this.get_jsonObjGetToken().buildScriptTag();this.get_jsonObjGetToken().addScriptTag()},onReceivesubmitUser:function(a){this.get_jsonObjSubmitUser().removeScriptTag()},submitUser:function(){if(!this._hasUserNameBeenSubmitted){if(this.get_userName().length>0){this._hasUserNameBeenSubmitted=true;var a=this.get_trackingServerURL()+"/submituser/?Token="+this.get_token()+"&Session="+this.get_session()+"&UserName="+this.get_userName()+"&callback=this.altTracker.onReceivesubmitUser";this.set_jsonObjSubmitUser(new JSONscriptRequest(a));this.get_jsonObjSubmitUser().buildScriptTag();this.get_jsonObjSubmitUser().addScriptTag()}}},onSessionSubmitAck:function(a){this.get_jsonObjSubmitSession().removeScriptTag();if(a!=null){this.set_session(a.Session);this.set_sessionDurationInMinutes(a.SessionDurationInMinutes);this.set_cookie(this.get_sessionCookieName(),a.Session,a.SessionDurationInMinutes,null,null,null);this.set_submitDurationinmillisec(a.SubmitDuration);this.set_numofEventsinaSubmit(a.NumofEventsinaSubmit);jQuery("#debugtext").prepend("NumofEventsinaSubmit!"+this.get_numofEventsinaSubmit()+"<br/>");jQuery("#debugtext").prepend("SubmitDuration!"+this.get_submitDurationinmillisec()+"<br/>");this.submitUser();this.submitEventsToWS()}},customEncoderForURLParam:function(a){var b=a;b=b.replace("?","%3F");b=b.replace("&","%26");b=encodeURIComponent(a);return b},submitSessionToWS:function(c){try{this.reset_cookie(this.get_tokenCookieName(),this.get_token(),730*24*60,null,null,null);var b=new Date();var a="&timeoffset="+b.getTimezoneOffset()+"&scrres="+this.getScreenSize()+"&username="+this.get_userName()+"&trackedsite="+this.get_siteTobeTracked();if(document.referrer.length>0){a=a+"&ref="+this.customEncoderForURLParam(document.referrer)}else{a=a+"&ref=unknown"}var e=this.get_trackingServerURL()+"/submitsession/?Token="+this.get_token()+"&callback=this.altTracker.onSessionSubmitAck"+a;e=encodeURI(e);this.set_jsonObjSubmitSession(new JSONscriptRequest(e));this.get_jsonObjSubmitSession().buildScriptTag();this.get_jsonObjSubmitSession().addScriptTag()}catch(d){}},setSubmitEventTimer:function(){var a=Function.createDelegate(this,this.submitEventsToWS);var b=window.setInterval(a,this.get_submitDurationinmillisec());this.set_eventSubmitTimerID(b)},clearSubmitEventTimer:function(){window.clearInterval(this.get_eventSubmitTimerID())},onEventSubmitAck:function(a){jQuery("#debugtext").prepend("Event Acknowledged!<br/>");this.get_jsonObjSubmitEvent().removeScriptTag();this.setSubmitEventTimer()},submitEventsToWS:function(){try{var a=this.get_cookie(this.get_sessionCookieName());if(a!=null){if(this.get_eventsToSubmitList().length>0){this.clearSubmitEventTimer();this.reset_cookie(this.get_sessionCookieName(),this.get_session(),this.get_sessionDurationInMinutes(),null,null,null);var e=null;var b=0;do{var d=this.get_eventsToSubmitList().pop();if(b>0){e=e+","+d}else{e=d}b++}while(this.get_eventsToSubmitList().length>0);e="["+e+"]";var c=this.get_trackingServerURL()+"/submitevents/?Token="+this.get_token()+"&Session="+this.get_session()+"&callback=this.altTracker.onEventSubmitAck&Events=";c=encodeURI(c)+this.customEncoderForURLParam(e);this.set_jsonObjSubmitEvent(new JSONscriptRequest(c));this.get_jsonObjSubmitEvent().buildScriptTag();this.get_jsonObjSubmitEvent().addScriptTag()}}}catch(f){}},optOutOfTracking:null,initTracker:function(b,d,c){try{this.calcTrackingServerURL(b);this.set_pageName(d);this.set_siteTobeTracked(c);if(typeof this.optOutOfTracking=="function"){if(this.optOutOfTracking(this.get_trackingServerURL(),this.get_pageName(),this.get_siteTobeTracked())){return}}if(this.get_assetsToTrack()!==null){this.bindEvents()}this.pageLoadEvent(this.get_pageName());var a=this.get_cookie(this.get_tokenCookieName());if(a==null){this.getToken()}else{this.set_token(a);this.initSession()}}catch(e){}},initSession:function(){this.set_token(this.get_cookie(this.get_tokenCookieName()));var a=this.get_cookie(this.get_sessionCookieName());if(a==null){this.submitSessionToWS()}else{this.set_session(a);this.submitEventsToWS()}},finalize:function(){window.clearInterval(this.get_eventSubmitTimerID());window.clearInterval(this.get_eventSubmitMonitorTimerID());this.submitEventsToWS();this.unbindEvents()},set_cookie:function(a,d,c,g,f,i){var h=a+"="+escape(d);var b=new Date();b.setTime(b.getTime());if(c){c=c*1000*60}var e=new Date(b.getTime()+(c));if(e){h+="; expires="+e.toGMTString()}if(g){h+="; path="+escape(g)}if(f){h+="; domain="+escape(f)}if(i){h+="; secure"}document.cookie=h},delete_cookie:function(a){var b=new Date();b.setTime(b.getTime()-1);document.cookie=a+="=; expires="+b.toGMTString()},reset_cookie:function(c,d,b,f,e,a){this.delete_cookie(c);this.set_cookie(c,d,b,f,e,a)},get_cookie:function(a){var b=document.cookie.match("(^|;) ?"+a+"=([^;]*)(;|$)");if(b){return(unescape(b[2]))}else{return null}}};Alterian.WA.ClientTracker.registerClass("Alterian.WA.ClientTracker");
