$(function() {
		
	$('#menu').css('display', 'none'); // Set all DIVs to hidden before the animation starts/page is loaded
	$('#content').css('display', 'none'); // Set all DIVs to hidden before the animation starts/page is loaded
	$('#ship').css('display', 'none'); // Set all DIVs to hidden before the animation starts/page is loaded

	$("#mp3").jmp3(); // jMP3 player basics

	// Font rendering for "special" menu text
	Cufon.replace('#menu a', { hover: true });	
	Cufon.replace('a.cufon', { hover: true });

	$('a.artist_thumbnail').click(function() {

		// Replace "Current" class to show full opacity on correct thumbnail image
		$('img.image_box_image').removeClass("current");
	
		// Hide the current image to show the "loading" background
		$('img.image_box_image').hide();
		$('img.image_box_loader').show();

		$('div#image_description').hide();
		
		// Load new description
		link = $(this).attr("href") + ' div#image_description';
		$('div#image_description').load(link, function() {
			$('div#image_description').fadeIn(1000);		
		});
		
		// Load new image in the background
		var img = new Image();
		
		img.onload = function() { 
			$('img.image_box_loader').hide();
			$('img.image_box_image').attr("src", img.src + "resize/231/224/");
			$('a#image_box_link').attr("href", img.src);
			//$('img.image_box_image').css("display", "block");
			$('img.image_box_image').fadeIn(1000);
		}
		
		// Load image
		img.src = $(this).attr("image");
		
		return false;

	});
	
});

$(document).ready(function(){

	$("#ship").fadeIn(1000);
	$('#menu').show(2000, function() {
		$("#content").fadeIn(600);
	});
	
	$('.slideshow').cycle({ speed:  700 });	// Cycle through the artist DIVs
	$('a.lightbox').lightBox(); // Lightbox call


	$("#menu a").hover(function () {

		if(!$(this).hasClass('current')) {
			$("#menu a").dequeue();
			$(this).effect("pulsate", { times: 1 }, 500);
		}
		
	}, function(){ } );
	
	
	/* Swaying ship animation */
	
	angle = 0; // Starting position
	direction = 1;

	setInterval(function() {

		$("#swaying_ship").rotate(angle);
		
		if(direction == 1) {
			angle += 0.3;
		} else {
			angle -= 0.2;
		}
		
		if(angle < -10) {
			direction = 1;
		}
		if(angle > 0) {
			direction = -1;
		}

	}, 50);
	
	
});
