
function check_form(form)
{
/* loop through the form looking for one or more critical fields that need to have been filled in, selection made or ???
   step one is to find the proper field 
   step two is to insure the field has content ( changed or contains ( or not) data . Perhaps seed it with element 0 of an array )
   step three is provide the test needed to insure the correct data is submitted with the form.
        This would include simple if then else tests (data input eq "test") or complex regular expression tests (phone number, email address etc)
*/		

temp_return = false;
return_boolean = true;

 obj = eval(form)
 for(i=0;i<obj.length;i++)
 {
  field_name = obj.elements[i].name;
 
  /* Make sure field has something selected */ 
  if (field_name.indexOf("ChooseSite") != -1) 
   {
   if (obj.elements[i].value == "")
   {
	obj.elements[i].style.backgroundColor = "yellow";
    alert('No selection made for clinic.');
	return_boolean = false;
   }
   else
   {
   obj.elements[i].style.backgroundColor = "white";  // set to white in case it was red from last time
   } 	
  }
  /* end choosesite */
 
  /* Make sure that if they entered a phone number it matches a telephone pattern */ 
  if (field_name.indexOf("telephone") != -1)
  {
   if (obj.elements[i].value == "")
   {
     obj.elements[i].style.backgroundColor = "white"; // set to white in case it was red from last time
   }
   else
   {
	var errmsg = false;
	/* lets make sure we have enough chars */
	var valueOfNbr = obj.elements[i].value;
	var lenOfNbr   = valueOfNbr.length;
	switch (lenOfNbr)
	{
	 case 8:
	  errmsg = false;
	  break
	 case 12:
	  errmsg = false;
	  break
    
	 default:
	 errmsg = true;
	}
		
	if (errmsg)
    {
	 alert('Use either of these patterns: 123 1234 or 123 123 1234  with dashes, periods or spaces as separators.');
	 obj.elements[i].style.backgroundColor = "yellow";
	  return_boolean = false;
	}
 	else
	{
	 /* if we have the correct length make sure they are all valid telephone chars */
	 var valid = "0123456789- .()";
	 for (var y=0; y < lenOfNbr; y++)
	 {
	  temp = "" + valueOfNbr.substring(y, y+1);
	  if (valid.indexOf(temp) == "-1")
	  {
	    errmsg = true;
	  }
	 }
	 /* if an illegal char was found alert the operator */
	 if (errmsg)
	 {
	   alert("Invalid characters in your telephone number.  Please try again.");
	   obj.elements[i].style.backgroundColor = "yellow";
	   return_boolean = false;
	 }	
	 else
	 {
	   obj.elements[i].style.backgroundColor = "white"; // set to white in case it was red from last time
	 }
	} 
   }
  }
  /* end telephone */
  
  /* Make sure email has data and is a valid email format */
  if (field_name.indexOf("email") != -1)
  {
    var goodEmail = (obj.elements[i].value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi));
    if (goodEmail)
    {
	  obj.elements[i].style.backgroundColor = "white"; // set to white in case it was red from last time
    }
    else
    {
     
	 obj.elements[i].style.backgroundColor = "yellow";
     alert('Please enter a valid e-mail address.');
	 return_boolean = false;
    }
  }
  /* end email */ 
  
 
 } 
return return_boolean;
}
-->

