//<!--
// This function will validate a form
function validateForm(theform)
{
  pass = 1; //assume everything is ok
  msg = "The following problems where found in trying to submit this form:\n\n";

  //make sure required fields are not empty
  if (isEmpty(theform.courseName.value))
  {
    msg = msg + " - Please Enter the Course Name \n";
    pass = 0;
  }
  
  if (isEmpty(theform.courseDate.value))
  {
    msg = msg + "- Please Enter the Course Date \n";
    pass = 0;
  }

if (isEmpty(theform.companyName.value))
  {
    msg = msg + "-  Please enter the Company Name \n";
    pass = 0;
  }

if (isEmpty(theform.country.value))
  {
    msg = msg + "-  Please Enter the Country \n";
    pass = 0;
  }

if (isEmpty(theform.officeTele.value))
  {
    msg = msg + "-  Please enter the Office Telephone \n";
    pass = 0;
  }

  //validate the email address
  if (!(isEmail(theform.mailForm.value)) && !(isEmpty(theform.mailForm.value)))
  {
    msg = msg + "-  Please enter a valid email address\n";
    pass = 0;
  }
  
  if (!(isEmail(theform.mailBill.value))  && !(isEmpty(theform.mailBill.value)))
  {
    msg = msg + "- Please enter a valid email address\n";
    pass = 0;
  }


  if (pass == 1)
  {
    return true;
  }
  else
  {
    alert(msg);
        return false;
  }
}


// This function will validate a contact list
function validateMailList(theform)
{
  pass = 1; //assume everything is ok
  msg = "The following problems where found in trying to submit this form:\n\n";


  //validate the email address
  if (!(isEmail(theform.mailList.value)))
  {
  msg = msg + "- Please enter a valid email address\n";
  pass = 0;
  }

  if (pass == 1)
  {
    return true;
  }
  else
  {
    alert(msg); 
        return false;
  }
}


// validators ------------------------------------------------------------------
	
function isEmpty (s) {
	var p = /\S+/;
	return !p.test(s);
}

function isEmail(string) {
    if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}
