$(document).ready(function(){

	// hide all questions except for the first one 
	$("#questions li:not(#question1)").hide();
	$("#error_message").hide();
	
	$("#questions a").click(function(event){
		$("#error_message").hide();
	});
	
	$("#question1 a").click(function(event){
		if ($("input#first_name").val()) {
		$(".name_to_change").append($("input#first_name").val());	
		$("#question1").hide();	
		$("#question2").fadeIn("slow");
		} else {
			$("#error_message").text("Please enter a first name").show();
		}
	});
	
	$("#question2 a").click(function(event){
		$("#question2").hide();	
		$("#question3").fadeIn("slow");
	});
	
	$("#question3 a").click(function(event){
		$("#question3").hide();	
		$("#question4").fadeIn("slow");
	});
	
	$("#question4 a").click(function(event){
		$("#question4").hide();	
	
		if ($("input[@name='coupon_for']:checked").val()== 'escort') {
			$("#escort_questions").fadeIn("slow");
			$("#generate_button").click(function(event){
				if ($("input#escort_food").val() && $("input#escort_verb").val()) {
					$("form:first").submit();
				} else {
					$("#error_message").text("Please enter a food and a verb that ends in 'ing'").show();
				}
			});
		}
	
		if ($("input[@name='coupon_for']:checked").val()== 'corpse') {
			$("#corpse_questions").fadeIn("slow");
			$("#generate_button").click(function(event){
				if ($("input#corpse_age").val() && $("input#corpse_job").val()) {
					$("form:first").submit();
				} else {
					$("#error_message").text("Please enter an age and job title").show();
				}
			});
		}

		if ($("input[@name='coupon_for']:checked").val()== 'balls') {
			$("#balls_questions").fadeIn("slow");
			$("#generate_button").click(function(event){
				if ($("input#balls_adj1").val() && $("input#balls_adj2").val()) {
					$("form:first").submit();
				} else {
					$("#error_message").text("Please enter two adjectives").show();
				}
			});		
		}
	
		if ($("input[@name='coupon_for']:checked").val()== 'soul') {
			$("form:first").submit();
			return true;
		}
	
		if ($("input[@name='coupon_for']:checked").val()== 'slave') {
			$("#slave_questions").fadeIn("slow");
			$("#generate_button").click(function(event){
				if ($("input#slave_job").val() && $("input#slave_age").val()) {
					$("form:first").submit();
				} else {
					$("#error_message").text("Please enter an age and job title").show();
				}
			});
		}
	
		$("#generate").fadeIn("slow");
	});
	

	
	$("#html a").fancybox({
		'overlayShow': true,
		'zoomSpeedIn': 250,
		'zoomSpeedOut': 250
	});
	

	

	
	
});
