$(document).ready(function(){
	//$('#pollForm').show();
	
	// on click behaviour to clear the text from the mailing list sign up box
	$('#poll-email').clickClear();
	$('#poll-email').validateEmail();			// validate the email
	$('#pollForm').validatePoll();				// poll submission handler
});

// use window.load rather than document.ready so that we ensure the images are loaded before the animation starts
$(window).load(function(){
	// start the animation after a short delay
	setTimeout("animate()",1000);
});


// animate the logo sign
function animate() {
	var spd = 1500;
	
	var bounce = function(){
		if (!crapBrowser) {
			$(this).effect("bounce", {
				times: 3,
				distance: 10
			}, 300);
		}
	};
	
	// show the coming soon logo
	$('#comingSoon_coverVoting').fadeIn('slow');
	
	// show the main logo and scroll
	$('#theMaggies_logo').animate({ "top": "0" }, spd, "swing");
	$('#scroll').animate({ "top": "90px" }, spd, "swing", function(){
		// add some glitter to the scroll
		$('#stage-front').addSparkleGroup(501,116,4,220,50);
	});
	
	// animate the survey itself
	$('#poll1-1').animate({ "top": "-271px" }, spd + parseInt(Math.random()*500), "linear", bounce);
	$('#poll1-2').animate({ "top": "-339px" }, spd + parseInt(Math.random()*500), "linear", bounce);
	$('#poll1-3').animate({ "top": "-437px" }, spd + parseInt(Math.random()*500), "linear", bounce);
	$('#poll1-4').animate({ "top": "-410px" }, spd + parseInt(Math.random()*500), "linear", bounce);
	$('#poll1-question').animate({ "top": "-253px" }, spd + parseInt(Math.random()*500), "linear", function(){
		bounce;
		
		$('.pollItem img').addSparkleImage(6);		// sparkle all the images
		
		// last poll element in, fade in the form itself (higher layer)
		$('#pollForm').fadeIn(2000,function(){
			// sparkle the button
			$('#poll1-vote').addSparkleImage(4);
		});
	});
};



