// GLOBAL FORM FUNCTIONS
//********************************************************************************************************
// Created: June 12, 2008
// By: Keith Valley
// Purpose: To create one document that can be included in all form pages to for java form verification 
//
//********************************************************************************************************
// 		TOC
/*
1. isBlank (inString)															
2. isWithinRange (inString, rangeMin, rangeMax)
3. trim (string)
6. advance(str)
7. cent(number)
8. round(number)
9. isNumeric(str)
10. isNumberString(inString)
11. isLetter(c)
12. isEmpty(val, name, title) - DEPRECATED
13. warnInvalid (theField, s) - DEPRACATED
14. isAlphabetic (s, name, title) - DEPRACATED
15. stripCharsInBag (s, bag) - DEPRECATED
16. stripWhitespace (s) - DEPRECATED
17. hidediv(id) 
18. showdiv(id) 
19. showDiet() 
20. popBoard(url)
21. isEmail(email)



*/

// whitespace characters
var whitespace = " \t\n\r";

/*
 * Function: isBlank (inString)
 * Purpose: Is the String Blank or empty
 * Arguments: String
 * Returns: boolean
 **/
function isBlank (inString) {
	if (inString == null || inString.length == 0) {
		return true;
	} else {
		return false;
	}
}
//********************************************************************************
//Function: isWithinRange (inString, rangeMin, rangeMax)
//Purpose: Is the String within the range
//Arguments: String, integer, integer
//Returns: boolean
//********************************************************************************
function isWithinRange (inString, rangeMin, rangeMax)  {
	if ((inString == null) || (inString == "")) { 
		return (false);
	}
	if((inString >= rangeMin) && (inString <= rangeMax)) {
		return true;
	} else {
		return false;
	}
}

//********************************************************************************
//Function: trim (string)
//Purpose: Removes the white space at the edges
//Arguments: String
//Returns: String
//********************************************************************************
function trim(sString) 
{ 
  while (sString.substring(0,1) == ' ') 
  { 
    sString = sString.substring(1, sString.length); 
  } 
  while (sString.substring(sString.length-1, sString.length) == ' ') 
  { 
    sString = sString.substring(0,sString.length-1); 
  } 
return sString; 
} 
//*************************************************
// If textbox reaches 2 in length go to next
//*************************************************
function advance(currentField,nextField) {
    if (currentField.value.length == 3)
        document.regForm[nextField].focus();
}

//****************************************************
// returns the amount in the .99 format
//****************************************************
function cent(amount) {
  amount -= 0;
  return (amount == Math.floor(amount)) ? amount + '.00' : (  (amount*10 == Math.floor(amount*10)) ? amount + '0' : amount);
}

//**********************************************************
// returns a number rounded to 2 decimal places
//**********************************************************
function round(number) {
  var X
  X = (!X ? 2 : X);
  return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
}


//********************************************************************************
// Function: isNumeric(str)
// Purpose: is string a numeric (integer or float)
// Arguments: String
// Returns: boolean
//********************************************************************************
function isNumeric(str) {
  var num;

  /* matches 99.999 */
  if (str.indexOf(".") > 0) {
    num = str.split(".");
    if (num.length == 2) {
      for (var i = 0; i < num.length; i++) {
        if (!isNumberString(num[i])) {
	  return false;
	}
      }
      return true;
    } else if (num.length > 2) {
      return false;
    }
    /* matches .999 */
    } else if (str.indexOf(".") == 0) {
      var temp = str.substring(1, str.length);
      if (isNumberString(temp)) {
        return true;
      } else {
	false;
      }
      
    /* matches 999 */
    } else if (isNumberString(str)) {
      return true;
    } else {
    return false;
  }
}
//*******************************************************************************
// Function: isNumberString(inString)
// Purpose: is the String a number (Integer)
// Arguments: String
// Returns: boolean
//*******************************************************************************
function isNumberString(inString)  {
  if (inString.length == 0) { 
    return false;
  }
  var refString = "1234567890";
  for (var count=0; count < inString.length; count++)  {
    var tempChar = inString.substring (count, count + 1);
    if (refString.indexOf(tempChar, 0) == -1) {  
      return false;
    }
  }
  return true;
}


