//----------------------------------------------------------
//--	Copyright (c) 2005 The Working Group				
//--		 http://theworkinggroup.ca					
//--		  Developed by: Jack Neto					
//----------------------------------------------------------


function validateOrderForm(form) 
{
	var retVal = true;

	//Check if the ServiceDescription field is empty
	if (isEmpty(form.txtServiceDescription, 'lblServiceDescription')) {
		retVal = false;
	}

	//Check if the Telephone field is empty
	if (isEmpty(form.txtTelephone, 'lblTelephone')) {
		retVal = false;
	}


	//Check if the Contact field is empty
	if (isEmpty(form.txtContact, 'lblContact')) {
		retVal = false;
	}

	//Check if the City field is empty
	if (isEmpty(form.txtPostalCode, 'lblPostalCode')) {
		retVal = false;
	}

	//Check if the City field is empty
	if (isEmpty(form.txtCity, 'lblCity')) {
		retVal = false;
	}

	//Check if the Address field is empty
	if (isEmpty(form.txtAddress, 'lblAddress')) {
		retVal = false;
	}

	//Check if the client name field is empty
	if (isEmpty(form.txtName, 'lblName')) {
		retVal = false;
	}

	return retVal;
 }


//---------------------------------------
// Returns true if the textBox is empty
//---------------------------------------
function isEmpty(textBox, labelName) {
	var retVal = false;

	if (textBox.value.length == 0) {
		document.getElementById(labelName).style.color="red";
		textBox.value = '';
		textBox.focus();
		return true;
	} else {
		document.getElementById(labelName).style.color="#757575";
		return false;
	}
}


//---------------------------------------
// Returns true if the email adddress in textBox is valid
//---------------------------------------
function emailIsValid(textBox, labelName) {

	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;

	if (!filter.test(textBox.value)) {
		document.getElementById(labelName).style.color="red";
		textBox.focus();
		return false;
	} else {
		document.getElementById(labelName).style.color="#757575";
		return true;
	}
}
