jQuery(document).ready(function(){
		
	//Hide submit button
	jQuery('form#quiz input[type="submit"]').hide();
	
	//Answers show and hide
	jQuery('form#quiz > fieldset > ol > li').not(":first").hide().append('<p><a href="#" class="back">Back</a></p>').end().find("input[type='radio']").click(function()
	{
		jQuery(this).closest('fieldset').closest('li').fadeOut("fast", function()
		{
			//Get next question
			var nextQuestion = jQuery(this).next();
					
			//Fade in next question or submit form
			if(nextQuestion.length > 0) {
				nextQuestion.fadeIn();
			} else {
				jQuery('form#quiz').submit();
			}
		});
	});
	
	//Back buttons
	jQuery('form#quiz a.back').click(function()
	{
		//Fade out current question
		jQuery(this).closest('li').fadeOut("fast", function()
		{
			//Fade in previous question
			jQuery(this).closest('li').prev('li').fadeIn();
		});
		return false;
	});
	
});
