
// When the DOM is ready...
$(function(){
	
	// Hide stuff with the JavaScript. If JS is disabled, the form will still be useable.
	// NOTE:
	// Sometimes using the .hide(); function isn't as ideal as it uses display: none; 
	// which has problems with some screen readers. Applying a CSS class to kick it off the
	// screen is usually prefered, but since we will be UNhiding these as well, this works.
	$(".choice_wrap").hide();
	
	
	// Reset form elements back to default values
	$("#submit_button").attr("disabled",true);
	$("#num_staff").val('Please Choose');
	
	
	
	// Fade out steps 2 and 3 until ready
	$("#step_2").css({ opacity: 0.3 });
	$("#step_3").css({ opacity: 0.3 });
	

		
	// When a dropdown selection is made
	$("#num_staff").change(function() {

		$(".choice_wrap").slideUp();
		
		switch ($("#num_staff option:selected").text()) {
			case '10':
				$("#choice_1_wrap").slideDown();
				break;
			case '20':
				$("#choice_2_wrap").slideDown();
				break;
			case '40':
				$("#choice_3_wrap").slideDown();
				break;
			case '60':
				$("#choice_4_wrap").slideDown();
				break;
			case '80':	
				$("#choice_5_wrap").slideDown();
				break;
			case '100':	
				$("#choice_6_wrap").slideDown();
				break;
			case 'Over 100':	
				$("#choice_7_wrap").slideDown();
				break;
				
			}
	});
	
	
		
	
	function stepOneTest() {
		if (($.stepOneComplete == "complete")) {
			$("#step_1")
			.animate({
				paddingBottom: "120px"
			})
			.css({
				"background-image": "url(http://localhost:8888/fruitful/wp-content/themes/fruitful_office/images/check.png)",
				"background-position": "bottom center",
				"background-repeat": "no-repeat"
			});
			$("#step_2").css({
				opacity: 1.0
			});
			$("#step_2 legend").css({
				opacity: 1.0 // For dumb Internet Explorer
			});
		}
	};
	
	$("#step_1 input[name=fruitNeeded]").click(function(){
		$.stepOneComplete = "complete"; 
		
		stepOneTest();
	});
	
	/* Check for field input in Step 2 */

$(".required").blur(function(){
	
		var all_complete = true;
				
		$(".required").each(function(){
			if ($(this).val() == '' ) {
				all_complete = false;
			};
		});
		
		if (all_complete ) {
			$("#step_2")
			.animate({
				paddingBottom: "120px"
			})
			.css({
				"background-image": "url(http://localhost:8888/fruitful/wp-content/themes/fruitful_office/images/check.png)",
				"background-position": "bottom center",
				"background-repeat": "no-repeat"
			});
			
			$("#step_3").css({
				opacity: 1.0
			});
			
			$("#step_3 legend").css({
				opacity: 1.0 // For dumb Internet Explorer
			});
			
			
			$("#submit_button").attr("disabled",false);
			
			
		};
	});


	
});
