// JavaScript Document
// form validation - core validation routine
function setupValidation()
{
	if(document.getElementById("frm-purchase"))
	{
		var frmvalidator = new Validator("frm-purchase");
			
		frmvalidator.addValidation("first_name", "req", "Please enter your forename");
		frmvalidator.addValidation("last_name", "req", "Please enter your surname(s)");
		frmvalidator.addValidation("company_name", "req", "Please enter your company name");
		
		frmvalidator.addValidation("address_1", "req", "Please enter your postal address");		
		frmvalidator.addValidation("post_town", "req", "Please enter your post town");	
		frmvalidator.addValidation("county", "req", "Please enter your county");							
		frmvalidator.addValidation("postcode", "req", "Please enter your postcode");			
	
		frmvalidator.addValidation("contact_phone", "req", "Please enter a contact telephone number");
		frmvalidator.addValidation("contact_email", "req", "Please enter your contact email address");
		frmvalidator.addValidation("contact_email", "email", "Please enter a valid contact email address");

		frmvalidator.addValidation("invoice_number", "req", "Please enter your allocated invoice number");
		frmvalidator.addValidation("payment_amount", "req", "Please enter the amount you are paying");
	}
}

// toggle visibility of billing
function toggle_alt_billing(showbilling)
{
	if(showbilling)
	{
		document.getElementById("billing_wrap").style.display = "block";
	}
	else
	{
		document.getElementById("billing_wrap").style.display = "none";
	}
}


// global startup function
/////////////////////////////////////////////////
if(document.getElementById && document.createTextNode)
{
	addEvent(window, 'load', function(e)
	{
		// form validation
		setupValidation();
		
		// hide the alt billing address to start with
		document.getElementById("billing_wrap").style.display = "none";
	});
}
