function checkTextField (strng, errormsg) {
 var error = "";
 if (strng == "") {
    error = errormsg;
 }
 return error;
}

function checkEmail (strng, errormsg) {
	var error = "";
	var emailFilter=/^[\w\.\-]+@([\w\-]+\.)+[a-zA-Z]+$/;
	if (!(emailFilter.test(strng))) {
	       error = errormsg;
	}
	return error;
}

function checkPhone (strng, errormsg) {
	var error = "";
	var stripped = strng.replace(/[\(\)\.\-\ ]/g, '');
	//strip out acceptable non-numeric characters
	if (isNaN(parseInt(stripped))) {
	       error = errormsg;
	}
	return error;
}

function checkDropdown(choice, errormsg) {
    var error = "";
    if (choice == "NULL") {
       error = errormsg;
    }    
return error;
} 

function checkCheckbox(choice, errormsg) {
    var error = "";
    if (choice == false) {
       error = errormsg;
    }    
return error;
}

function checkRadio(checkvalue, errormsg) {
var error = "";
   if (!(checkvalue)) {
       error = errormsg;
    }
return error;    
}

function checkContactForm(theForm) {
	var why = "";
	var why_errors = "";
	why_errors += checkTextField(theForm.myname.value, "- your full name\n");
	why_errors += checkEmail(theForm.mailurl.value, "- a valid email address\n");
	why_errors += checkPhone(theForm.tel_number.value, "- your contact number (digits only)\n");
	why_errors += checkTextField(theForm.numberofpeople.value, "- number of people\n");
	//why_errors += checkTextField(theForm.captcha.value, "- the spam prevention code\n");

    if (why_errors != "") {
       why = "Please fill in:\n"+why_errors;
       alert(why);
       return false;
    }	
}

function checkProvisionalForm(theForm) {
	var why = "";
	var why_errors = "";
	
	alert(theForm.fname2.value);
	
	why_errors += checkTextField(theForm.fname2.value, "- your full name\n");
	why_errors += checkEmail(theForm.epos2.value, "- a valid email address\n");
	why_errors += checkPhone(theForm.number2.value, "- a contact number\n");
	why_errors += checkDropdown(theForm.tour.value, "- a tour\n");
	why_errors += checkTextField(theForm.departure_date.value, "- departure date\n");
	why_errors += checkCheckbox(theForm.terms.checked, "- acceptance of Terms and Conditions\n");	
	why_errors += checkCheckbox(theForm.passport.checked, "- a copy of your passport needs to be faxed in order to secure your booking\n");		

    if (why_errors != "") {
       why = "Please fill in:\n"+why_errors;
       alert(why);
       return false;
    }
}

function extrafields(theForm) {
	var why = "";
	var why_errors = "";
	
	why_errors += checkTextField(theForm.group_name.value, "- group name\n");
	why_errors += checkTextField(theForm.participants.value, "- number of participants\n");
	why_errors += checkTextField(theForm.arrival_date.value, "- arrival date\n");
	why_errors += checkTextField(theForm.nights.value, "- number of nights\n");
	why_errors += checkDropdown(theForm.hotel.value, "- hotel category\n");
	why_errors += checkTextField(theForm.fname.value, "- your full name\n");
	why_errors += checkTextField(theForm.address.value, "- your address\n");
	why_errors += checkTextField(theForm.city.value, "- city\n");
	why_errors += checkTextField(theForm.zip.value, "- zip/postal code\n");
	why_errors += checkTextField(theForm.country.value, "- country\n");
	why_errors += checkPhone(theForm.phonenumber.value, "- a valid phone number\n");
	why_errors += checkEmail(theForm.epos.value, "- a valid email address\n");
	


    if (why_errors != "") {
       why = "Please fill in:\n"+why_errors;
       alert(why);
       return false;
    }
}

function byot1(theForm) {
	//alert("check that a checkbox has been filled in");
	//return false;
}

