function validate()
{
    theForm = document.forms['f'];
    if (theForm.firstname.value.match('^ *$')) {
        alert('Please enter your first name in the "First Name" field.');
        return false;
    }
    if (theForm.lastname.value.match('^ *$')) {
        alert('Please enter your last name in the "Last Name" field.');
        return false;
    }
    if (theForm.email.value.match('^ *$')
     && theForm.phonenumber.value.match('^ *$')) {
        alert('Please enter an email address or phone number so that we can '
            + 'contact you.');
        return false;
    }
    if (!theForm.phonenumber.value.match('^ *$')) {
        var us = /^\(?\d{3}\)?(\s|-)?\d{3}(\s|-)?\d{4}$/;
        var international = /^\+?\d(\d|-|\.|\s){7,20}$/;
        if (!theForm.phonenumber.value.match(us)
            && !theForm.phonenumber.value.match(international)) {
            alert('Please enter a valid US (xxx-xxx-xxxx) or international phone number.');
            return false;
        }
    }
    if (!theForm.email.value.match('^ *$')) {
        if (!emailCheck(theForm.email.value)){
            return false;
        }
    }
// if (-1 == theForm.date.selectedIndex) {
// alert('Please select your preferred date for the webinar')
// return false;
// }
// var checksession = false;
// for (i =0; i < theForm.session.length; i++) {
// checksession = checksession || theForm.session[i].checked;
// }
// checksession = checksession || (theForm.sessionalt.value != "");
// if(!checksession){
// alert('Please select a session time');
// return false;
// }
    
    if (theForm.recaptcha_response_field.value.match('^ *$')) {
        alert('Please enter a value into the CAPTCHA field above.');
        return false;
    }

    return true;
}
function emailCheck (emailStr) {
/*
 * This script and many more are available free online at The JavaScript
 * Source!! http://javascript.internet.com
 * 
 * V1.1.3: Sandeep V. Tamhankar (stamhankar@hotmail.com)
 * 
 * this was modified from the original by removing comments for performance -
 * rgi@tek
 */

var checkTLD=1;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

var matchArray=emailStr.match(emailPat);
if (matchArray==null) {
  alert("Email address seems incorrect (check @ and .'s)");
  return false;
}
var user=matchArray[1];
var domain=matchArray[2];

for (i=0; i<user.length; i++) {
  if (user.charCodeAt(i)>127) {
    alert("Ths username portion of your e-mail address contains invalid characters.");
    return false;
  }
}
for (i=0; i<domain.length; i++) {
  if (domain.charCodeAt(i)>127) {
    alert("Ths domain name in your e-mail address contains invalid characters.");
    return false;
  }
}

if (user.match(userPat)==null) {
  alert("The username portion of your e-mail address doesn't seem to be valid.");
  return false;
}

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
  for (var i=1;i<=4;i++) {
    if (IPArray[i]>255) {
      alert("Destination IP address in your e-mail address is invalid!");
      return false;
      }
  }
  return true;
}

var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
  if (domArr[i].search(atomPat)==-1) {
    alert("The domain name portion of your e-mail address does not seem to be valid.");
    return false;
    }
}
if (checkTLD && domArr[domArr.length-1].length!=2 && 
    domArr[domArr.length-1].search(knownDomsPat)==-1) {
  alert("Your e-mail address must end in a well-known domain or two letter " + "country.");
  return false;
}

if (len<2) {
  alert("Your e-mail address is missing a hostname!");
  return false;
}
return true;
}
