(function(w){var impl,boomr,k,d=w.document;if(typeof BOOMR==="undefined"){BOOMR={};}
if(BOOMR.version){return;}
BOOMR.version="0.9";impl={beacon_url:"",site_domain:w.location.hostname.replace(/.*?([^.]+\.[^.]+)\.?$/,'$1').toLowerCase(),user_ip:'',events:{"page_ready":[],"page_unload":[],"before_beacon":[]},vars:{},disabled_plugins:{},fireEvent:function(e_name,data){var i,h,e;if(!this.events.hasOwnProperty(e_name)){return false;}
e=this.events[e_name];for(i=0;i<e.length;i++){h=e[i];h[0].call(h[2],data,h[1]);}
return true;},addListener:function(el,sType,fn,capture){if(el.addEventListener){el.addEventListener(sType,fn,(capture));}
else if(el.attachEvent){el.attachEvent("on"+sType,fn);}}};boomr={utils:{getCookie:function(name){if(!name){return null;}
name=' '+name+'=';var i,cookies;cookies=' '+d.cookie+';';if((i=cookies.indexOf(name))>=0){i+=name.length;cookies=cookies.substring(i,cookies.indexOf(';',i));return cookies;}
return null;},setCookie:function(name,subcookies,max_age,path,domain,sec){var value="",k,nameval,c,exp="";if(!name){return false;}
for(k in subcookies){if(subcookies.hasOwnProperty(k)){value+='&'+encodeURIComponent(k)
+'='+encodeURIComponent(subcookies[k]);}}
value=value.replace(/^&/,'');if(max_age){exp=new Date();exp.setTime(exp.getTime()+max_age*1000);exp=exp.toGMTString();}
nameval=name+'='+value;c=nameval+
((max_age)?"; expires="+exp:"")+
((path)?"; path="+path:"")+
((typeof domain!=="undefined")?"; domain="
+(domain!==null?domain:impl.site_domain):"")+
((sec)?"; secure":"");if(nameval.length<4000){d.cookie=c;return(value===this.getCookie(name));}
return false;},getSubCookies:function(cookie){var cookies_a,i,l,kv,cookies={};if(!cookie){return null;}
cookies_a=cookie.split('&');if(cookies_a.length===0){return null;}
for(i=0,l=cookies_a.length;i<l;i++){kv=cookies_a[i].split('=');kv.push("");cookies[decodeURIComponent(kv[0])]=decodeURIComponent(kv[1]);}
return cookies;},removeCookie:function(name){return this.setCookie(name,{},0,"/",null);},pluginConfig:function(o,config,plugin_name,properties){var i,props=0;if(!config||!config[plugin_name]){return false;}
for(i=0;i<properties.length;i++){if(typeof config[plugin_name][properties[i]]!=="undefined"){o[properties[i]]=config[plugin_name][properties[i]];props++;}}
return(props>0);}},init:function(config){var i,k,properties=["beacon_url","site_domain","user_ip"];if(!config){config={};}
for(i=0;i<properties.length;i++){if(typeof config[properties[i]]!=="undefined"){impl[properties[i]]=config[properties[i]];}}
if(typeof config.log!=="undefined"){this.log=config.log;}
if(!this.log){this.log=function(m,l,s){};}
for(k in this.plugins){if(config[k]&&typeof config[k].enabled!=="undefined"&&config[k].enabled===false){impl.disabled_plugins[k]=1;continue;}
else if(impl.disabled_plugins[k]){delete impl.disabled_plugins[k];}
if(this.plugins.hasOwnProperty(k)&&typeof this.plugins[k].init==="function"){this.plugins[k].init(config);}}
if(typeof config.autorun==="undefined"||config.autorun!==false){impl.addListener(w,"load",function(){impl.fireEvent("page_ready");});}
return this;},page_ready:function(){impl.fireEvent("page_ready");return this;},subscribe:function(e_name,fn,cb_data,cb_scope){var i,h,e;if(!impl.events.hasOwnProperty(e_name)){return this;}
e=impl.events[e_name];for(i=0;i<e.length;i++){h=e[i];if(h[0]===fn&&h[1]===cb_data&&h[2]===cb_scope){return this;}}
e.push([fn,cb_data||{},cb_scope||null]);if(e_name==='page_unload'){impl.addListener(w,"unload",function(){fn.call(cb_scope,null,cb_data);fn=cb_scope=cb_data=null;});}
return this;},addVar:function(name,value){if(typeof name==="string"){impl.vars[name]=value;}
else if(typeof name==="object"){var o=name,k;for(k in o){if(o.hasOwnProperty(k)){impl.vars[k]=o[k];}}}
return this;},removeVar:function(){var i,params;if(!arguments.length){return this;}
if(arguments.length===1&&Object.prototype.toString.apply(arguments[0])==="[object Array]"){params=arguments[0];}
else{params=arguments;}
for(i=0;i<params.length;i++){if(impl.vars.hasOwnProperty(params[i])){delete impl.vars[params[i]];}}
return this;},sendBeacon:function(){var k,url,img,nparams=0;for(k in this.plugins){if(this.plugins.hasOwnProperty(k)){if(impl.disabled_plugins[k]){continue;}
if(!this.plugins[k].is_complete()){return this;}}}
impl.fireEvent("before_beacon",impl.vars);if(!impl.beacon_url){return this;}
url=impl.beacon_url+'?v='+encodeURIComponent(BOOMR.version);for(k in impl.vars){if(impl.vars.hasOwnProperty(k)){nparams++;url+="&"+encodeURIComponent(k)
+"="+encodeURIComponent(impl.vars[k]);}}
if(nparams){img=new Image();img.src=url;}
return this;}};var make_logger=function(l){return function(m,s){this.log(m,l,"boomerang"+(s?"."+s:""));return this;};};boomr.debug=make_logger("debug");boomr.info=make_logger("info");boomr.warn=make_logger("warn");boomr.error=make_logger("error");if(typeof w.YAHOO!=="undefined"&&typeof w.YAHOO.log!=="undefined"){boomr.log=w.YAHOO.log;}
else if(typeof w.Y!=="undefined"&&typeof w.Y.log!=="undefined"){boomr.log=w.Y.log;}
else if(typeof console!=="undefined"&&typeof console.log!=="undefined"){boomr.log=function(m,l,s){console.log(s+": ["+l+"] ",m);};}
for(k in boomr){if(boomr.hasOwnProperty(k)){BOOMR[k]=boomr[k];}}
BOOMR.plugins=BOOMR.plugins||{};}(window));(function(w){var d=w.document;BOOMR=BOOMR||{};BOOMR.plugins=BOOMR.plugins||{};var impl={complete:false,timers:{},cookie:'RT',cookie_exp:600,strict_referrer:true,start:function(){var t_end,t_start=new Date().getTime();if(!BOOMR.utils.setCookie(impl.cookie,{s:t_start,r:d.URL.replace(/#.*/,'')},impl.cookie_exp,"/",null)){BOOMR.error("cannot set start cookie","rt");return this;}
t_end=new Date().getTime();if(t_end-t_start>50){BOOMR.utils.removeCookie(impl.cookie);BOOMR.error("took more than 50ms to set cookie... aborting: "
+t_start+" -> "+t_end,"rt");}
return this;}};BOOMR.plugins.RT={init:function(config){impl.complete=false;impl.timers={};BOOMR.utils.pluginConfig(impl,config,"RT",["cookie","cookie_exp","strict_referrer"]);BOOMR.subscribe("page_ready",this.done,null,this);BOOMR.subscribe("page_unload",impl.start,null,this);return this;},startTimer:function(timer_name){if(timer_name){impl.timers[timer_name]={start:new Date().getTime()};impl.complete=false;}
return this;},endTimer:function(timer_name,time_value){if(timer_name){impl.timers[timer_name]=impl.timers[timer_name]||{};impl.timers[timer_name].end=(typeof time_value==="number"?time_value:new Date().getTime());}
return this;},setTimer:function(timer_name,time_delta){if(timer_name){impl.timers[timer_name]={delta:time_delta};}
return this;},done:function(){var t_start,u,r,r2,subcookies,basic_timers={t_done:1,t_resp:1,t_page:1},ntimers=0,t_name,timer,t_other=[];if(impl.complete){return this;}
this.endTimer("t_done");u=d.URL.replace(/#.*/,'');r=r2=d.referrer.replace(/#.*/,'');subcookies=BOOMR.utils.getSubCookies(BOOMR.utils.getCookie(impl.cookie));BOOMR.utils.removeCookie(impl.cookie);if(subcookies!==null&&typeof subcookies.s!=="undefined"&&typeof subcookies.r!=="undefined"){r=subcookies.r;if(!impl.strict_referrer||r===r2){t_start=parseInt(subcookies.s,10);}}
else{BOOMR.warn("start cookie not set","rt");}
BOOMR.removeVar('t_done','t_page','t_resp','u','r','r2');for(t_name in impl.timers){if(!impl.timers.hasOwnProperty(t_name)){continue;}
timer=impl.timers[t_name];if(typeof timer.delta!=="number"){if(typeof timer.start!=="number"){timer.start=t_start;}
timer.delta=timer.end-timer.start;}
if(isNaN(timer.delta)){continue;}
if(basic_timers.hasOwnProperty(t_name)){BOOMR.addVar(t_name,timer.delta);}
else{t_other.push(t_name+'|'+timer.delta);}
ntimers++;}
if(ntimers){BOOMR.addVar({"u":u,"r":r});if(r2!==r){BOOMR.addVar("r2",r2);}
if(t_other.length){BOOMR.addVar("t_other",t_other.join(','));}}
impl.timers={};impl.complete=true;BOOMR.sendBeacon();return this;},is_complete:function(){return impl.complete;}};}(window));(function(w){var d=w.document;BOOMR=BOOMR||{};BOOMR.plugins=BOOMR.plugins||{};var images=[{name:"image-0.png",size:11483,timeout:1400},{name:"image-1.png",size:40658,timeout:1200},{name:"image-2.png",size:164897,timeout:1300},{name:"image-3.png",size:381756,timeout:1500},{name:"image-4.png",size:1234664,timeout:1200},{name:"image-5.png",size:4509613,timeout:1200},{name:"image-6.png",size:9084559,timeout:1200}];images.end=images.length;images.start=0;images.l={name:"image-l.gif",size:35,timeout:1000};var impl={base_url:'images/',timeout:15000,nruns:5,latency_runs:10,user_ip:'',cookie_exp:7*86400,cookie:'BA',results:[],latencies:[],latency:null,runs_left:0,aborted:false,complete:false,running:false,ncmp:function(a,b){return(a-b);},iqr:function(a)
{var l=a.length-1,q1,q3,fw,b=[],i;q1=(a[Math.floor(l*0.25)]+a[Math.ceil(l*0.25)])/2;q3=(a[Math.floor(l*0.75)]+a[Math.ceil(l*0.75)])/2;fw=(q3-q1)*1.5;l++;for(i=0;i<l&&a[i]<q3+fw;i++){if(a[i]>q1-fw){b.push(a[i]);}}
return b;},calc_latency:function()
{var i,n,sum=0,sumsq=0,amean,median,std_dev,std_err,lat_filtered;lat_filtered=this.iqr(this.latencies.sort(this.ncmp));n=lat_filtered.length;BOOMR.debug(lat_filtered,"bw");for(i=1;i<n;i++){sum+=lat_filtered[i];sumsq+=lat_filtered[i]*lat_filtered[i];}
n--;amean=Math.round(sum/n);std_dev=Math.sqrt(sumsq/n-sum*sum/(n*n));std_err=(1.96*std_dev/Math.sqrt(n)).toFixed(2);std_dev=std_dev.toFixed(2);n=lat_filtered.length-1;median=Math.round((lat_filtered[Math.floor(n/2)]+lat_filtered[Math.ceil(n/2)])/2);return{mean:amean,median:median,stddev:std_dev,stderr:std_err};},calc_bw:function()
{var i,j,n=0,r,bandwidths=[],bandwidths_corrected=[],sum=0,sumsq=0,sum_corrected=0,sumsq_corrected=0,amean,std_dev,std_err,median,amean_corrected,std_dev_corrected,std_err_corrected,median_corrected,nimgs,bw,bw_c;for(i=0;i<this.nruns;i++){if(!this.results[i]||!this.results[i].r){continue;}
r=this.results[i].r;nimgs=0;for(j=r.length-1;j>=0&&nimgs<3;j--){if(typeof r[j]==='undefined'){break;}
if(r[j].t===null){continue;}
n++;nimgs++;bw=images[j].size*1000/r[j].t;bandwidths.push(bw);bw_c=images[j].size*1000/(r[j].t-this.latency.mean);bandwidths_corrected.push(bw_c);}}
BOOMR.debug('got '+n+' readings',"bw");BOOMR.debug('bandwidths: '+bandwidths,"bw");BOOMR.debug('corrected: '+bandwidths_corrected,"bw");if(bandwidths.length>3){bandwidths=this.iqr(bandwidths.sort(this.ncmp));bandwidths_corrected=this.iqr(bandwidths_corrected.sort(this.ncmp));}else{bandwidths=bandwidths.sort(this.ncmp);bandwidths_corrected=bandwidths_corrected.sort(this.ncmp);}
BOOMR.debug('after iqr: '+bandwidths,"bw");BOOMR.debug('corrected: '+bandwidths_corrected,"bw");n=Math.max(bandwidths.length,bandwidths_corrected.length);for(i=0;i<n;i++){if(i<bandwidths.length){sum+=bandwidths[i];sumsq+=Math.pow(bandwidths[i],2);}
if(i<bandwidths_corrected.length){sum_corrected+=bandwidths_corrected[i];sumsq_corrected+=Math.pow(bandwidths_corrected[i],2);}}
n=bandwidths.length;amean=Math.round(sum/n);std_dev=Math.sqrt(sumsq/n-Math.pow(sum/n,2));std_err=Math.round(1.96*std_dev/Math.sqrt(n));std_dev=Math.round(std_dev);n=bandwidths.length-1;median=Math.round((bandwidths[Math.floor(n/2)]+bandwidths[Math.ceil(n/2)])/2);n=bandwidths_corrected.length;amean_corrected=Math.round(sum_corrected/n);std_dev_corrected=Math.sqrt(sumsq_corrected/n-Math.pow(sum_corrected/n,2));std_err_corrected=(1.96*std_dev_corrected/Math.sqrt(n)).toFixed(2);std_dev_corrected=std_dev_corrected.toFixed(2);n=bandwidths_corrected.length-1;median_corrected=Math.round((bandwidths_corrected[Math.floor(n/2)]
+bandwidths_corrected[Math.ceil(n/2)])/2);BOOMR.debug('amean: '+amean+', median: '+median,"bw");BOOMR.debug('corrected amean: '+amean_corrected+', median: '+median_corrected,"bw");return{mean:amean,stddev:std_dev,stderr:std_err,median:median,mean_corrected:amean_corrected,stddev_corrected:std_dev_corrected,stderr_corrected:std_err_corrected,median_corrected:median_corrected};},defer:function(method)
{var that=this;return setTimeout(function(){method.call(that);that=null;},10);},load_img:function(i,run,callback)
{var url=this.base_url+images[i].name
+'?t='+(new Date().getTime())+Math.random(),timer=0,tstart=0,img=new Image(),that=this;img.onload=function(){img.onload=img.onerror=null;img=null;clearTimeout(timer);if(callback){callback.call(that,i,tstart,run,true);}
that=callback=null;};img.onerror=function(){img.onload=img.onerror=null;img=null;clearTimeout(timer);if(callback){callback.call(that,i,tstart,run,false);}
that=callback=null;};timer=setTimeout(function(){if(callback){callback.call(that,i,tstart,run,null);}},images[i].timeout
+Math.min(400,this.latency?this.latency.mean:400));tstart=new Date().getTime();img.src=url;},lat_loaded:function(i,tstart,run,success)
{if(run!==this.latency_runs+1){return;}
if(success!==null){var lat=new Date().getTime()-tstart;this.latencies.push(lat);}
if(this.latency_runs===0){this.latency=this.calc_latency();}
this.defer(this.iterate);},img_loaded:function(i,tstart,run,success)
{if(run!==this.runs_left+1){return;}
if(this.results[this.nruns-run].r[i]){return;}
if(success===null){this.results[this.nruns-run].r[i+1]={t:null,state:null,run:run};return;}
var result={start:tstart,end:new Date().getTime(),t:null,state:success,run:run};if(success){result.t=result.end-result.start;}
this.results[this.nruns-run].r[i]=result;if(i>=images.end-1||typeof this.results[this.nruns-run].r[i+1]!=='undefined'){BOOMR.debug(this.results[this.nruns-run],"bw");if(run===this.nruns){images.start=i;}
this.defer(this.iterate);}else{this.load_img(i+1,run,this.img_loaded);}},finish:function()
{if(!this.latency){this.latency=this.calc_latency();}
var bw=this.calc_bw(),o={bw:bw.median_corrected,bw_err:parseFloat(bw.stderr_corrected,10),lat:this.latency.mean,lat_err:parseFloat(this.latency.stderr,10)};BOOMR.addVar(o);this.complete=true;BOOMR.sendBeacon();if(!isNaN(o.bw)){BOOMR.utils.setCookie(this.cookie,{ba:Math.round(o.bw),be:o.bw_err,l:o.lat,le:o.lat_err,ip:this.user_ip,t:Math.round(new Date().getTime()/1000)},(this.user_ip?this.cookie_exp:0),"/",null);}
this.running=false;},iterate:function()
{if(this.aborted){return false;}
if(!this.runs_left){this.finish();}
else if(this.latency_runs){this.load_img('l',this.latency_runs--,this.lat_loaded);}
else{this.results.push({r:[]});this.load_img(images.start,this.runs_left--,this.img_loaded);}},setVarsFromCookie:function(cookies){var ba=parseInt(cookies.ba,10),bw_e=parseFloat(cookies.be,10),lat=parseInt(cookies.l,10)||0,lat_e=parseFloat(cookies.le,10)||0,c_sn=cookies.ip.replace(/\.\d+$/,'0'),t=parseInt(cookies.t,10),p_sn=this.user_ip.replace(/\.\d+$/,'0'),t_now=Math.round((new Date().getTime())/1000);if(c_sn===p_sn&&t>=t_now-this.cookie_exp){this.complete=true;BOOMR.addVar({'bw':ba,'lat':lat,'bw_err':bw_e,'lat_err':lat_e});return true;}
return false;}};BOOMR.plugins.BW={init:function(config){var cookies;BOOMR.utils.pluginConfig(impl,config,"BW",["base_url","timeout","nruns","cookie","cookie_exp"]);if(config&&config.user_ip){impl.user_ip=config.user_ip;}
images.start=0;impl.runs_left=impl.nruns;impl.latency_runs=10;impl.results=[];impl.latencies=[];impl.latency=null;impl.complete=false;impl.aborted=false;BOOMR.removeVar('ba','ba_err','lat','lat_err');cookies=BOOMR.utils.getSubCookies(BOOMR.utils.getCookie(impl.cookie));if(!cookies||!cookies.ba||!impl.setVarsFromCookie(cookies)){BOOMR.subscribe("page_ready",this.run,null,this);}
return this;},run:function(){if(impl.running||impl.complete){return this;}
if(w.location.protocol==='https:'){BOOMR.info("HTTPS detected, skipping bandwidth test","bw");impl.complete=true;return this;}
impl.running=true;setTimeout(this.abort,impl.timeout);impl.defer(impl.iterate);return this;},abort:function(){impl.aborted=true;impl.finish();return this;},is_complete:function(){return impl.complete;}};}(window));