// form validation - core validation routine
function setupValidation()
{
	if(document.getElementById("quotes"))
	{
		setupQuoteForm();
	}
}

// this is actually the brochure page but shares the same ID to save on duplicating the CSS
function setupQuoteForm()
{
	var frmvalidator = new Validator("quotes");
	frmvalidator.addValidation("fullname", "req", "Please enter your name(s)");

	frmvalidator.addValidation("email", "req", "Please enter your email address");	
	frmvalidator.addValidation("email", "email", "Please enter a valid email address");

	frmvalidator.addValidation("address", "req", "Please enter your postal address");	
	frmvalidator.addValidation("postcode", "req", "Please enter your postcode");	

	frmvalidator.setAddnlValidationFunction("customQuoteValidation");
}

function customQuoteValidation()
{
	frm = document.forms["quotes"];
		
	// require at least one phone number
	if(frm.phonenumber.length == 0 &&
		frm.eveningnumber.length == 0 &&
		   frm.mobilenumber.length == 0)
	{
		alert("Please enter at least one phone number");
		return false;
	}
	
	// no errors found throughout
	return true;
}



// global startup function
/////////////////////////////////////////////////
if(document.getElementById && document.createTextNode)
{
	addEvent(window, 'load', function(e)
	{
		setupValidation();
	});
}