if(typeof shell==="undefined"){shell={}}shell.metrics={initialize:function(){this.domainRegex=new RegExp("(https?:)//([^\\/]+).*","i");this.isGAEnabled=(typeof _gaq!=="undefined");if(this.isGAEnabled===false){return}_gaq.push(["_setDomainName",window.location.host]);_gaq.push(["_setAllowLinker",true]);_gaq.push(["_setAllowAnchor",true]);_gaq.push(["_gat._anonymizeIp"]);this.addGACustomVariables();_gaq.push(["_trackPageview"])},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);this.setGACustomVariable(2,"Subdomain",location.hostname)},addGAEventHandlers:function(){this.addGALinkHandler();this.addGAFormHandler();this.addGAEventHandlersMailLinks();this.addGAEventHandlersExternalLinks();this.addGAEventHandlersDownloads();this.addGAEventHandlersDifferentDomainLinks();this.addGAEventHandlersTagCloud();this.addGAEventHandlersSearch();this.addGAEventHandlersFollowUs();this.addGAEventHandlersTabs();this.addGAEventHandlersPromo();this.addGAEventHandlersAccordions();this.addGAEventHandlersGoogleMaps();this.addGAEventHandlersPersona();this.addGAEventHandlersForms();this.addGAEventHandlersLoggedUsers()},addGAEventHandlersLoggedUsers:function(){var category="User Domain",optLabel=document.URL,that=this,domain,array,has_just_logged;array=document.referrer.split("/");has_just_logged=array[array.lenght-1]==="users"&&array[array.length-2]==="LoginAction.action";if(document.referrer===document.location.href||has_just_logged){if($("#welcome_fragment > a:first").length!==0){domain=$("#welcome_fragment > a:first").attr("id").split("@")[1];that.trackGAEvent(category,domain,optLabel)}}},addGAEventHandlersForms:function(){var category="Form",optLabel=document.URL,that=this;if($("li.error").length!==0){that.trackGAEvent(category,"Validation Error",optLabel)}if($("li.error.voucher").length!==0){that.trackGAEvent(category,"Voucher Validation Error",optLabel)}if($("div#form_submit_success").length!==0){that.trackGAEvent(category,"Submit Successful",optLabel)}if($("div#form_submit_fail").length!==0){that.trackGAEvent(category,"Submit Failed",optLabel)}},addGAEventHandlersPersona:function(){var handler,that=this;handler=function(){var persona=$(this).text().trim();that.trackGAEvent("Persona",persona,document.URL);return true};$(".shell_for ul li a").each(function(){that.bindEvents($(this),handler)})},addGAEventHandlersGoogleMaps:function(){var category="Google Maps",action,optLabel=document.URL,i,map,clickHandler,typeChangedHandler,that=this;if(typeof maps==="undefined"){return}this.mapEvents={};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(that.mapEvents[name]===true){return}action="Placemark - "+name;that.trackGAEvent(category,action,optLabel);that.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).text().trim();if($(this).parent().hasClass("selected")){return}that.trackGAEvent(category,action,optLabel);return true};$("div.accordion h4 a").each(function(){that.bindEvents($(this),handler)})},addGAEventHandlersPromo:function(){var category="Banners",action="Expandable Promo",handler,that=this;handler=function(event){var optLabel=$(this).attr("title").trim();that.trackGAEvent(category,action,optLabel);return true};$(".module_promo a").each(function(){that.bindEvents($(this),handler)})},addGAEventHandlersDifferentDomainLinks:function(){var category="Different Domain Links",action,optLabel,handler,items,that=this;handler=function(event){action=$(this).attr("href");optLabel=document.URL;that.trackGAEvent(category,action,optLabel);return true};items=$('a:not([href~="'+document.location.host+'"])');items=items.filter(':not([href^="/"])');items=items.filter(':not([href^="#"])');items=items.filter(':not([href^="java"])');items=items.filter(':not([href^="/")');items=items.filter(":not(.metrics_download)");items=items.filter(":not(.metrics_mailto)");items.each(function(){that.bindEvents($(this),handler)})},addGAEventHandlersDownloads:function(){var category="Downloads",action,optLabel,handler,that=this;handler=function(event){var filename=$(this).attr("href").replace(/^.*\//,"");action=filename.replace(/^.*\./,"").toUpperCase();optLabel=filename+", "+document.URL;that.trackGAEvent(category,action,optLabel);return true};$(".metrics_download").each(function(){that.bindEvents($(this),handler)})},addGAEventHandlersExternalLinks:function(){var category,tmp,action,optLabel=document.URL,handler,that=this;handler=function(event){tmp=decodeURIComponent($(this).attr("href"));action=tmp.replace(/.*&URL=/,"");category="External Links";that.trackGAEvent(category,action,optLabel);return true};$(".metrics_external").each(function(){that.bindEvents($(this),handler)})},addGAEventHandlersMailLinks:function(){var category="Social",action="Mail to Shell",optLabel,tmp,handler,that=this;handler=function(event){tmp=$(this).attr("href").replace(/^mailto:/,"");optLabel=tmp+", "+document.URL;that.trackGAEvent(category,action,optLabel);return true};$(".metrics_mailto").each(function(){that.bindEvents($(this),handler)})},addGAEventHandlersTagCloud:function(){var plainURL=document.URL.replace(/(\?.*)$/,""),category="Tag Cloud - "+plainURL,optLabel,action,handler,that=this;handler=function(event){action=$(this).text().trim();optLabel=$(this).attr("href");that.trackGAEvent(category,action,optLabel);return true};$(".metrics_tag").each(function(){that.bindEvents($(this),handler)})},addGAEventHandlersSearch:function(){var category="Internal Search",optLabel=document.URL,action,handler,that=this;handler=function(event){action=$(this).prev().find("input").attr("value").trim();if(action!=="Search"){that.trackGAEvent(category,action,optLabel)}return true};$("form.search input.button").each(function(){that.bindEvents($(this),handler)})},addGAEventHandlersFollowUs:function(){var handler,social_handler,that=this;handler=function(event){var action=$(this).attr("href"),category="Social",optLabel=document.URL;that.trackGAEvent(category,action,optLabel);return true};social_handler=function(event){var network=$(this).text().trim(),action="Follow",optLabel=$(this).attr("href"),optPath=document.URL;that.trackGASocial(network,action,optLabel,optPath);return true};$(".follow_us a").each(function(){that.bindEvents($(this),handler);that.bindEvents($(this),social_handler)})},addGAEventHandlersTabs:function(){var isSelected=false,category="Tabs",optLabel=document.URL,handler,action,that=this;this.lastSentTab="";handler=function(event){var action=$(this).text().trim();if(that.lastSentTab===action){return true}that.trackGAEvent(category,action,optLabel);that.lastSentTab=action;return true};$(".tab_module li h2 a").each(function(){isSelected=$(this).parent().parent().hasClass("selected");action=$(this).text().trim();if(isSelected){that.trackGAEvent(category,action,optLabel);that.lastSentTab=action}that.bindEvents($(this),handler)})},addGALinkHandler:function(){var href,result,handler,that=this;$(".ga_link_by_post").each(function(){if($(this).hasClass("metrics_download")){return}href=$(this).attr("href");result=that.domainRegex.exec(href);if(that.checkDomain(result)===false){return}handler=function(event){_gaq.push(["_link",href]);return true};that.bindEvents($(this),handler)})},addGAFormHandler:function(){var that=this,action,result,handler;$("form").each(function(){action=$(this).attr("action");result=that.domainRegex.exec(action);if(that.checkDomain(result)===false){return}handler=function(event){_gaq.push(["_linkByPost",$(this)[0]]);return true};$(this).bind("submit",handler)})},bindEvents:function(element,handler){element.bind("click 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.initialize();var youTubeObject={};function onYouTubePlayerReady(playerId){var videoUrl,videoId,ytPlayer=document.getElementById(playerId),category;youTubeObject={};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,event="Play",label=document.URL,value=percentage,ext=file.split(".").pop().toLowerCase(),filename=file.split("/").pop();if(ext==="mp3"||ext==="ogg"){category="Audio - "+filename}else{if(ext==="mp4"||ext==="m4v"){category="Video - "+filename}else{return}}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 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)}$(document).ready(function(){shell.metrics.setupGAEvents()});