//********************************************************************************
// Function: isLetter(c)
// Purpose: to verify that a character is a letter
// Arguments: a single Character
// Returns: true if character c is an English letter (A .. Z, a..z).
//********************************************************************************
function isLetter (c)
{   
  if (c == "-")
  {
    return true;
    //alert("got here");
  }
  else
  {
   return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) )
  }
}


//***************************************************************************
// Verify if the field is empty or not.
// If it is return false and tell the user that is is a required field
// Written By: Keith Valley  - Sept 14, 2001
//**************************************************************************
function isEmpty(val, name, title)
{
  //val = stripWhitespace(val)
  
  if (val == "")
  {
    var s
    s = "You have not entered your "+ title +". Please enter before submitting your registration"
    return warnInvalid(name, s);
  }
  return true;
}


//****************************************************************************
// Notify user that contents of field theField are invalid.
// String s describes expected contents of theField.value.
// Put select theField, put focus in it, and return false.
//****************************************************************************
function warnInvalid (theField, s)
{   theField.focus()
    theField.select()
    alert(s)
    return false
}


//*********************************************************************************
// Added May 2011 - Needed a function to verify emails before submitting the 
// retrieve password information
//*********************************************************************************
function isEmail(argvalue) {

  if (argvalue.indexOf(" ") != -1)
    return false;
  else if (argvalue.indexOf("@") == -1)
    return false;
  else if (argvalue.indexOf("@") == 0)
    return false;
  else if (argvalue.indexOf("@") == (argvalue.length-1))
    return false;

  // arrayString = argvalue.split("@"); (works only in netscape3 and above.)
  var retSize = customSplit(argvalue, "@", "arrayString");

  if (arrayString[1].indexOf(".") == -1)
    return false;
  else if (arrayString[1].indexOf(".") == 0)
    return false;
  else if (arrayString[1].charAt(arrayString[1].length-1) == ".") {
    return false;
  }

  return true;
}


//********************************************************************************
//
//********************************************************************************
function isAlphabetic (s, name, title) {   
  var i;
  var send
  send = "The Field '" + title +"' is not in a Valid format.  Please include only Letters (A-Z or a-z) in this field."
  
  for (i = 0; i < s.length; i++)
  {   
        // Check that current character is letter.
        var c = s.charAt(i);
        
        if (!isLetter(c))
        return warnInvalid(name, send);
  }
    // All characters are letters.
    return true;
}



//********************************************************************************
// Removes all characters which appear in string bag from string s.
//********************************************************************************
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;
}
//********************************************************************************
// Removes all whitespace characters from s.
// Global variable whitespace (see above)
// defines which characters are considered whitespace.
//********************************************************************************
function stripWhitespace (s)
{   return stripCharsInBag (s, whitespace)
}






//*****************************************************************
// Hide block of HTML code within div tag
//*****************************************************************
function hidediv(id) {
  //safe function to hide an element with a specified id
  if (document.getElementById) { // DOM3 = IE5, NS6
    document.getElementById(id).style.display = 'none';
  } else {
    if (document.layers) { // Netscape 4
      document.id.display = 'none';
    } else { // IE 4
      document.all.id.style.display = 'none';
    }
  }
}

//*****************************************************************
// show block of HTML code within div tag
//*****************************************************************
function showdiv(id) {
  //safe function to show an element with a specified id
  if (document.getElementById) { // DOM3 = IE5, NS6
    document.getElementById(id).style.display = 'block';
  } else {
    if (document.layers) { // Netscape 4
      document.id.display = 'block';
    } else { // IE 4
      document.all.id.style.display = 'block';
    }
  }
}

//***************************************************************
// Show or hide Diet information
//***************************************************************
function showDiet() {
  if (document.regForm.diet[1].checked)
  {
    showdiv('diet_display');
  } else {
    document.regForm.diet_specify.value="";
    //document.regForm.pnametag.value="";
    hidediv('diet_display');
  }
}

function showSpecial() {

  if (document.regForm.special_needs[1].checked)
  {
    showdiv('special_display');
  } else {
    document.regForm.special_specify.value="";
    hidediv('special_display');
  }
}

//***************************************************************
// A pop up window function
//***************************************************************
function popBoard(url)
{
	window.open(url, "winn", 'toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=0,resizable=0,width=800,height=565');
}


//***************************************************************
// Surf to a different page based on drop down selection
//***************************************************************
function surfto(form) {
       var myindex=form.dest.selectedIndex
       window.open(form.dest.options[myindex].value, 
         target="_blank");
}



