// Check whether links are external:
$.extend($.expr[':'],{
    external: function(a,i,m) {
        if(!a.href) {return false;}
        return a.hostname && a.hostname !== window.location.hostname;
    }
});
$(function() {
	$('a:external').attr('target','_blank'); //make external links open new window
	
	//$("a[href*='http://']:not([href*='"+location.hostname+"'])").attr("target","_blank"); //alternative solution
	
	//prevent widows in content
	$('article p').html(function(i,html){
  		return html.replace(/ (\S+)$/,'&nbsp;$1');
	});
});

var _gaq = _gaq || [];
_gaq.push(
    ['_setAccount', 'UA-5459139-1'],
    ['_setDomainName', 'www.castlesblog.com'],
    ['_trackPageview']
);
(function() {
	var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
	ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
	(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
})();