$(function(){
   $("a").click( function() { 
      
      theURL = this.href;  
      prefix = ""
      
      //remove trailing / if present
      if (theURL.charAt(theURL.length - 1) == "/"){
		      theURL = theURL.substring(0, theURL.length - 1);
		}
		
      //find end of URL
      if (theURL.indexOf("?") + 1){
		   end = theURL.indexOf("?");
		}else{
		   end = theURL.length;
		}
		
		//find beginning of URL
		if (theURL.indexOf("http://") + 1){
		   begin = 7;
		}else if(theURL.indexOf("https://") + 1){
		   begin = 8;
		}else{
		   begin = 0;
		}
		
		//host is defined on the calling page as Request.ServerVariables("HTTP_HOST")
		//check to see if URL is local
      if (theURL.indexOf(host) + 1){
         //redefine beginning for local including trailing /
         begin = begin + host.length + 1;
         //extentions to run analytics on
         var Extensions = ['PDF', 'DOC', 'XLS'];
         for(var index = 0; index < Extensions.length; index++ ){
            if (theURL.toUpperCase().indexOf("." + Extensions[index]) != -1){
               prefix = "/downloads/"+ Extensions[index] + "/";
               end = theURL.toUpperCase().indexOf("." + Extensions[index]) + 1 + Extensions[index].length;
            }
         }
		}else{
		   prefix = "/outgoing/";
		}
		if (prefix != "") {
		   cleanedURL = theURL.substring(begin, end).replace(/\//g, "|");
//alert(prefix + cleanedURL + " " + theURL);
		   urchinTracker(prefix + cleanedURL);
		}
//the rest of this will be removed
//else{
//   alert("local");
//}
//return false;
   });
});