function background_resolution_replace() {
	var resolution = '1680x1050';
	if (screen.width == 1024 && screen.height == 768) {
		resolution = '1024x768';
	}
	if (screen.width == 1280 && screen.height == 1024) {
		resolution = '1280x1024';
	}
	if (screen.width == 1280 && screen.height == 800) {
		resolution = '1280x800';
	}
	if (screen.width == 1600 && screen.height == 900) {
		resolution = '1600x900';
	}
	$('.background').each(function(el, index) {
		$(this).attr('href', $(this).attr('href').replace('1680x1050', resolution));
	});
}

function featureSwitch() {
	var $active = $('#feature a.active');

	if ( $active.length == 0 ) $active = $('#feature a:last');

	// use this to pull the images in the order they appear in the markup
	var $next =  $active.next().length ? $active.next()
		: $('#feature a:first');

	$active.addClass('last-active');

	$next.css({opacity: 0.0})
		.addClass('active')
		.animate({opacity: 1.0}, 1000, function() {
			$active.removeClass('active last-active');
		});
}

$(function() {
	// Homepage slideshow
	if ($('#feature').length) {
		setInterval( "featureSwitch()", 5000 );
		if (!$('#feature a.active').length) {
			$('#feature a:first').addClass('active');
		}
	}

	// Highlight the current navigation
	$('#navigation a img.active').each(function(index, el) {
		$(el).attr('src',  $(el).attr('src').replace('off.jpg', 'on.jpg'));
	});

	// Pre-load all of the images
	$('#navigation a img').each(function(index, el) {
		$(el).css('background-image', "url("+$(el).attr('src').replace('off.jpg', 'on.jpg')+")");
	});

	// Hovers
	$('#navigation a img').hover(function() {
		$(this).attr('src', $(this).attr('src').replace('off.jpg', 'on.jpg'));
	}, function() {
		if (!$(this).hasClass('active')) {
			$(this).attr('src', $(this).attr('src').replace('on.jpg', 'off.jpg'));
		}
	});

	$(window).resize(function() {
		// Min-height
		$('#body').css('min-height', '200px'); // Absolute minimum.
		$('#body').css('min-height', $(document).height() - $('#header').outerHeight() - $('#navigation').outerHeight() - $('#footer').outerHeight() - ($('#body').outerHeight() - $('#body').height()));
	});
	$(window).resize();
});
