
function checkEmail(address) {			

	if (address != '') {

		if (address.length > 6  &&  address.indexOf('@') != -1 && address.indexOf('.') != -1 && address.indexOf('@') < address.indexOf('.') && address.indexOf('@') > 0 && address.indexOf('.') > 2 ) {
			/* begin additional checks here */
			return true;
		} else {
			return false;
		}
		
	} else {
		
		return false;
	
	}
	
}

function checkPhone(phone) {			

	if (phone != '') {

		if (  phone.length > 9  ) {
			/* begin additional checks here */
			return true;
		} else {
			return false;
		}
	
	} else {
	
		return false;
		
	}
}

function checkForm(formName) {

	emailValue = document[formName].email.value;
	phoneValue = document[formName].phone.value;
	firstName = document[formName].firstname.value;
	lastName = document[formName].lastname.value;
	fromcity = document[formName].fromcity.value;
	fromstate = document[formName].fromstate.value;
	tocity = document[formName].tocity.value;
	tostate = document[formName].tostate.value;
	date1 = document[formName].date1.value;
	ttc = document[formName].ttc.value;
	
	if ( checkEmail(emailValue) && checkPhone(phoneValue) ) {
	
		if (

			firstName !="First" && firstName != ""
			&& lastName !="Last" && lastName != ""
			&& fromcity !="City" && fromcity != ""
			&& fromstate != "State" && fromstate != ""
			&& tocity != "City" && tocity != ""
			&& tostate != "State" && tostate != ""
			&& date1 != ""
			&& ttc != "not_selected"
			
			)
			
		{
		
			return true;

		} else {

			error = 'Please enter all required information before pressing submit.';
			alert(error);
			return false;

		}
			
	} else {

		error = 'Please enter all required information before pressing submit.';
		alert(error);
		return false;

	}		

}

