$(document).ready(function()
	{

	$('a[href="#top"]').click(function()
		{
			$("html, body").animate(
				{ scrollTop:0 }, 500
			);
			return false;
		}
	);

	$('a').each(function(){
		if (this.href.match('^https?://(?!'+document.location.hostname+')')) {
			this.target = '_blank';
		}
	});

});

// Fix for iOS rotate bug
if (navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i)) {
	var viewportmeta = document.querySelectorAll('meta[name="viewport"]')[0];
	if (viewportmeta) {
		viewportmeta.content = 'width=device-width, minimum-scale=1.0, maximum-scale=1.0';
		document.body.addEventListener('gesturestart', function() {
		viewportmeta.content = 'width=device-width, minimum-scale=0.25, maximum-scale=1.6';
		}, false);
	}
}
