function shred_quote_form_submit()
{
	shred_quote_form_request_send();
	shred_quote_form_form_disable();

	return true;
}

function shred_quote_form_strip_fields()
{
	var regexp;

	regexp = /[^\w\s]+$/;
	$("#txtName").val($("#txtName").val().replace(regexp, ""));
	$("#txtCompany").val($("#txtCompany").val().replace(regexp, ""));

	regexp = /[^\d]+$/;
	$("#txtZip").val($("#txtZip").val().replace(regexp, ""));

	regexp = /[^\d\-]+$/;
	$("#txtPhone").val($("#txtPhone").val().replace(regexp, ""));

	return true;
}

function shred_quote_form_form_disable()
{
	$("#shred_quote_form :input").attr('disabled', 'disabled');
	$("#shred_quote_form_button_submit").val('Processing...');

	return true;
}

function shred_quote_form_form_enable()
{
	$("#shred_quote_form :input").removeAttr('disabled');
	$("#shred_quote_form_button_submit").val('Request Quote');

	return true;
}

function shred_quote_form_request_send()
{
	var params = $("#shred_quote_form").serialize();

	$.getJSON('shred_quote_form/shred_quote_form_ajax.php', params, function (json) { shred_quote_form_request_complete(json); });

	return true;
}

function shred_quote_form_request_complete(json)
{
	var errors;
	var i;

	if(json.code == '0')
	{
		alert("Thank you for taking the time to contact us! A customer service representative will be contacting you shortly!\n\nIf you wish to speak to a customer service representative you can contact us at: (415) 621-6200, Monday through Friday from 8:00am - 5:00pm Pacific Standard Time.");
		$("#shred_quote_form").get(0).reset();
	}
	else
	{
		errors = "The following errors were found with your submission:";
		for(i = 0; i < json.error_count; i++)
		{
			errors += "\n- "+json.error_strings[i];
		}

		alert(errors);
	}

	shred_quote_form_form_enable();

	return true;
}