//<!--

// This function will validate a form
function validateForm_press_room(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.password.value))
  {
    msg = msg + "Password cannot be empty.\n";
    pass = 0;
  }

  if (pass == 1)
  {
    return true;
  }
  else
  {
    alert(msg);
    return false;
  }
}

// This function will validate a form
function validateForm_newsletter(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.email.value))
  {
    msg = msg + "Email cannot be empty.\n";
    pass = 0;
  }
  else
  {
    //validate the email address
    if (!(isEmail(theform.email.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 form
function validateForm_newsletter_90_day(theform)
{
  pass = 1; //assume everything is ok
  msg = "The following problems where found in trying to submit this form:\n\n";
  
  if (isEmpty(theform.yourname.value))
  {
    msg = msg + "Name cannot be empty.\n";
    pass = 0;
  }
  //make sure required fields are not empty
  if (isEmpty(theform.email.value))
  {
    msg = msg + "Email cannot be empty.\n";
    pass = 0;
  }
  else
  {
    //validate the email address
    if (!(isEmail(theform.email.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 form
function validateForm_comment(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.author.value))
  {
    msg = msg + "Name cannot be empty.\n";
    pass = 0;
  }
  
  if (isEmpty(theform.country.value))
  {
    msg = msg + "Country cannot be empty.\n";
    pass = 0;
  }
  
  //make sure required fields are not empty
  if (isEmpty(theform.email.value))
  {
    msg = msg + "Email cannot be empty.\n";
    pass = 0;
  }
  else
  {
    //validate the email address
    if (!(isEmail(theform.email.value)))
    {
      msg = msg + "Please enter a valid email address.\n";
      pass = 0;
    }
  }
  
  if (isEmpty(theform.subject.value))
  {
    msg = msg + "Subject cannot be empty.\n";
    pass = 0;
  }
  /*
  if (isEmpty(theform.captcha.value))
  {
    msg = msg + "Security Code cannot be empty.\n";
    pass = 0;
  }
  */
  if (isEmpty(theform.comment.value))
  {
    msg = msg + "Comment cannot be empty.\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;
}

function isAlphaNum(string) {
    if (string.search(/^[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}

function isNum(string) {
    if (string.search(/^[0-9]+$/) != -1)
        return false;
    else
        return true;
}

function isExecutable (s) {
	var p = /\.(bat|com|dll|exe|vbs)$/i;
	return p.test(s);
}

function isImage (s) {
	var p = /\.(gif|jpg)$/i;
	return p.test(s);
}

function isUrl (s) {
	var p = /^(http|https|ftp):\/\/\S+\.[^\.\s]{2,4}(\/\S*)?$/i;
	return p.test(s);
}

//-->