// This file contains javascript functions used to adapt anchors to enable event tracking in google analytics
// It uses jQuery

$(document).ready(function () {
	$('a').live('click',function(){try{if($(this).hasClass("GAeventbanner")){trackBannerto(this)}else if(this.protocol=="mailto:"){trackMailto(this)}else if(this.hostname==document.location.host){var path=this.pathname+this.search;var isDoc=path.match(/\.(?:doc|eps|jpg|png|svg|xls|ppt|pdf|xls|zip|txt|vsd|vxd|js|css|rar|exe|wma|mov|avi|wmv|mp3)($|\&|\?)/);if(isDoc)trackDownloadLinks(this)}else{trackExternalLinks(this)}}catch(e){}});$('form').live('submit',function(){try{myhost=location.hostname;if(this.action.indexOf(myhost)==-1&&this.action.indexOf('http')==0){trackExternalForms(this)}}catch(e){}});
});

function trackMailto(evnt){var href=evnt.href;var mailto=href.substring(7);_gaq.push(['_trackEvent','Mailto',mailto])}function trackBannerto(evnt){var e=evnt;while(e.tagName!="A"){e=e.parentNode}var lnk=(e.pathname.charAt(0)=="/")?e.pathname:"/"+e.pathname;if(e.search&&e.pathname.indexOf(e.search)==-1)lnk+=e.search;if(e.hostname!=location.host)lnk=e.hostname+lnk;else lnk=lnk;_gaq.push(['_trackEvent','Banner',lnk,$(this).attr("id")])}function trackExternalForms(evnt){_gaq.push(['_trackEvent','External Form',evnt.action])}function trackExternalLinks(evnt){var e=evnt;while(e.tagName!="A"){e=e.parentNode}var path=e.pathname+e.search;var lnk='';lnk=(e.pathname.charAt(0)=="/")?e.pathname:"/"+e.pathname;if(e.search&&e.pathname.indexOf(e.search)==-1)lnk+=e.search;lnk=e.hostname+lnk;_gaq.push(['_trackEvent','External',lnk])}function trackDownloadLinks(evnt){var e=evnt;while(e.tagName!="A"){e=e.parentNode}var lnk=(e.pathname.charAt(0)=="/")?e.pathname:"/"+e.pathname;if(e.search&&e.pathname.indexOf(e.search)==-1)lnk+=e.search;if(e.hostname!=location.host)lnk=e.hostname+lnk;else lnk=lnk;_gaq.push(['_trackEvent','Download',lnk])}
