$(document).ready(function() {

	$('#container').corner();

	var loadContent = function (id) {
		$('#loader').fadeIn('slow', function () {

			$.get('projects/?project=' + id.replace('project:', '') + "&_nocache=" + +new Date, function (html) {
				$('#ajax-content').html(html);
				$('#loader').fadeOut('slow');
				SyntaxHighlighter.highlight();
			});
		});
	}

	// Fix hover classes for project menu
	$('#right li').hover(
		function (e) {
			$(this).addClass('hover');
		},
		function (e) {
			$(this).removeClass('hover');
		}
	)

	// Hook click events to load info and such
	.click(function () {
		if (location.hash.replace('project:', '') === this.id) return;

		location.hash = 'project:' + this.id;

		$(this).addClass('active').siblings().removeClass('active');
		loadContent('project:' + this.id);
	})

	// Remove actual links (graceful)
	.find('a').css('background-color', 'transparent').attr('href', 'javascript:;');

	// Trigger load page
	$(location.hash ? location.hash.replace('project:', '') : '#960-gridder').click();
});
