function validate() 
{ 
	valid=true;
	valid = all_fields_entered();
	if(valid==true) {
		valid = valid_email();
	}	
	return valid;

}


function all_fields_entered() {

	if (mail_query.FIELD_NAME.value == '') {		
		alert("You must fill in the Name Field");
		return false;
		}
	if (mail_query.FIELD_EMAIL.value == '') {
		alert("You must fill in the Email Field");
		return false;
	}	

		
	if (mail_query.FIELD_QUERY.value == '') { 
		alert("You must fill in your query");
		return false;
	}

return true;

}

function valid_email()
{

        var re;
		valid=false;
        // Rules for the email regular expression:
        // The start of the email must have at least one character 
        // before the @ sign
        // There may be either a . or a -, but not together before the @ sign
        // There must be an @ sign
        // At least once character must follow the @ sign
        // There may be either a . or a -, but not together in the address
        // The address must end with a . followed by at least 2 characters
        re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;
        if (re.test(mail_query.FIELD_EMAIL.value) == true){
            
			valid=true;
		}	
        else
        {
            alert("Mail is invalid");
			mail_query.FIELD_EMAIL.value=""
			valid=false;
          
        }
		
		return valid
}

// Booking Validating Form
function validatebooking() {
	//alert("Validating Booking 2");
	var valid=true;
		if (bookingform.FIELD_NAME.value == '') {
			alert("You must fill in the Name Field");
			valid=false;
		}	
		if (bookingform.FIELD_ADDRESS1.value == '') {
			alert("You must fill in the Address Field");
			valid=false;
		}	
		if (bookingform.FIELD_EMAIL.value == '') {
			alert("You must fill in the Email Field");
			valid=false;
		}	
		if (bookingform.FIELD_PHONE_NUMBER.value == '') {
			alert("You must fill in the Phone Field");
			valid=false;			
		}	
		traveller_count= bookingform.traveller_count.value;	
					//alert("count is: " + traveller_count);
		for(i=0; i < traveller_count; i++) {
			//if (bookingform.getElementById("traveller_0").value=='')  {
				//alert("You must fill in each traveller's name";
				//valid=false;
					//} //else alert("OK");
			
		
		}
		
		
		//alert ("Count is: " + traveller_count);
		
	
	
	return valid;

}
