Cufon.replace('h1, h2, h3, h4, #main_menu a');

$(document).ready(function() {
	// setup external links (so we validate strict)
	$('a.external').click(function() {
		window.open($(this).attr('href'));
		return false;
	});
	
	// if the body is shorter than the window then reposition the footer to the bottom, so it doesn't look out of place
	var windowHeight = $(document).height();
	var bodyHeight = $('body').height();
	if(windowHeight > bodyHeight) {
		$('#footer_shadow').css({background:"none"});
		$('#footer').css({position:"absolute", bottom:"0"});
		$('#container').css({height:windowHeight+"px"});
	}
	
	// add our background
	var currentTime = new Date();
	var hour = currentTime.getHours();
	if(hour < 6 || hour > 23) {
		hour = 23;
	}
	$('body').css({backgroundImage:"url(/_images/backgrounds/"+hour+".jpg)"});
	
	// add menu states without messy class code
	var path = window.location.pathname.split('/');
	path = '/'+path[1]+'/';
	if(path == '//') path = '/';
	$('#main_menu li a').each(function() {
		if($(this).attr('href') == path) {
			$(this).addClass('selected');
		}
	});
	
	// Try to rid the world of IE6
	if($.browser.msie && $.browser.version.substr(0,1) == 6) {
		$('#wrapper').html('<h2>Sorry</h2><p>Your internet browser (Internet explorer 6, released 2001) is too old to use this website. I strongly recommend that you upgrade now.</p><ul><li><a href="http://www.microsoft.com/windows/Internet-explorer/default.aspx">Upgrade to Internet Explorer 8</a></li><li><a href="http://www.mozilla-europe.org/en/firefox/">Switch to Mozilla Firefox 3 - Web developers choice</a></li><li><a href="http://www.google.com/chrome">Switch to Google Chrome - PC users choice</a></li><li><a href="http://www.apple.com/safari/">Switch to Apple Safari 4 - Mac users choice</a></li></ul>');
		$('body').css({background:'#000'});
	}
	
	// Try to make IE7 people upgrade again
	if($.browser.msie && $.browser.version.substr(0,1) == 7) {
		$('#main_content').prepend('<p><a href="http://www.microsoft.com/windows/Internet-explorer/default.aspx">Internet Explorer 8 is available (You\'re using 7) - Download it now</a></p>');
	}
	
});