
var form = "";
var error_message = "";
var error = false;

function validate_contact_form(form_name)
{
	error = false;
	form = form_name;

	error_message = "Errors have occured during the process of your form.\n\nPlease make the following corrections:\n\n";

	check_input("firstname", 2, "First Name must contain a minimum of 2 characters.");
	check_input("lastname", 2, "Last Name must contain a minimum of 2 characters.");
	check_input("street_address", 5, "Street address must contain a minimum of 5 characters.");
	check_input("city", 3, "City must contain a minimum of 3 characters.");
	check_input("state", 2, "State must contain a minimum of 2 characters.");
	check_input("postcode", 4, "Postcode must contain a minimum of 2 characters.");
	check_input("email_address", 6, "Email Address must contain a minimum of 6 characters.");
	check_input("telephone", 3, "Telephone must contain a minimum of 6 characters.");
	
	if (error == true) {
		alert(error_message);
		return false;
	} else {
		submitted = true;
		return true;
	}
}

function validate_shipping_form(form_name)
{
	error = false;
	form = form_name;

	error_message = "Errors have occured during the process of your form.\n\nPlease make the following corrections:\n\n";

	check_input("ship_firstname", 2, "First Name must contain a minimum of 2 characters.");
	check_input("ship_lastname", 2, "Last Name must contain a minimum of 2 characters.");
	check_input("ship_street_address", 5, "Street address must contain a minimum of 5 characters.");
	check_input("ship_city", 3, "City must contain a minimum of 3 characters.");
	check_input("ship_state", 2, "State must contain a minimum of 2 characters.");
	check_input("ship_postcode", 5, "Postcode must contain a minimum of 5 characters.");
	
	if (error == true) {
		alert(error_message);
		return false;
	} else {
		submitted = true;
		return true;
	}
}

function check_input(field_name, field_size, message) {
  if (form.elements[field_name] && (form.elements[field_name].type != "hidden")) {
    var field_value = form.elements[field_name].value;

    if (field_value == '' || field_value.length < field_size) {
      error_message = error_message + "* " + message + "\n";
      error = true;
    }
  }
}


// vim: ts=4 sw=4


