var speed = 1000;
function showpolaroidbox(pointer_id) {
	$('.polaroidBox').show();
	
	// Bepaal start index:
	var index = 0;
	if(pointer_id){
		index = $('#shuffle img.pointer_' + pointer_id + ':first').prevAll().length;
	}
	
	// Fotos
	$('#shuffle').cycle({
		fx:     'shuffle',
		easing: 'easeOutBack',
		next: '.next',
		prev: '.prev',
		speed: speed,
		startingSlide: index
	});
	
	// Quotes
	$('#shuffle_quote').cycle({
		easing: 'easeOutBack',
		next: '.next',
		prev: '.prev',
		speed: speed,
		startingSlide: index
	});
	
	// Quotes in het midden centreren
	$('#shuffle_quote span').each(function(){
		$(this).css({marginTop: parseInt(($(this).parent().height() - $(this).height()) / 2) + 'px'});
	});
}

var rotation = 0;
function rocketrotate(){
	$('.rocket').css({ WebkitTransform: 'rotate(' + rotation + 'deg)'});
    $('.rocket').css({ '-moz-transform': 'rotate(' + rotation + 'deg)'});

	rotation-= 2;
	
	setTimeout(rocketrotate, 20);
}

$(document).ready(function(){
	// Rakketje
	if($('.rocket').length){
		rocketrotate();
	}
	
	$('body').bind('click', function(event){
		if($(event.target).attr('id') == 'wrapper' && $('.polaroidBox').length){
			$('.polaroidBox').hide();
			$('#shuffle, #shuffle_quote').cycle('stop')
		}
	});
	
	loadcaptcha()	
});

function loadcaptcha(){
	if(!$('#captcha').length)
		return;	
		
	$('#captcha span').load('includes/captcha.php?r=' + Math.random()*100000);
}
