function fInstantQuote() {
	var strError = "";
	var strYear = $("#year_built").val();
	var strCoverage = $("#curr_amount_owner").val();
	var strZip = $("#zip").val();
	var strConstType = $("input[name=construction_type]:checked").val();
	var strReplCost = $("input[name=repl_cost]:checked").val();
	var strRoof2001 = $("input[name=roof_2001]:checked").val();
	
	if(strYear == "") { strError += "Please enter a year.\n"; }
	if(strCoverage == "") { strError += "Please enter a coverage amount.\n"; }
	if(strZip == "") { strError += "Please enter a zipcode.\n"; }
	if(strConstType == undefined) { strError += "Please enter the construction type.\n"; }
	if(strReplCost == undefined) { strError += "Please answer if you want replacement cost.\n"; }
	if(strRoof2001 == undefined) { strError += "Please answer if the roof has been replaced since 2001.\n"; }
	if(strError != "") {
		alert(strError);
		return false;
	}
		$.get('ajaxInstantQuote.php', {
				year: strYear,
				coverage: strCoverage,
				zip: strZip,
				construction_type: strConstType,
				replcost: strReplCost,
				roof2001: strRoof2001
			}, function(data) { $.facebox(data) });
	//$(document).bind('close.facebox', function() { fQuoteStage2(); });
}

function fQuoteStage2() {
	$("#auto_fields").show();
	$("#home_fields").show();
	$("#disclaimer").show();
	$("#submitfield").show();
	$("#contact").show();
	$("#iqbutton").hide();
	$("#firstname").focus();
}

$(document).ready(function(){
	
	$('input#homequote').attr('value', 'Annual Premium');
	var contactFields = $('fieldset#contact');
	var homeFields = $('fieldset#home_fields');

	$('#round_two input').focus(function(){
			$(this).val('');
	})
	
	$("form").validate({
			rules: {
					firstname: "required",
					lastname: "required",
					address1: "required",
					city: "required",
					state: "required",
					zip: "required",// simple rule, converted to {required:true}
					email: {				// compound rule
								required: true,
								email: true
								},
					curr_amount_owner: {
							required: true,
							number: true,
							range: [100000, 2000000]
					},
					year_built: {
							required: true,
							number: true,
							range: [1810, 2050]
					},
					square_footage: {
						required : true,
						number : true
					},
					construction_type: "required",
					roof_2001: "required",
					repl_cost: "required"
			}
		});
		
}); 

