//This function checks for the existence of required fields, highlights and returns if not valid
//Required Fields: customer_name, customer_phone, customer_email

function CheckSubmit()
{
	var error_count = 0;
	t_form = document.contact_form;
	error_count += value_checker("customer_name", error_count);
	error_count += value_checker("customer_phone", error_count);
	error_count += value_checker("customer_email", error_count);
	if (error_count > 0)
	{
		alert("You have left " + error_count + " of the required fields blank. Please fill them in and click Submit again.");
	}else{	
	t_form.submit();
	}
}

function value_checker(field, error_count)
{
	var test_field = eval("document.contact_form." + field);
	if (test_field.value == "")
	{
		test_field.style.background = "#EEF111";
		if (error_count == 0) //This is the first error, take the user there
		{
			test_field.focus();
		}
		return 1;
	}else{
		test_field.style.background = "#FFFFFF";
		return 0;
	}
}
