// non-empty textbox
function isEmpty(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please enter a comment.\n"
  }
return error;	  
}

// non-empty textbox
function checkComments(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please enter a comment.\n"
  }
return error;	  
}

// valid title
function checkTitle(choice) {
var error = "";
    if (choice == 0) {
    error = "Please select a title.\n";
    }    
return error;
}

// name - 4-10 chars, uc, lc, and underscore only.
function checkName (strng) {
var error = "";

    var illegalChars = /\W/; // allow letters, numbers, and underscores
    if ((strng.length < 2)) {
       error = "The name is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) {
    error = "The name contains illegal characters.\n";
} 

if (strng == "") {
   error = "Please enter your name.\n";
}
return error;
}


// name - 4-10 chars, uc, lc, and underscore only.
function checkSurname (strng) {
var error = "";

    var illegalChars = /\W/; // allow letters, numbers, and underscores
    if ((strng.length < 2)) {
       error = "The surname is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) {
    error = "The surname contains illegal characters.\n";
} 

if (strng == "") {
   error = "Please enter your surname.\n";
}
return error;
}


// name - 4-10 chars, uc, lc, and underscore only.
function checkOrganisation (strng) {
var error = "";

    var illegalChars = /\W\D\S\d\s\ /; // allow letters, numbers, and underscores
    if ((strng.length < 2)) {
       error = "The Organisation/Company name is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) {
    error = "The Organisation/Company name contains illegal characters.\n";
} 

if (strng == "") {
   error = "Please enter your Organisation/Company name.\n";
}
return error;
}


// name - 4-10 chars, uc, lc, and underscore only.
function checkPosition (strng) {
var error = "";

    var illegalChars = /\W/; // allow letters, numbers, and underscores
    if ((strng.length < 2)) {
       error = "The position is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) {
    error = "The position contains illegal characters.\n";
} 

if (strng == "") {
   error = "Please enter your position.\n";
}
return error;
}


// name - 4-10 chars, uc, lc, and underscore only.
function checkAddress (strng) {
var error = "";

    var illegalChars = /\W\D\S\d\s\ /; // allow letters, numbers, and underscores
    if ((strng.length < 2)) {
       error = "The address is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) {
    error = "The address contains illegal characters.\n";
} 

if (strng == "") {
   error = "Please enter your address.\n";
}
return error;
}


// name - 4-10 chars, uc, lc, and underscore only.
function checkCity (strng) {
var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
    if ((strng.length < 2)) {
       error = "The city name is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) {
    error = "The city name contains illegal characters.\n";
    } 
if (strng == "") {
   error = "Please enter your city name.\n";
}	
return error;
}


// name - 4-10 chars, uc, lc, and underscore only.
function checkState (strng) {
var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
    if ((strng.length < 2)) {
       error = "The state/province name is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) {
    error = "The state/province name contains illegal characters.\n";
    } 
if (strng == "") {
   error = "Please enter your state/province name.\n";
}	
return error;
}


// name - 4-10 chars, uc, lc, and underscore only.
function checkCountry (strng) {
var error = "";
    var illegalChars = /\W/; // allow letters, numbers, and underscores
    if ((strng.length < 2)) {
       error = "The country name is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) {
    error = "The country name contains illegal characters.\n";
    } 
if (strng == "") {
   error = "Please enter your country.\n";
}	
return error;
}


function checkPostal(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please enter your post/zip code.\n"
  }
return error;
}


// international tel number - strip out delimiters and check for tel number
function checkIntTel (strng) {
var error = "";
var stripped = strng.replace(/[\(\)\.\-\ ]/g, "");
var illegalChars = strng.replace(/[\(\)\.\-\ \0-9]/g, "");
	if (strng == "") {
   	error = "Please enter your tel number.\n";
	}
	else if (illegalChars.length != 0) {
       	error = "The tel number contains illegal characters.\n";
	}	
	else if (stripped.length <10) {
		error = "The tel number is the wrong length.\n";
	}
return error;
}

// international fax number - strip out delimiters and check for tel number
function checkIntFax (strng) {
var error = "";

var stripped = strng.replace(/[\(\)\.\-\+\ ]/g, ''); //strip out acceptable non-numeric characters
    if (isNaN(parseInt(stripped))) {
       error = "The fax number contains illegal characters.\n";
    }

if (strng == "") {
   error = "Please enter your fax number.\n";
}
return error;
}

// email
function checkEmail (strng) {
var error="";

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "The email address is invalid.\n";
    }
    else {
	//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "The email address contains illegal characters.\n";
       }
    }

if (strng == "") {
   error = "Please enter your email address.\n";
}

return error;
}

