jQuery(document).ready(function($) {
	
	// Homepage slider using jQuery UI Tabs
	$('#slider').tabs({
		fx: { opacity: 'toggle' }
	}).tabs( 'rotate', 5500, true );
	
	// Add extra classes to WP calendar to make it look nicer
	$('td a').parent().addClass('has_link');
	$('td#today').addClass('today');
	
	// Add extra rows to WP calendar to space the body out a bit
	$('table#wp-calendar tbody tr:first').before('<tr class="jquery-added">&nbsp;</tr>');
	$('table#wp-calendar tbody tr:last').after('<tr class="jquery-added">&nbsp;</tr>');
	
	// Clear search field when it's clicked in
	$('#header form input[type=text]').focus(function() {
		$(this).val('');
	});
	
	// Below concerns the navigation on the 'Game' page, between news, reviews etc.
	
	// Hide all boxes. Show current.
	function hideExceptCurrent(current) {
		$('div#game-news').hide();
		$('div#game-reviews').hide();
		$('div#game-previews').hide();
		$('div#game-' + current).show();
	}
	
	// Remove 'current' class from all links. Add back to the one we need.
	function createCurrentHighlight(current) {
		$('li#game-news-link').removeClass('current');
		$('li#game-reviews-link').removeClass('current');
		$('li#game-previews-link').removeClass('current');
		$('li#game-' + current + '-link').addClass('current');
	}
	
	// Starting point
	hideExceptCurrent('news');
	createCurrentHighlight('news');
	
	// If News is clicked
	$('li#game-news-link').click(function() {
		hideExceptCurrent('news');
		createCurrentHighlight('news');
		return false;
	});
	
	// If Reviews is clicked
	$('li#game-reviews-link').click(function() {
		hideExceptCurrent('reviews');
		createCurrentHighlight('reviews');
		return false;
	});
	
	// If Previews is clicked
	$('li#game-previews-link').click(function() {
		hideExceptCurrent('previews');
		createCurrentHighlight('previews');
		return false;
	});
	
});
