// non-empty textbox
function isEmpty(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please leave a comment.\n"
  }
return error;	  
}

// non-empty textbox
function checkCode(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please enter the security code.\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;
}       


// international tel number - strip out delimiters and check for tel number
function checkIntTel (strng) {
var error = "";

var stripped = strng.replace(/[\(\)\.\-\+\ ]/g, ''); //strip out acceptable non-numeric characters
    if (isNaN(parseInt(stripped))) {
       error = "The tel number contains illegal characters.\n";
}

if (strng == "") {
   error = "You didn't enter a valid tel 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;
}


// valid suite
function checkSuite(checkvalue) {
var error = "";
   if (!(checkvalue)) {
       error = "Please select the type of accommodation.\n";
    }
return error;
}

// valid party
function checkParty(choice) {
var error = "";
    if (choice == '-') {
    error = "Please select the number of guests.\n";
    }    
return error;
}  


// valid date
function checkDate(choice) {
var error = "";
    if (choice == '-') {
    error = "Please check the dates.\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 = "You didn't enter a valid fax number.\n";
}

return error;
}



/* ----------------------------------------  unused functions  ------------------------------------  

// passort number
function checkPassport (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a valid passport number.\n";
}
var stripped = strng.replace(/[\(\)\.\-\+\ ]/g, ''); //strip out acceptable non-numeric characters
    if (isNaN(parseInt(stripped))) {
       error = "The passport number contains illegal characters.\n";
    }
return error;
}

function checkNationality(strng) {
var error = "";
  if (strng.length < 2) {
     error = "The nationality is incorrect.\n"
  }
return error;
}

// passort expire
function checkPassExpire (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a valid expiry date.\n";
}
return error;
}

function checkHeading (strng) {
var error = "";
var maxwords=15
		var temp=strng.split(" ")
		if ((temp.length>maxwords)){
		error = "Please limit the heading to 15 words.\n";
		}
		else if(strng == "maximum 15 words"){
		error = "Please unput an appropriate heading.\n";
		}
		return error;
}


function checkKey(strng) {
var error = "";
  if (strng.length == 0) {
     error = "Please fill in at least 2 keywords.\n"
  }
return error;
}


function checkCopy (strng) {
var error = "";
var maxwords=300
		var temp=strng.split(" ")
		if ((temp.length>maxwords)){
		error = "Please limit the copy to 300 words.\n";
		}
		else if(strng.length<30){
		error = "Please unput some appropriate copy.\n";
		}
		return error;
}

 

// tel number - strip out delimiters and check for 10 digits
function checkTel (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a tel number.\n";
}
var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
    if (isNaN(parseInt(stripped))) {
       error = "The tel number contains illegal characters.";
      }
    if (!(stripped.length == 10)) {
	error = "The tel number is the wrong length. Make sure you included an area code.\n";
    } 
return error;
}

// fax number - strip out delimiters and check for 10 digits
function checkFax (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a fax number.\n";
}
var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
    if (isNaN(parseInt(stripped))) {
       error = "The fax number contains illegal characters.";
      }
    if (!(stripped.length == 10)) {
	error = "The fax number is the wrong length. Make sure you included an area code.\n";
    } 
return error;
}

// cell number - strip out delimiters and check for 10 digits
function checkCell (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a cell number.\n";
}
var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
    if (isNaN(parseInt(stripped))) {
       error = "The cell number contains illegal characters.";
  
    }
    if (!(stripped.length == 10)) {
	error = "The cell number is the wrong length.\n";
    } 
return error;
}

// non-empty textbox
function isEmpty(strng) {
var error = "";
  if (strng.length == 0) {
     error = "The mandatory text area has not been filled in.\n"
  }
return error;	  
}

// was textbox altered
function isDifferent(strng) {
var error = ""; 
  if (strng != "Can\'t touch this!") {
     error = "You altered the inviolate text area.\n";
  }
return error;
}

// exactly one radio button is chosen
function checkRadio(checkvalue) {
var error = "";
   if (!(checkvalue)) {
       error = "Please check a radio button.\n";
    }
return error;
}

// valid selector from dropdown list
function checkDropdown(choice) {
var error = "";
    if (choice == 0) {
    error = "You didn't choose an option from the drop-down list.\n";
    }    
return error;
}  

  ----------------------------------  end unused functions  --------------------------*/