//****************************************************************************
// Display the tax depending on whether or not it is an exempt user
// registering.
// Written By: Keith Valley   May 10, 2006
//****************************************************************************
function isExempt(amount) {
  var SubTotal 
	var Total
	var tax
	var gst			= 5.00
	
	SubTotal =  (amount - 0);
	 //alert(SubTotal);
	 if (document.regForm.exempt.checked)
   {
       document.regForm.gst.value = "0.00";
       tax = ("0.00" - 0)
   } else {
       // figure out the tax
       tax = SubTotal / 100 * gst;
       tax = Math.floor(tax * 1000)/1000;
       document.regForm.gst.value = "" + cent(round(tax));
  }
 Total = (cent(round(tax))-0) + SubTotal;
 //alert(Total);
 document.regForm.Total.value = cent(Total);
}




//****************************************************************************
// Calculates the total of all conference fees
// Then call the necessary functions to calculate the total cost!
//****************************************************************************
function TotalCost_basic() {
 
 var SubTotal
 var tax
 var Total
 var gst = 12.00
 
 //document.regForm.partb.value = cent((document.regForm.precost1.value - 0) + (document.regForm.precost2.value - 0) + (document.regForm.postcost1.value - 0) + (document.regForm.postcost2.value - 0));
 //document.regForm.SubTotal.value = cent((document.regForm.parta.value - 0) + (document.regForm.partb.value - 0) + (document.regForm.partc.value - 0));
 
 SubTotal = document.regForm.subtotal.value
 
 if (document.regForm.gstexempt.value == "YES") 
 {
 
	 if (document.regForm.exempt.checked)
	 {
		  document.regForm.gst.value = "0.00";
		  tax = ("0.00" - 0)
	 } else {
		  
			// figure out the tax
		   tax = SubTotal / 100 * gst;
		   tax = Math.floor(tax * 1000)/1000;
		   document.regForm.gst.value = "" + cent(round(tax));
	 }
} else {

  tax = SubTotal / 100 * gst;
  tax = Math.floor(tax * 1000)/1000;
  document.regForm.gst.value = "" + cent(round(tax));


}
  
 //now get the total
 Total = (SubTotal - 0) + (tax - 0);
 document.regForm.total.value = "" + cent(round(Total));
}

//****************************************************************************
// Calculates the total of all conference fees
// Then call the necessary functions to calculate the total cost!
//****************************************************************************
function TotalCost_nogst() {
 
 var SubTotal
 var tax
 var Total
 //var gst = 5.00
 
 //document.regForm.partb.value = cent((document.regForm.precost1.value - 0) + (document.regForm.precost2.value - 0) + (document.regForm.postcost1.value - 0) + (document.regForm.postcost2.value - 0));
 //document.regForm.SubTotal.value = cent((document.regForm.parta.value - 0) + (document.regForm.partb.value - 0) + (document.regForm.partc.value - 0));
 
 SubTotal = document.regForm.subtotal.value
 
 /*if (document.regForm.gstexempt.value == "YES") 
 {
 
	 if (document.regForm.exempt.checked)
	 {
		  document.regForm.gst.value = "0.00";
		  tax = ("0.00" - 0)
	 } else {
		  
			// figure out the tax
		   tax = SubTotal / 100 * gst;
		   tax = Math.floor(tax * 1000)/1000;
		   document.regForm.gst.value = "" + cent(round(tax));
	 }
}*/
  
 //now get the total
 //Total = (SubTotal - 0) + (tax - 0);
 document.regForm.total.value = "" + cent(round(SubTotal));
}


//****************************************************************************
// Calculates the total of all conference fees
// Then call the necessary functions to calculate the total cost!
//****************************************************************************
function TotalCost_2subtotals() {
 
 var SubTotal
 var tax
 var Total
 var gst = 12.00
 
 document.regForm.subtotal.value = cent((document.regForm.subtotal1.value - 0) + (document.regForm.subtotal2.value - 0));
 SubTotal = document.regForm.subtotal.value
 
 //if (document.regForm.gstexempt.value == "YES") 
// {
 
	 if (document.regForm.exempt.checked)
	 {
		  document.regForm.gst.value = "0.00";
		  tax = ("0.00" - 0)
	 } else {
		  
			// figure out the tax
		   tax = SubTotal / 100 * gst;
		   tax = Math.floor(tax * 1000)/1000;
		   document.regForm.gst.value = "" + cent(round(tax));
	 }
//}
  
 //now get the total
 Total = (SubTotal - 0) + (tax - 0);
 document.regForm.total.value = cent(round(Total));
  
}







