if(typeof shell==="undefined"){shell={}}var youTubeObject={};var mapEvents={};shell.Metrics=new Class({initialize:function(){this.domainRegex=new RegExp("(https?:)//([^\\/]+).*","i");this.isGAEnabled=(typeof _gaq!=="undefined");if(this.isGAEnabled===false){return}_gaq.push(["_setDomainName","none"]);_gaq.push(["_setAllowLinker",true]);_gaq.push(["_setAllowHash",false]);_gaq.push(["_setAllowAnchor",true]);_gaq.push(["_gat._anonymizeIp"]);this.addGACustomVariables();_gaq.push(["_trackPageview"]);_gaq.push(["_trackPageLoadTime"])},setupGAEvents:function(){if(this.isGAEnabled){this.addGAEventHandlers()}},trackGASocial:function(network,action,optLabel,optPath){if(!this.isGAEnabled){return}_gaq.push(["_trackSocial",network,action,optLabel,optPath])},trackGAEvent:function(category,action,optLabel,optValue){if(!this.isGAEnabled){return}_gaq.push(["_trackEvent",category,action,optLabel,optValue])},trackGAExternalEvent:function(category,action,optLabel,optValue){this.trackGAEvent(category,action,optLabel,optValue)},setGACustomVariable:function(index,name,value,scope){_gaq.push(["_setCustomVar",index,name,value,scope])},deleteGACustomVariable:function(index){_gaq.push(["_deleteCustomVar",index])},addGACustomVariables:function(){var short_url=location.pathname.replace(/^\/home\/[^\/]*\/[^\/]*/,"");this.setGACustomVariable(1,"URL",short_url,3);this.setGACustomVariable(2,"Subdomain",location.hostname,3)},addGAEventHandlers:function(){this.addGALinkHandler();this.addGAFormHandler();this.addGAEventHandlersMailLinks();this.addGAEventHandlersExternalLinks();this.addGAEventHandlersDownloads();this.addGAEventHandlersTagCloud();this.addGAEventHandlersSearch();this.addGAEventHandlersPageTools();this.addGAEventHandlersFollowUs();this.addGAEventHandlersTabs();this.addGAEventHandlersPromo();this.addGAEventHandlersOther();this.addGAEventHandlersAccordions();this.addGAEventHandlersGoogleMaps();this.addGAEventHandlersPersona()},addGAEventHandlersPersona:function(){var handler,that=this;handler=function(){var persona=this.get("text").trim();that.trackGAEvent("Persona",persona,document.URL);return true};$$(".shell_for ul li a").each(function(elem){that.bindEvents(elem,handler)})},addGAEventHandlersGoogleMaps:function(){var category="Google Maps",action,optLabel=document.URL,i,map,clickHandler,typeChangedHandler,that=this;if(typeof maps==="undefined"){return}typeChangedHandler=function(){var mapType=this.getCurrentMapType().getName();action="Map Style - "+mapType;that.trackGAEvent(category,action,optLabel)};clickHandler=function(overlay,latlng,overlaylatlng){var name;if(!overlay||!overlay.da){return true}name=overlay.da.name;if(mapEvents[name]===true){return}action="Placemark - "+name;that.trackGAEvent(category,action,optLabel);mapEvents[name]=true;return true};for(i=0;i<maps.length;i+=1){map=maps[i];GEvent.addListener(map,"click",clickHandler);GEvent.addListener(map,"maptypechanged",typeChangedHandler)}},addGAEventHandlersAccordions:function(){var category="Accordions",optLabel=document.URL,that=this,handler;handler=function(event){var action=this.get("text").trim();if(this.getParent().hasClass("selected")){return}that.trackGAEvent(category,action,optLabel);return true};$$("div.accordion h4 a").each(function(elem){that.bindEvents(elem,handler)})},addGAEventHandlersPromo:function(){var category="Banners",action="Expandable Promo",handler,that=this;handler=function(event){var optLabel=this.get("title").trim();that.trackGAEvent(category,action,optLabel);return true};$$(".module_promo a").each(function(elem){that.bindEvents(elem,handler)})},addGAEventHandlersDownloads:function(){var category="Downloads",action,optLabel,handler,that=this;handler=function(event){var filename=this.get("href").replace(/^.*\//,"");action=filename.replace(/^.*\./,"").toUpperCase();optLabel=filename+", "+document.URL;that.trackGAEvent(category,action,optLabel);return true};$$(".metrics_download").each(function(elem){that.bindEvents(elem,handler)})},addGAEventHandlersExternalLinks:function(){var category,tmp,domain,action,optLabel=document.URL,handler,that=this;handler=function(event){tmp=decodeURIComponent(this.get("href"));domain=tmp.replace(/^(.*URL=)https?:\/\/(www.)?([^\/]*)(.*)$/,"$3");action=tmp.replace(/.*&URL=/,"");category="External Links - "+domain;that.trackGAEvent(category,action,optLabel);return true};$$(".metrics_external").each(function(elem){that.bindEvents(elem,handler)})},addGAEventHandlersMailLinks:function(){var category="Social",action="Mail to Shell",optLabel,tmp,handler,that=this;handler=function(event){tmp=this.get("href").replace(/^mailto:/,"");optLabel=tmp+", "+document.URL;that.trackGAEvent(category,action,optLabel);return true};$$(".metrics_mailto").each(function(elem){that.bindEvents(elem,handler)})},addGAEventHandlersTagCloud:function(){var plainURL=document.URL.replace(/(\?.*)$/,""),category="Tag Cloud - "+plainURL,optLabel,action,handler,that=this;handler=function(event){action=this.get("text").trim();optLabel=this.get("href");that.trackGAEvent(category,action,optLabel);return true};$$(".metrics_tag").each(function(elem){that.bindEvents(elem,handler)})},addGAEventHandlersSearch:function(){var category="Internal Search",optLabel=document.URL,action,handler,that=this;handler=function(event){action=this.getPrevious().getElement("input").get("value").trim();if(action!=="Search"){that.trackGAEvent(category,action,optLabel)}return true};$$("form.search input.button").each(function(elem){that.bindEvents(elem,handler)})},addGAEventHandlersOther:function(){var category="Other",optLabel=document.URL,handler,action,that=this;handler=function(event){action=this.get("text").trim();that.trackGAEvent(category,action,optLabel);return true};$$(".page_tools .printer a").each(function(elem){that.bindEvents(elem,handler)})},addGAEventHandlersPageTools:function(){var handler,social_handler,bookmark,that=this;handler=function(event){var action=this.get("text").trim(),category="Social",optLabel=document.URL;that.trackGAEvent(category,action,optLabel);return true};social_handler=function(event){var network=this.get("text").trim(),action="Share",optLabel=this.get("href"),optPath=document.URL;that.trackGASocial(network,action,optLabel,optPath);return true};bookmark=$$(".page_tools .bookmark>a");$$(".page_tools a").each(function(item){if(item===bookmark[0]){return}that.bindEvents(item,handler);if(item.get("id")===null){return}that.bindEvents(item,social_handler)})},addGAEventHandlersFollowUs:function(){var handler,social_handler,that=this;handler=function(event){var action=this.get("href"),category="Social",optLabel=document.URL;that.trackGAEvent(category,action,optLabel);return true};social_handler=function(event){var network=this.get("text").trim(),action="Follow",optLabel=this.get("href"),optPath=document.URL;that.trackGASocial(network,action,optLabel,optPath);return true};$$(".follow_us a").each(function(elem){that.bindEvents(elem,handler);that.bindEvents(elem,social_handler)})},addGAEventHandlersTabs:function(){var is_selected=false,category="Tabs",optLabel=document.URL,handler,action,that=this;this.last_sent_tab="";handler=function(event){var action=this.get("text").trim();if(that.last_sent_tab===action){return true}that.trackGAEvent(category,action,optLabel);that.last_sent_tab=action;return true};$$(".tab_module li h2 a").each(function(elem){is_selected=elem.getParent().getParent().hasClass("selected");action=elem.get("text").trim();if(is_selected){that.trackGAEvent(category,action,optLabel);that.last_sent_tab=action}that.bindEvents(elem,handler)})},addGALinkHandler:function(){var href,result,handler,that=this;$$(".ga_link_by_post").each(function(elem){if(elem.hasClass("metrics_download")){return}href=elem.get("href");result=that.domainRegex.exec(href);if(that.checkDomain(result)===false){return}handler=function(event){_gaq.push(["_link",href]);return true};that.bindEvents(elem,handler)})},addGAFormHandler:function(){var that=this,action,result,handler;$$("form").each(function(elem){action=elem.get("action");result=that.domainRegex.exec(action);if(that.checkDomain(result)===false){return}handler=function(event){_gaq.push(["_linkByPost",elem]);return true};elem.addEvent("submit",handler)})},bindEvents:function(element,handler){element.addEvent("click",handler);element.addEvent("keypress",handler)},checkDomain:function(string){if(!string){return false}if(string.length!==3){return false}if(string[1]===window.location.protocol&&string[2]===window.location.host){return false}return true}});shell.metrics=new shell.Metrics();function onYouTubePlayerReady(playerId){var videoUrl,videoId,ytPlayer=document.getElementById(playerId),category;playerId="_"+playerId;videoUrl=ytPlayer.getVideoUrl();videoId=videoUrl.replace(/.*?v=(.*)\&.*/,"$1");category="YouTube - "+videoUrl;youTubeObject[playerId]={};youTubeObject[playerId].started=false;youTubeObject[playerId].stateChange=function(newState){if(newState===1&&youTubeObject[playerId].started===false){youTubeObject[playerId].started=true;shell.metrics.trackGAEvent(category,"Started",document.URL)}if(newState===0){youTubeObject[playerId].started=false;shell.metrics.trackGAEvent(category,"Completed",document.URL)}};youTubeObject[playerId].qualityChange=function(suggestedQuality){var quality="Quality - "+suggestedQuality;shell.metrics.trackGAEvent(category,quality,document.URL)};ytPlayer.addEventListener("onStateChange","youTubeObject."+playerId+".stateChange");ytPlayer.addEventListener("onPlaybackQualityChange","youTubeObject."+playerId+".qualityChange")}var jPlayerMetrics={reportsSent:[],flush:function(playerID){this.reportsSent[playerID]=-1},sendGAEvent:function(file,percentage){var category="Audio - "+file.replace(/^.*\//,""),event="Play",label=document.URL,value=percentage;if(percentage===1){shell.metrics.trackGAEvent(category,"Started",label)}if(percentage===99){shell.metrics.trackGAEvent(category,"Completed",label)}shell.metrics.trackGAEvent(category,event,label,value)},sendStats:function(playerID,file,percentage){this.reportsSent[playerID]=percentage;this.sendGAEvent(file,percentage)},tryToSend:function(playerID,file,percentage,p){var reportSent=this.reportsSent[playerID];if(percentage>=p&&reportSent<p){this.sendStats(playerID,file,p)}},track:function(playerID,file,percentage){this.tryToSend(playerID,file,percentage,99);this.tryToSend(playerID,file,percentage,75);this.tryToSend(playerID,file,percentage,50);this.tryToSend(playerID,file,percentage,25);this.tryToSend(playerID,file,percentage,1)}};function flash_transition(objJSON){if(!window.location.href.match(/\.content\.shell\.com/)){if(objJSON.onclick!==""&&objJSON.onclick!=="null"){eval(objJSON.onclick)}}if(objJSON.href!==""){if(objJSON.target==="_blank"){window.open(objJSON.href)}else{window.location.href=objJSON.href}}}function shell_flash(swffile,swfevent){var category="Flash",action=swfevent,label=document.URL,file=swffile.replace(/^.*\//,""),value;if(/^(?:videoFullScreenOn|videoFullScreenOff|videoVolumeMute|videoVolume.*|videoSeek.*|videoPause|videoPlayClicked)$/.test(swfevent)){return}if(/\.mp4$/.test(swffile)===false&&/\.flv$/.test(swffile)===false){category="Banner";action="Expandable Promo";shell.metrics.trackGAEvent(category,action,file+", "+label);return}category="Video - "+file;if(swfevent==="videoPlay"){shell.metrics.trackGAEvent(category,"Started",label);action="Play";value=1}else{if(swfevent.match(/^video([0-9]*%)Played$/)){action="Play";value=swfevent.replace(/^video([0-9]*%)Played$/,"$1");value=parseInt(value,10)}else{if(swfevent==="videoComplete"){shell.metrics.trackGAEvent(category,"Completed",label);action="Play";value=99}else{if(swfevent==="videoCaptionsOn"){action="Captions On"}else{if(swfevent==="videoCaptionsOff"){action="Captions Off"}}}}}shell.metrics.trackGAEvent(category,action,label,value)}window.addEvent("domready",function(){shell.metrics.setupGAEvents()});
