// JavaScript Document
$(document).ready(function() {
	
	/*
	$('.entry a').click(function(event) {	
		
		event.preventDefault();
		var hyperlink = escape($(this).attr("href"));
		var title = escape($(this).text() + "&");
				
		$(this).attr('target', '_blank');
		$(this).attr("href", "http://www.planetdiet.org/external.php?title=" + title + "&exturl=" + hyperlink + "&cat=climate");	
		//location.href = "http://www.planetdiet.org/external.php?title=" + title + "&exturl=" + hyperlink + "&cat=climate"
					
	});
	*/
	
	$('.entry a').each(function() {	
		
		
		//Add branded prefix to external links
		//NOTE: DO NOT add branded prefix to INTERNAL links - Bern 20 June 2010
/*
		console.debug ($(this).text() + '  Hostname: ' + this.hostname);
//*/		
		
/*
		//if (-1 == hyperlink.indexOf (location.hostname)) {
		if (this.hostname != location.hostname) {
			console.debug ('NOT:' + hyperlink + ' is NOT a local link on ' + location.hostname);
		} else {
			console.debug ('IS:' + hyperlink + ' IS a local link on ' + location.hostname);
		}
//*/		
		
		if ((this.hostname != location.hostname) && (1==0)){
			var title = $(this).text();							
			var hyperlink = escape($(this).attr("href"));						
			
			var title_uri_encode = encodeURIComponent(title);	
			var url_uri_encode = encodeURIComponent(hyperlink);
			
			$(this).attr('target', '_blank');
			
			$(this).attr("href", "http://www.worldpreservationfoundation.org/external.php?title=" + title_uri_encode + "&exturl=" + url_uri_encode + "&cat=climate");
		}
					
	});


});
