jQuery(document).ready(function() { 
	var host = window.location.host;
	
	// Links
	jQuery('a').each(function() {
		var a = jQuery(this);
		if(a.attr('href')){
			var href = a.attr('href');
			if ( (href.match(/^http/)) && (! href.match(host)) ) {
				  a.click(function() {
					//For external Links.
					pageTracker._trackPageview('/outgoing/' + href);
					//alert("being tracked");
				});
			} else {
				//Specialist Links. Later on this could be a function.
				if((href).match(/.zip|.pdf/i)){
					a.click(function() {
						pageTracker._trackPageview('/downloads/' + href);
					});
				}
				
				if((href).match(/mailto:/i)){
					a.click(function() { 
						pageTracker._trackPageview('/contacts/' + href);
					});
				}
			}
		}
	});
	
	//Image Maps - This later on could be converted to accept different elements.
	jQuery('area').each(function() {
		var a = jQuery(this);
		if(a.attr('href')){
			var href = a.attr('href');
			if ( (href.match(/^http/)) && (! href.match(host)) ) {
				  a.click(function() {
					//For external Links.
					pageTracker._trackPageview('/outgoing/' + href);
					//alert("being tracked");
				});
			} else {
				//Specialist Links. Later on this could be a function.
				if((href).match(/.zip|.pdf/i)){
					a.click(function() {
						pageTracker._trackPageview('/downloads/' + href);
					});
				}
				
				if((href).match(/mailto:/i)){
					a.click(function() { 
						pageTracker._trackPageview('/contacts/' + href);
					});
				}
			}
		}
	});
	
});