/* Validates the document. Returns true if valid                  */
/* else Opens a window with an error message(s) and returns false */
function isValidDocument_Basic() {

  //alert("got here");

	var errorMessages = "";
	var valid = true;
  	var phone = trim(document.regForm.phone1.value) +"-"+ trim(document.regForm.phone2.value) +"-"+ trim(document.regForm.phone3.value)

	/* find data entry errors */
	/* If an error occured, data input element is highlighted */
	with (document.regForm) {

		/* FIELD NAME = firstname -- Required */
		firstname.value = trim(firstname.value);
		if (isBlank(firstname.value) || firstname.value == "") {
			errorMessages += "Please Enter a First Name.\n";
			valid = false;
			firstname.className  = "DisplayFieldError";
		} else {
			firstname.className  = "DisplayFieldData";
		}

		/* FIELD NAME = lastname -- Required */
		lastname.value = trim(lastname.value);
		if (isBlank(lastname.value) || lastname.value == "") {
			errorMessages += "Please Enter a Last Name.\n";
			valid = false;
			lastname.className  = "DisplayFieldError";
		} else {
			lastname.className  = "DisplayFieldData";
		}
		
		/* FIELD NAME = Representing -- Required */
		representing.value = trim(representing.value);
		if (isBlank(representing.value) || representing.value == "") {
			errorMessages += "Please Enter an Organization .\n";
			valid = false;
			representing.className  = "DisplayFieldError";
		} else {
			representing.className  = "DisplayFieldData";
		}
		
		/* FIELD NAME = position -- Required */
		position.value = trim(position.value);
		if (isBlank(position.value) || position.value == "") {
			errorMessages += "Please Enter a Position.\n";
			valid = false;
			position.className  = "DisplayFieldError";
		} else {
			position.className  = "DisplayFieldData";
		}
		
		/* FIELD NAME = address -- Required */
		address.value = trim(address.value);
		if (isBlank(address.value) || address.value == "") {
			errorMessages += "Please Enter an Address.\n";
			valid = false;
			address.className  = "DisplayFieldError";
		} else {
			address.className  = "DisplayFieldData";
		}
		
		/* FIELD NAME = address -- Required */
		//address.value = trim(address.value);
		if (isBlank(province.value) || province.value == "") {
			errorMessages += "Please Enter a Province.\n";
			valid = false;
			province.className  = "DisplayFieldError";
		} else {
			province.className  = "DisplayFieldData";
		}
		
		/* FIELD NAME = city -- Required */
		city.value = trim(city.value);
		if (isBlank(city.value) || city.value == "") {
			errorMessages += "Please Enter a City.\n";
			valid = false;
			city.className  = "DisplayFieldError";
		} else {
			city.className  = "DisplayFieldData";
		}
		
		/* FIELD NAME = pcode  -- Required */
		pcode.value = trim(pcode.value);
		if (isBlank(pcode.value) || pcode.value == "") {
			errorMessages += "Please Enter a Postal Code.\n";
			valid = false;
			pcode.className  = "DisplayFieldError";
		} else {
			pcode.className  = "DisplayFieldData";
		}

		/* FIELD NAME = phone  -- Required */
		if (isBlank(phone1.value) || isBlank(phone2.value) || isBlank(phone3.value) ) {
			errorMessages += "Please Enter a Phone Number.\n";
			valid = false;
			phone1.className  = "DisplayFieldError";
			phone2.className  = "DisplayFieldError";
			phone3.className  = "DisplayFieldError";
		} else {
			phone1.className  = "DisplayFieldData";
			phone2.className  = "DisplayFieldData";
			phone3.className  = "DisplayFieldData";
		}
		
		/* FIELD NAME = email  -- Required */
		email.value = trim(email.value);
		if (isBlank(email.value) || email.value == "") {
			errorMessages += "Please Enter an Email.\n";
			valid = false;
			email.className  = "DisplayFieldError";
		} else {
			email.className  = "DisplayFieldData";
		}
		
		/* FIELD NAME = email  -- Required */
		if (diet[1].checked) {
			if (isBlank(diet_specify.value) || diet_specify.value == "") {
				errorMessages += "Please Enter Specific Dietary Needs.\n";
				valid = false;
				diet_specify.className  = "DisplayFieldError";
			} else {
				diet_specify.className  = "DisplayFieldData";
			}	
		}
	}

	if (valid) {
		return true;
	} else {
    alert("" + errorMessages);
		return false;
	}
}

