window.INK=(window.INK||{});INK.widget=(window.INK.widget||{});INK.widget.Canary=(window.INK.widget.Canary||null);(function(INK,Canary){if(Canary){return false;}window.hasOwnProperty=window.hasOwnProperty||Object.prototype.hasOwnProperty;var wid=(function b(a){return a?(a^Math.random()*16>>a/4).toString(16):([10000000]+-1000+-4000+-8000+-100000000000).replace(/[018]/g,b);})(),each=function(a,f){for(var i in a){if(hasOwnProperty.call(a,i)){f(a[i],i);}}},extend=function e(a,b,c,d){b=b||this;d={};for(c in a){d[c]=b[c];b[c]=a[c];}return{undo:function(){e(d,b);}};},xhr=function(s,a){a=[a="Msxml2.XMLHTTP",a+".3.0",a+".6.0"];do{try{s=a.pop();return new (s?ActiveXObject:XMLHttpRequest)(s);}catch(e){}}while(s);},bind=function(a,b,c,d){a=a||document;d=a[b="on"+b];b=a[b]=function(e){d=d&&d(e=e||a.event);return(c=c&&b(e))?b:d;};a=this;},toJson=function f(a,b,c){for(b in (c=/t]/.test(a)&&[])&&a){c.push(f(b)+":"+f(a[b]));}return""+a===a?'"'+a+'"':a&&a.map?"["+a.map(f)+"]":c?"{"+c+"}":a;};var isEventSupported=(function(undef){var TAGNAMES={"select":"input","change":"input","submit":"form","reset":"form","error":"img","load":"img","abort":"img"};function isEventSupported(eventName,element){element=element||document.createElement(TAGNAMES[eventName]||"div");eventName="on"+eventName;var isSupported=(eventName in element);if(!isSupported){if(!element.setAttribute){element=document.createElement("div");}if(element.setAttribute&&element.removeAttribute){element.setAttribute(eventName,"");isSupported=typeof element[eventName]=="function";if(typeof element[eventName]!="undefined"){element[eventName]=undef;}element.removeAttribute(eventName);}}element=null;return isSupported;}return isEventSupported;})();Canary=function(scope,cfg){this.versionDetail=this.versionDetail||{major:0,minor:3,patch:0};this.version=[this.versionDetail.major,this.versionDetail.minor,this.versionDetail.patch].join(".");cfg=cfg||{};this.wid=wid;this.prefetch=false;this.uri=(scope.location||"").toString();this.parent_uri=null;if(scope.opener){try{this.parent_uri=(scope.opener.location||"").toString();}catch(e){this.parent_uri="non-CustomInk domain";}}this.scope=scope;var hash=(cfg.uri||this.uri).split("#")[1];this._hash=hash?"#"+hash:null;extend(cfg,this);};Canary.prototype={printStackTrace:function(){return[];},set:function(o,value){for(k in o){if(o.hasOwnProperty(k)){this[k]=o[k];}}return this;},log:function(event_type,msg,serialized_data){var x=xhr(),qs=[],pObj={},pMsg=[],params={"client_event[localtime]":+new Date(),"client_event[version]":this.version,u:this.uri,w:this.wid};if(msg){extend({m:msg},params);}if(serialized_data){if(serialized_data.stackTrace){pObj.stackTrace=serialized_data.stackTrace;delete serialized_data.stackTrace;}extend({"client_event[serialized_data]":toJson(serialized_data)},params);}if(this.prefetch){params.prefetch=this.prefetch;}if(this.parent_uri){extend({parent_uri:this.parent_uri},params);}each(params,function(value,key){qs.push(key+"="+encodeURIComponent(value));});each(pObj,function(value,key){pMsg.push(key+"="+encodeURIComponent(value));});var url="/canary/log/"+event_type+"?"+qs.join("&");x.open((pObj.stackTracek?"POST":"GET"),url);try{x.send(pMsg[0]?pMsg.join("&"):null);}catch(e){}return this;},trackPageEvents:function(){INK.Canary.log("page_initialization");if(isEventSupported("pageshow",this.scope)){bind("pageshow",function(e){INK.Canary.log(e.persisted?"page_show":"page_load");});}else{bind("load",function(e){INK.Canary.log("page_load",this.scope);});}if(isEventSupported("hashchange",this.scope)){bind("hashchange",function(){var loc=this.location,hash=loc?"#"+loc.toString().split("#")[1]:"n/a";INK.Canary.log("hashchange","Hash changed from "+INK.Canary._hash+" to "+hash);INK.Canary._hash=hash;});}if(isEventSupported("pagehide",this.scope)){bind("pagehide",function(e){INK.Canary.log(e.persisted?"page_hide":"page_unload");});}return this;},trackXHRs:function(jQ,Ext){var notCanaryXhr=function(url){return !/^\/canary\//.test(url);},elapsedTime=function(e){return(+new Date()-e.timeStamp)/1000;};return function(libs){if(jQ=jQ||libs.jQuery){jQ(document).ajaxSend(function(e,xhr,req){if(notCanaryXhr(req.url)){INK.Canary.log("xhr_send",req.url,{type:req.type});}}).ajaxSuccess(function(e,xhr,req){if(notCanaryXhr(req.url)){INK.Canary.log("xhr_success",req.url,{elapsed_time:elapsedTime(e)});}}).ajaxError(function(e,xhr,req,err){if(notCanaryXhr(req.url)){var m=xhr.status+" "+xhr.statusText+"("+req.url+")";INK.Canary.log("xhr_error",m,{xhr_uri:req.url,code:xhr.status,text:xhr.statusText,elapsed_time:elapsedTime(e)});}});}if(Ext=Ext||libs.Ext){Ext.Ajax.on({beforerequest:function(conn,o){o.timeStamp=o.timeStamp||new Date().getTime();INK.Canary.log("xhr_send",o.url,{type:o.method});},requestcomplete:function(conn,res,o){INK.Canary.log("xhr_success",o.url,{elapsed_time:elapsedTime(o)});},requestexception:function(conn,res,o){var m=res.status+" "+res.statusText+"("+o.url+")";INK.Canary.log("xhr_error",m,{xhr_uri:o.url,code:res.status,text:res.statusText,elapsed_time:elapsedTime(e)});}});}return this;};}(this.jQuery,this.Ext),toString:function(){return"[INK::Canary v"+this.version+"] "+this.uri;}};INK.Canary=INK.widget.Canary=new Canary(this);var old_onerror=this.onerror;this.onerror=function(msg,uri,lineNumber){INK.Canary.log("error",msg,{lineNumber:lineNumber,filename:uri,stackTrace:INK.Canary.printStackTrace()});if(old_onerror){old_onerror.apply(this,arguments);}};(function(){var scripts=document.getElementsByTagName("script"),i=0,len=scripts.length,canary_path=null;for(i;i<len;i++){canary_path=scripts[i].getAttribute("src");if(canary_path&&canary_path.match(/ink\.widget\.canary\./)){break;}else{canary_path=null;}}if(canary_path){var stackTrace=document.createElement("script");stackTrace.src=canary_path.replace(/\.canary\./,".canary.stacktrace.");stackTrace.async="true";scripts[0].parentNode.insertBefore(stackTrace,scripts[0]);}})();})(INK,INK.widget.Canary);
