function checkFields() 
{
  missinginfo = "";
  if(document.enquiry.lsttitle.options[document.enquiry.lsttitle.selectedIndex].value == "") 
  {
    missinginfo += "\n     -  Title";
  }  
  if(document.enquiry.txtfname.value == "") 
  {
    missinginfo += "\n     -  First Name";
  } 
  if(document.enquiry.txtsname.value == "") 
  {
    missinginfo += "\n     -  Surname";
  }
  if(!validate_phone(document.enquiry.txthomephone) && !validate_phone(document.enquiry.txtworkphone) && !validate_phone(document.enquiry.txtmobile)) 
  {
    missinginfo += "\n     -  Phone Number";
  }
  if(!validate_email(document.enquiry.txtemail)) 
  {
    missinginfo += "\n     -  Valid Email";
  }
  if(document.enquiry.lstnumadults.selectedIndex == 0)
  {
    missinginfo += "\n     -  Select the number of Adults";
  }
  if(document.enquiry.lstnumchildren.selectedIndex != 0)
  {
    if(document.enquiry.txtchildrensages.value == "")
    {
      missinginfo += "\n     -  Ages of Children";
    }
  }

if (missinginfo != "") {
missinginfo ="_____________________________\n" +
"You failed to correctly fill in\n" +
missinginfo + "\n_____________________________" +
"\nPlease re-enter and try again!";
alert(missinginfo);
return false;
}
else return true;
}


function validate_email(emField)
	{
	var fieldValue = emField.value // store field's entire value in variable
	// Begin Valid Email Address Tests
	
	//if field is not empty
	if(fieldValue != ""){ 
	var atSymbol = 0
	
	//loop through field value string
	for(var a = 0; a < fieldValue.length; a++){ 
	
	//look for @ symbol and for each @ found, increment atSymbol variable by 1
	if(fieldValue.charAt(a) == "@"){ 
	atSymbol++
	}
	
	}
	
	// if more than 1 @ symbol exists
	if(atSymbol > 1){ 
	// then cancel and don't submit form
	//alert("Please Enter A Valid Email Address") 
	return false
	}
	
	// if 1 @ symbol was found, and it is not the 1st character in string
	if(atSymbol == 1 && fieldValue.charAt(0) != "@"){ 
	//look for period at 2nd character after @ symbol 
	var period = fieldValue.indexOf(".",fieldValue.indexOf("@")+2) 
	
	// "." immediately following 1st "." ? 
	var twoPeriods = (fieldValue.charAt((period+1)) == ".") ? true : false 
	
	//if period was not found OR 2 periods together OR field contains less than 5 characters OR period is in last position
	if(period == -1 || twoPeriods || fieldValue.length < period + 2 || fieldValue.charAt(fieldValue.length-1)=="."){
	// then cancel and don't submit form
	//alert("Please Enter A Valid Email Address") 
	return false
	}
	}
	// no @ symbol exists or it is in position 0 (the first character of the field)
	else{ 
	// then cancel and don't submit form
	//alert("Please Enter A Valid Email Address")
	return false 
	}
	}
	// if field is empty
	else{ 
	// then cancel and don't submit form
	//alert("Please Enter A Valid Email Address")
	return false 
	}
	//all tests passed, submit form
	return true
}

// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

function validate_phone(emField){
	var Phone=emField;
	
	if ((Phone.value==null)||(Phone.value=="")){
		return false
	}
	if (checkInternationalPhone(Phone.value)==false){
		return false
	}
	return true
 }

function CountLeft(field, max)
{
	if (field.value.length > max)
	{ 	field.value = field.value.substring(0,max);  }
}

function goConfirm()
{
	if(confirm('Are you sure you would like to reset this form and clear all fields?')) 
	{
		return true;
	} 
	else 
	{
		return false;
	}
}