// cell number - check for 10 digits and strip out non-numeric characters
function checkCell (strng) {
var error = "";
var stripped = strng.replace(/[\(\)\.\-\ ]/g, "");
var illegalChars = strng.replace(/[\(\)\.\-\ \0-9]/g, "");
	if (strng == "") {
   	error = "Please enter your cell number.\n";
	}
	else if (illegalChars.length != 0) {
       	error = "The cell number contains illegal characters.\n";
	}	
	else if (stripped.length <10) {
		error = "The cell number is the wrong length.\n";
	}
return error;
}

/************************ Passport **************************/

// Passport Number
function checkPassport (strng) {
	var error = "";
	if (strng == "") {
	    error = "Please enter your passport number.\n";
	}
return error;
}

// Nationality
function checkNationality (strng) {
var error = "";
	if (strng == "") {
	   error = "Please enter your nationality.\n";
	}
return error;
}

// Expiry Date
function checkExpiryDate (strng) {
var error = "";
	if (strng == "" || strng == "DD / MM / YYYY") {
	   error = "Please enter your passport expiry date.\n";
	} else if(strng.length!=10) {
		error = "Your passport expiry date is not in the correct format (DD/MM/YYYY).\n";
	}
return error;
}

/**************************** Partner ******************************/

// name - 4-10 chars, uc, lc, and underscore only.
function checkPartner(strng) {
var error = "";

    var illegalChars = /\W/; // allow letters, numbers, and underscores
    if ((strng.length < 2)) {
       error = "Your partner's name is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) {
    error = "Your partner's name contains illegal characters.\n";
	} 

if (strng == "") {
   error = "Please enter your partner's full name.\n";
}
return error;
}

// Passport Number
function checkPartnerPassport (strng) {
	var error = "";
	if (strng == "") {
	   error = "Please enter your partner's passport number.\n";
	}
return error;
}

// Nationality
function checkPartnerNationality (strng) {
var error = "";
	if (strng == "") {
	   error = "Please enter your partner's nationality.\n";
	}
return error;
}

// Expiry Date
function checkPartnerExpiryDate (strng) {
var error = "";
	if (strng == "" || strng == "DD / MM / YYYY") {
	   error = "Please enter your partner's passport expiry date.\n";
	} else if(strng.length!=10) {
		error = "Your partner's passport expiry date is not in the correct format (DD/MM/YYYY).\n";
	}
return error;
}

/**************************** Hotel ******************************/

// hotel
function checkHotelInDay(choice) {
var error = "";
    if (choice == 0) {
    error = "Please select your day of arrival.\n";
    }    
return error;
}

// hotel
function checkHotelInMonth(choice) {
var error = "";
    if (choice == 0) {
    error = "Please select your month of arrival.\n";
    }    
return error;
}

// hotel
function checkHotelOutDay(choice) {
var error = "";
    if (choice == 0) {
    error = "Please select your day of departure.\n";
    }    
return error;
}

// hotel
function checkHotelOutMonth(choice) {
var error = "";
    if (choice == 0) {
    error = "Please select your month of departure.\n";
    }    
return error;
}

// valid party
function checkRoom(choice) {
var error = "";
    if (choice == 0) {
    error = "Please select the type of room.\n";
    }    
return error;
}  

// valid party
function checkBed(choice) {
var error = "";
    if (choice == 0) {
    error = "Please select the type of bed.\n";
    }    
return error;
}  

// valid party
function checkAdults(choice) {
var error = "";
    if (choice == 0) {
    error = "Please select the number of adults.\n";
    }    
return error;
}  

// valid party
function checkChildren(choice) {
var error = "";
    if (choice == 0) {
    error = "Please select the number of children.\n";
    }    
return error;
}  

// arrival day
function checkArrivDay(choice) {
var error = "";
    if (choice == 0) {
    error = "Please enter your day of arrival.\n";
    }    
return error;
}
// arrival month
function checkArrivMonth(choice) {
var error = "";
    if (choice == 0) {
    error = "Please enter your month of arrival.\n";
    }    
return error;
}

// arrival year
function checkArrivYear(choice) {
var error = "";
    if (choice == 0) {
    error = "Please enter your year of arrival.\n";
    }    
return error;
}

// departure day
function checkDepDay(choice) {
var error = "";
    if (choice == 0) {
    error = "Please enter your day of departure.\n";
    }    
return error;
}

// departure month
function checkDepMonth(choice) {
var error = "";
    if (choice == 0) {
    error = "Please enter your month of departure.\n";
    }    
return error;
}

// departure year
function checkDepYear(choice) {
var error = "";
    if (choice == 0) {
    error = "Please enter your year of departure.\n";
    }    
return error;
}

// non-empty codebox
function checkCode(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please enter the security code.\n"
  }
return error;	  
}


