function checkEmail (strng) {
var error="";
if (strng == "") {
   error = "You didn't enter an email address.\n";
}

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Please enter a valid email address.\n";
    }
    else {  //test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "The email address contains illegal characters.\n";
       }
    }
return error;    
}


// phone number - strip out delimiters and check for 10 digits

function checkPhone (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a phone number.\n";
}

var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
   if (isNaN(parseInt(stripped))) {
      error = "The Phone number contains illegal characters.";
 
   }
   if (!(stripped.length == 10)) {
	error = "The Phone number is the wrong length. Make sure you included an area code.\n";
    } 
return error;
}


// Address - longer than 6 chars, uppercase or lowercase, and numeral

function checkAddress (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a Street Address.\n";
}

    var illegalChars = /[\(\)\<\>\;\:\\\"\[\]]/ // allow only letters and numbers
    
    if ((strng.length < 6) || (strng.length > 100)) {
       error = "The Street Address is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) {
      error = "The Street Address contains illegal characters.\n";
    } 
    else if (!((strng.search(/(a-z)+/)) && (strng.search(/(A-Z)+/)) && (strng.search(/(0-9)+/)))) {
       error = "The Street Address must contain at least one Number and letters letter.\n";
    }  
return error;    
}  

// Suburb - longer than 2 chars, uppercase or lowercase

function checkSuburb (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a Suburb.\n";
}

    var illegalChars = /[\(\)\<\>\;\:\\(0-9)\"\[\]]/ // allow only letters and numbers
    
    if ((strng.length < 3) || (strng.length > 50)) {
       error = "The Suburb is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) {
      error = "The Suburb contains illegal characters.\n";
    } 
    else if (!((strng.search(/(a-z)+/)) && (strng.search(/(A-Z)+/)))) {
       error = "The Suburb must contain at least 2 letters.\n";
    }  
return error;    
}   


// fullname - 4-30 chars, uc, lc, and underscore only.

function checkFullname (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a Name.\n";
}


    var illegalChars = /[\(\)\<\>\,\;\\(0-9)\:\\\"\[\]]/ // allow letters, numbers, and underscores
    if ((strng.length < 4) || (strng.length > 30)) {
       error = "The Name is the wrong length. Remember to include your full name.\n";
    }
    else if (illegalChars.test(strng)) {
    error = "The Name contains illegal characters.\n";
    } 
return error;
}       

// Post Code - check for 4 digits

function checkPostcode (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a Post Code.\n";
}

    var illegalChars = /[\(\)\<\>\,\;\\(A-Z)\(a-z)\:\\\"\[\]]/ // allow numbers only
    if (illegalChars.test(strng)) {
    error = "The Post Code contains illegal characters, please enter 4 numbers only.\n";
    }
    else if (!(strng.length == 4)) {
       error = "The Post Code is the wrong length (4 Numbers only).\n";
    }
return error;
}

// Compare Number of Adults in Family with Gold/Bronze Selection && (FamilyGold == 0) && (FamilyBronze == 0)){

function checkFamily (Gold, Bronze, Adult, Children) {

    var error = "";
    if((Adult > 0) && (Gold == 0) && (Bronze == 0)){ 
    error = "You haven't selected Gold or Bronze for family.\n";
    }
    if((Children > 0) && (Gold == 0) && (Bronze == 0)){ 
    error = "You haven't selected Gold or Bronze for family.\n";
    }
    else if ((Gold > 0) && (Adult == 0)) {
    error = "You haven't selected Number of Adults/Children coming.\n";
    }
    else if ((Bronze > 0) && (Adult == 0)) {
    error = "You haven't selected Number of Adults/Children coming.\n";
    }
return error;
}

// Compare Number of Seperate Entries on form (only 1 type allowed (Family, Couple or Single)

function checkonly1entry (AdultGold, AdultBronze, CoupleGold, CoupleBronze, SingleGold, SingleBronze) {

    var error = "";
      if (AdultGold > 0) {
         if ((AdultBronze > 0) || (CoupleGold > 0) || (CoupleBronze > 0) || (SingleGold > 0) || (SingleBronze > 0)){ 
         error = "You have Selected too many entrants only 1 family per form.\n";
      }
      }
      if (AdultBronze > 0) {
         if ((AdultGold > 0) || (CoupleGold > 0) || (CoupleBronze > 0) || (SingleGold > 0) || (SingleBronze > 0)){ 
         error = "You have Selected too many entrants only 1 family per form.\n";
      }
      }
      if (CoupleGold > 0) {
         if ((AdultGold > 0) || (AdultBronze > 0) || (CoupleBronze > 0) || (SingleGold > 0) || (SingleBronze > 0)){ 
         error = "You have Selected too many entrants only 1 family per form.\n";
      }
      }
      if (CoupleBronze > 0) {
         if ((AdultGold > 0) || (AdultBronze > 0) || (CoupleGold > 0) || (SingleGold > 0) || (SingleBronze > 0)){ 
         error = "You have Selected too many entrants only 1 family per form.\n";
      }
      }
      if (SingleGold > 0)  {
         if ((AdultGold > 0) || (AdultBronze > 0) || (CoupleGold > 0) || (CoupleBronze > 0) || (SingleBronze > 0)){ 
         error = "You have Selected too many entrants only 1 family per form.\n";
      }
      }
      if (SingleBronze > 0) {
         if ((AdultGold > 0) || (AdultBronze > 0) || (CoupleGold > 0) || (CoupleBronze > 0) || (SingleGold > 0)){ 
         error = "You have Selected too many entrants only 1 family per form.\n";
      }
      }
return error;
}


checkyoungadultwithfamily
function checkyoungadultwithfamily (AdultGold, AdultBronze, Young_Adult_Gold, Young_Adult_Bronze) {

    var error = "";
      if (Young_Adult_Gold > 0) {
         if ((AdultGold < 1) && (AdultBronze < 1)){ 
         error = "You have Selected Young Adult, but not a family1.\n";
      }
      }
      if (Young_Adult_Bronze > 0) {
         if ((AdultGold < 1) && (AdultBronze < 1)){ 
         error = "You have Selected Young Adult, but not a family2.\n";
      }
      }
return error;
}

// Shirt Size - check for max 2 digits

function checkshirtsize (strng) {
var error = "";

    var illegalChars = /[\(\)\<\>\,\;\\(A-Z)\(a-z)\:\\\"\[\]]/ // allow numbers only
    if (illegalChars.test(strng)) {
    error = "The extra T-Shirt or Polo Shirt Quantities contain incorrect values, please use numbers only (up to 10).\n";
    }
    else if (!(strng.length < 2 )) {
       error = "Too many extra T-Shirts or Polo Shirts have been selected.  Up to 10 only in each box.\n";
   }
return error;
}

// Is T-Shirt Different

function isTShirtDifferent (strng) {
var error = "";
if (!(strng == 0)) {
    error = "The Total amount of T-Shirt's selected isn't the same as you have purchased.\n";
    }
return error;
}

// Is Polo-Shirt Different

function isPoloDifferent (strng) {
var error = "";
if (!(strng == 0)) {
    error = "The Total amount of Total Polo Shirt's selected isn't the same as you have purchased.\n";
    }
return error;
}

function checkAgree (Agree) {

    var error = "";
    if(!(Agree)){ 
    error = "You haven't agreed to the Terms and Conditions of Entry.\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 haven't selected your free T-Shirt (or $15 extra for Polo shirt) size from the drop-down list.\n";
    }    
return error;
}    
