/**
 * @author Colin McCrory
*/

var profileId = "UA-3741125-27";

/////////////////////////////////
// DO NOT EDIT PAST THIS POINT //
/////////////////////////////////

//Simplifies onload, you will no longer have to add an onload event call just call addLoadEvent
//Allows basic GA tracking (without external, document and mailto) on pages that do not have jquery
//ie: The Extranet
function addLoadEvent(func,arg){if(!arg){var oldonload=window.onload;if(typeof window.onload!='function'){window.onload=func}else{window.onload=function(){oldonload();func()}}}else{if(arg){oldonload=window.onload;if(typeof window.onload!='function'){window.onload=func(arg)}window.onload=function(){oldonload();func(arg)}}}}

//Attach the appropriate ga.js file based on protocol (http or https)
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

//Set up initial page tracking fucnction and run on load.
function callGA(){
	var pageTracker = _gat._getTracker(profileId);
	pageTracker._trackPageview();
}
addLoadEvent(callGA);



//The script below (external, document and mailto tracking) will only work if jquery is loaded first
if (typeof jQuery != "undefined"){ 
	$(document).ready(function(){
		
		//Track external links
		$("a[href*='http://']:not([href*='" + location.hostname + "'])").click(function(event){
			var url = $(this).attr('href')
			var pageTracker = _gat._getTracker(profileId);
			pageTracker._trackPageview('/external/' + url);
		});
		
		//Track document (doc, txt, rtf, pdf, zip, ppt, xls) links not hosted on DMS 
		$("a[href$='.doc'], a[href$='.txt'], a[href$='.rft'], a[href$='.pdf'], a[href$='.zip'], a[href$='.ppt'], a[href$='.xls']").click(function(event){
			var url = $(this).attr('href')
			var pageTracker = _gat._getTracker(profileId);
			pageTracker._trackPageview('/documents/' + url);
		});
		
		//Track All DMS links
		//This is needed because DMS links dont have an extension at the end
		$("a[href*='http://dms.']").click(function(event){
			var url = $(this).attr('href')
			var pageTracker = _gat._getTracker(profileId);
			pageTracker._trackPageview('/documents/' + url);
		});
		
		//Track mailto links
		$("a[href*='mailto']").click(function(event){
			var url = $(this).attr('href')
			var pageTracker = _gat._getTracker(profileId);
			pageTracker._trackPageview('/mailto/' + url);
		});
	});
}
