/*	
	validateform.js
	contains all validation functions for all form fields
	date created: 16 July 2005
	author ari rizos webology www.webology.net.au
*/

/*	GLOBAL VARIABLES */
var submitform;
var errormessage;

/*	
	function validatetextfield(textfield, textfieldname)
	checks to make sure that the text field contains information
	parameters:		textfield - form field
					textfieldname - name of form field
	author ari rizos www.webology.net.au info@webology.net.au
*/

function validatetextfield(textfield, textfieldname)
{
	if(textfield.value == "" || textfield.value == "PLEASE COMPLETE"){
			textfield.value = "PLEASE COMPLETE";
			submitform = false;
			errormessage += textfieldname + " must be completed\n";
	}
}

/*
	function verification(textfieldOne, textfieldTwo)
	compares the values of two form fields and checks that the values are the same
	if not the same sets the submit value to false and adds an errormessage
	parameters		textfieldOne	first form field
					textfieldTwo	second form field
					textfieldname	name of the form field
	author			ari rizos www.webology.net.au info@webology.net.au
*/

function verification(textfieldOne, textfieldTwo, textfieldname){
	if(textfieldOne.value != textfieldTwo.value){
		submitform = false;
		errormessage += textfieldname + " do not match\n";
	}		
}	

/*	function checkform()
	checks the required form fields for the metropole contact form
	date created:	7 August 2006
	author:			ari rizos www.webology.net.au info@webology.net.au
*/
function checkform()
{
	errormessage = "Error: \n";
	submitform = true;
	// checking that the name and e-mail has been selected
	validatetextfield(document.forms[0].name, "Name");
	validatetextfield(document.forms[0].email, "Email");
	validatetextfield(document.forms[0].phone, "Phone");
	
	if(submitform == false){
		alert(errormessage);
	}
	if(submitform == true){
		document.forms[0].submit();
	}
}

/*	function checkCorporateForm()
	checks the required form fields for the metropole contact form
	date created:	3 June 2009
	author:			ari rizos www.webology.net.au info@webology.net.au
*/
function checkCorporateForm()
{
	errormessage = "Error: \n";
	submitform = true;
	// checking that the name and e-mail has been selected
	validatetextfield(document.forms[0].name, "Name");
	validatetextfield(document.forms[0].company, "Company");
	validatetextfield(document.forms[0].bookings, "Estimated Bookings");
	validatetextfield(document.forms[0].email, "Email");
	validatetextfield(document.forms[0].phone, "Phone");
	
	
	if(submitform == false){
		alert(errormessage);
	}
	if(submitform == true){
		document.forms[0].submit();
	}
}