//this javascript check if the link is an external link and apply the tracker code

function isExternalURL(url){
	var hostname = window.location.hostname;
	hostname = hostname.replace("www.","").toLowerCase();


	return (url.indexOf("http://")!=-1 && url.indexOf(hostname)==-1) ? true : false;
}

//the main function
function checkExternalURL(){
	var a = document.getElementsByTagName("a");
	
	for (var i=0;i<a.length;i++){
		if(isExternalURL(a[i].href)){
			a[i].setAttribute('rel','external');
			a[i].target = "_blank";
		

			a[i].onclick = function(){
				var url = this.href;
				
				//remove the protocol
				url = url.replace('http://','');
			
				//urchin tracker version
				//urchinTracker('/external/'+url)
				//pagetracker version
				pageTracker._trackPageview('/external/'+url);

			}
		}
	};
	
}

//load the function on DOM ready or window load

//prototype
Event.observe(window, 'load', checkExternalURL);