/* Validates the document. Returns true if valid                  */
/* else Opens a window with an error message(s) and returns false */
function isValidDocument_nodiet() {

  //alert("got here");

	var errorMessages = "";
	var valid = true;
  	var phone = trim(document.regForm.phone1.value) +"-"+ trim(document.regForm.phone2.value) +"-"+ trim(document.regForm.phone3.value)

	/* find data entry errors */
	/* If an error occured, data input element is highlighted */
	with (document.regForm) {

		/* FIELD NAME = firstname -- Required */
		firstname.value = trim(firstname.value);
		if (isBlank(firstname.value) || firstname.value == "") {
			errorMessages += "Please Enter a First Name.\n";
			valid = false;
			firstname.className  = "DisplayFieldError";
		} else {
			firstname.className  = "DisplayFieldData";
		}

		/* FIELD NAME = lastname -- Required */
		lastname.value = trim(lastname.value);
		if (isBlank(lastname.value) || lastname.value == "") {
			errorMessages += "Please Enter a Last Name.\n";
			valid = false;
			lastname.className  = "DisplayFieldError";
		} else {
			lastname.className  = "DisplayFieldData";
		}
		
		/* FIELD NAME = Representing -- Required */
		representing.value = trim(representing.value);
		if (isBlank(representing.value) || representing.value == "") {
			errorMessages += "Please Enter an Organization .\n";
			valid = false;
			representing.className  = "DisplayFieldError";
		} else {
			representing.className  = "DisplayFieldData";
		}
		
		/* FIELD NAME = position -- Required */
		position.value = trim(position.value);
		if (isBlank(position.value) || position.value == "") {
			errorMessages += "Please Enter a Position.\n";
			valid = false;
			position.className  = "DisplayFieldError";
		} else {
			position.className  = "DisplayFieldData";
		}
		
		/* FIELD NAME = address -- Required */
		address.value = trim(address.value);
		if (isBlank(address.value) || address.value == "") {
			errorMessages += "Please Enter an Address.\n";
			valid = false;
			address.className  = "DisplayFieldError";
		} else {
			address.className  = "DisplayFieldData";
		}
		
		/* FIELD NAME = address -- Required */
		//address.value = trim(address.value);
		if (isBlank(province.value) || province.value == "") {
			errorMessages += "Please Enter a Province.\n";
			valid = false;
			province.className  = "DisplayFieldError";
		} else {
			province.className  = "DisplayFieldData";
		}
		
		/* FIELD NAME = city -- Required */
		city.value = trim(city.value);
		if (isBlank(city.value) || city.value == "") {
			errorMessages += "Please Enter a City.\n";
			valid = false;
			city.className  = "DisplayFieldError";
		} else {
			city.className  = "DisplayFieldData";
		}
		
		/* FIELD NAME = pcode  -- Required */
		pcode.value = trim(pcode.value);
		if (isBlank(pcode.value) || pcode.value == "") {
			errorMessages += "Please Enter a Postal Code.\n";
			valid = false;
			pcode.className  = "DisplayFieldError";
		} else {
			pcode.className  = "DisplayFieldData";
		}

		/* FIELD NAME = phone  -- Required */
		if (isBlank(phone1.value) || isBlank(phone2.value) || isBlank(phone3.value) ) {
			errorMessages += "Please Enter a Phone Number.\n";
			valid = false;
			phone1.className  = "DisplayFieldError";
			phone2.className  = "DisplayFieldError";
			phone3.className  = "DisplayFieldError";
		} else {
			phone1.className  = "DisplayFieldData";
			phone2.className  = "DisplayFieldData";
			phone3.className  = "DisplayFieldData";
		}
		
		/* FIELD NAME = email  -- Required */
		email.value = trim(email.value);
		if (isBlank(email.value) || email.value == "") {
			errorMessages += "Please Enter an Email.\n";
			valid = false;
			email.className  = "DisplayFieldError";
		} else {
			email.className  = "DisplayFieldData";
		}
		
	}

	if (valid) {
		return true;
	} else {
    alert("" + errorMessages);
		return false;
	}
}



