(function($) {
	var player, playerAPIReady = false;
	
	function onPlayerStateChange(event) {
		if(event.data == 0) {
			removePlayer()
		}
	}
	
	window.onYouTubePlayerAPIReady = function() {
		playerAPIReady = true;
		$(function(){
			player = new YT.Player('player', {
				events: {
					'onStateChange': onPlayerStateChange
				}
			});			
		})
	}

	function removePlayer() {
		$("#player").remove();
	}



	$(function(){
		$.supersized({
			//Background image
			slides	:  [ { image : $(window).width()>=480?'/images/bg_photo2.jpg':'/images/bg_photo_small.jpg' } ]					
		});
		
		$("a.out").attr("target","_blank");
			
		$("#tour-dates").hover(
			function(){
				$(this).stop().animate({
					opacity: 0.9
					},400);
				},
			function(){
				$(this).animate({
					opacity: 0.4
					},400);
				}
		);
		
		
		$("#film").hover(
			function(){
				$(this).stop().animate({
					left:0,
					opacity: 0.8
					},400);
				},
			function(){
				$(this).animate({
					left:-105,
					opacity: 0.5
					},600);
				}
		);
		
		$("#amazon, #itunes").hover(
			function(){
				$(this).animate({
					left:0,
					opacity: 0.8
					},400);
				},
			function(){
				$(this).animate({
					left:-165,
					opacity: 0.5
					},600);
				}
		);		
		
		$("#player").contents().css("background-color","#000000");
		
	});
})(jQuery);

