$(document).ready(function() {
	$('a.panel').click(function () {
		$('a.panel').removeClass('selected');
		$(this).addClass('selected');		
		current = $(this);
		
		$('#wrapper').scrollTo($(this).attr('href'), 900);		
		return false;
	});

	$("img").hide().fadeIn(700);

//	$("#embedcode").hide();

	$(window).resize(function () {
		// resizePanel();
	});
	
	$('#slideshow').cycle({ 
    	sync:		0,
    	speed:		800,
    	timeout:	2500,
    	sync:       1,
    	pause:      1
	});

	$('#album-cover div.back').hide().css('left', 0);

	function stuySideChange(front) {
        if (front) {
            $(this).parent().find('div.front').show();
            $(this).parent().find('div.back').hide();
            
        } else {
            $(this).parent().find('div.front').hide();
            $(this).parent().find('div.back').show();
        }
    }
	
	$('#flipper a#tracklisting').click(
		function () {
			$('#album-cover').find('div').stop().rotate3Di('toggle', 250, {direction: 'anticlockwise', sideChange: stuySideChange, easing: 'easeInExpo'});
		},
		function () {
			$('#album-cover').find('div').stop().rotate3Di('toggle', 400, {sideChange: stuySideChange, easing: 'easeOutExpo'});
		}
	);

	$("a#contact").fancybox({
		'centerOnScroll'	: true,
		'padding'			: 10,
		'margin'			: 0,
		'width'				: 640,
		'height'			: '75%',
		'titlePosition'		: 'inside',
		'overlayOpacity'	: 0.5,
		'overlayColor'		: '#666',
		'type'				: 'iframe',
		'showNavArrows'		: false
	});

	$("a#embed").fancybox({
		'centerOnScroll'	: true,
		'padding'			: 10,
		'margin'			: 0,
//		'transitionIn'		: 'elastic',
//		'transitionOut'		: 'elastic',
		'titlePosition'		: 'inside',
		'overlayOpacity'	: 0.5,
		'overlayColor'		: '#666',
		'showNavArrows'		: false
	});

	$("a#credit").fancybox({
		'centerOnScroll'	: true,
		'padding'			: 10,
		'margin'			: 0,
//		'transitionIn'		: 'elastic',
//		'transitionOut'		: 'elastic',
		'titlePosition'		: 'inside',
		'overlayOpacity'	: 0.5,
		'overlayColor'		: '#666',
		'showNavArrows'		: false
	});

});

function resizePanel() {
	width = $(window).width();
	height = $(window).height();

	mask_width = width * $('.item').length;

	$('#debug').html(width  + ' ' + height + ' ' + mask_width);		
	$('#wrapper, .item').css({width: width, height: height});
	$('#mask').css({width: mask_width, height: height});
	$('#wrapper').scrollTo($('a.selected').attr('href'), 0);
		
}