/* Validates the document. Returns true if valid                  */
/* else Opens a window with an error message(s) and returns false */
function isValidDocument_Partner() {

  //alert("got here");

	var errorMessages = "";
	var valid = true;
  	var phone = trim(document.regForm.phone1.value) +"-"+ trim(document.regForm.phone2.value) +"-"+ trim(document.regForm.phone3.value)

	/* find data entry errors */
	/* If an error occured, data input element is highlighted */
	with (document.regForm) {

		/* FIELD NAME = firstname -- Required */
		firstname.value = trim(firstname.value);
		if (isBlank(firstname.value) || firstname.value == "") {
			errorMessages += "Please Enter a First Name.\n";
			valid = false;
			firstname.className  = "DisplayFieldError";
		} else {
			firstname.className  = "DisplayFieldData";
		}

		/* FIELD NAME = lastname -- Required */
		lastname.value = trim(lastname.value);
		if (isBlank(lastname.value) || lastname.value == "") {
			errorMessages += "Please Enter a Last Name.\n";
			valid = false;
			lastname.className  = "DisplayFieldError";
		} else {
			lastname.className  = "DisplayFieldData";
		}
		
		/* FIELD NAME = Representing -- Required */
		/*representing.value = trim(representing.value);
		if (isBlank(representing.value) || representing.value == "") {
			errorMessages += "Please Enter an Organization .\n";
			valid = false;
			representing.className  = "DisplayFieldError";
		} else {
			representing.className  = "DisplayFieldData";
		}*/
		
		/* FIELD NAME = position -- Required */
		dname.value = trim(dname.value);
		if (isBlank(dname.value) || dname.value == "") {
			errorMessages += "Please Enter a who you are Attending With.\n";
			valid = false;
			dname.className  = "DisplayFieldError";
		} else {
			dname.className  = "DisplayFieldData";
		}
		
		/* FIELD NAME = address -- Required */
		address.value = trim(address.value);
		if (isBlank(address.value) || address.value == "") {
			errorMessages += "Please Enter an Address.\n";
			valid = false;
			address.className  = "DisplayFieldError";
		} else {
			address.className  = "DisplayFieldData";
		}
		
		/* FIELD NAME = city -- Required */
		city.value = trim(city.value);
		if (isBlank(city.value) || city.value == "") {
			errorMessages += "Please Enter a City.\n";
			valid = false;
			city.className  = "DisplayFieldError";
		} else {
			city.className  = "DisplayFieldData";
		}
		
		/* FIELD NAME = pcode  -- Required */
		pcode.value = trim(pcode.value);
		if (isBlank(pcode.value) || pcode.value == "") {
			errorMessages += "Please Enter a Postal Code.\n";
			valid = false;
			pcode.className  = "DisplayFieldError";
		} else {
			pcode.className  = "DisplayFieldData";
		}

		/* FIELD NAME = phone  -- Required */
		if (isBlank(phone1.value) || isBlank(phone2.value) || isBlank(phone3.value) ) {
			errorMessages += "Please Enter a Phone Number.\n";
			valid = false;
			phone1.className  = "DisplayFieldError";
			phone2.className  = "DisplayFieldError";
			phone3.className  = "DisplayFieldError";
		} else {
			phone1.className  = "DisplayFieldData";
			phone2.className  = "DisplayFieldData";
			phone3.className  = "DisplayFieldData";
		}
		
		/* FIELD NAME = email  -- Required */
		email.value = trim(email.value);
		if (isBlank(email.value) || email.value == "") {
			errorMessages += "Please Enter an Email.\n";
			valid = false;
			email.className  = "DisplayFieldError";
		} else {
			email.className  = "DisplayFieldData";
		}
		
		/* FIELD NAME = email  -- Required */
		if (diet[1].checked) {
			if (isBlank(diet_specify.value) || diet_specify.value == "") {
				errorMessages += "Please Enter Specific Dietary Needs.\n";
				valid = false;
				diet_specify.className  = "DisplayFieldError";
			} else {
				diet_specify.className  = "DisplayFieldData";
			}	
		}
	}

	if (valid) {
		return true;
	} else {
    alert("" + errorMessages);
		return false;
	}
}
