function wopen(url, name, w, h)
{
w += 32;
h += 96;
 var win = window.open(url,
  name, 
  'width=' + w + ', height=' + h + ', ' +
  'location=no, menubar=no, ' +
  'status=no, toolbar=no, scrollbars=yes, resizable=yes');
 win.resizeTo(w, h);
 win.focus();
}

function emailvalidation(field, alertbox) {
var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.info)|(\.sex)|(\.biz)|(\.aero)|(\.coop)|(\.museum)|(\.name)|(\.pro)|(\..{2,2}))$)\b/gi);
apos=field.value.indexOf("@");
dotpos=field.value.lastIndexOf(".");
lastpos=field.value.length-1;
var badEmail = (apos<1 || dotpos-apos<2 || lastpos-dotpos<2)
if (goodEmail && !badEmail) {
return true;
}
else {
alert(alertbox);
field.focus();
field.select();
return false;
   }
}
function emptyvalidation(entered, alertbox)
{
with (entered)
{
if (value==null || value=="")
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}
function formvalidation(thisform)
{
with (thisform)
{

if (emptyvalidation(name,"Please enter your name")==false) {name.focus(); return false;};

if (emptyvalidation(lastname,"Please enter your last name")==false) {lastname.focus(); return false;};

if (emailvalidation(email,"Please enter your valid email address")==false) {email.focus(); return false;};

}

}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function ContactForm_Validator(theForm)
{

  if (theForm.sfirstname.value == "")
  {
    alert("Please enter a value for the \"First Name\" field.");
    theForm.sfirstname.focus();
    return (false);
  }

  if (theForm.sfirstname.value.length < 3)
  {
    alert("Please enter at least 3 characters in the \"First Name\" field.");
    theForm.sfirstname.focus();
    return (false);
  }

  if (theForm.sfirstname.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"First Name\" field.");
    theForm.sfirstname.focus();
    return (false);
  }

  if (theForm.slastname.value == "")
  {
    alert("Please enter a value for the \"Last Name\" field.");
    theForm.slastname.focus();
    return (false);
  }

  if (theForm.slastname.value.length < 3)
  {
    alert("Please enter at least 3 characters in the \"Last Name\" field.");
    theForm.slastname.focus();
    return (false);
  }

  if (theForm.slastname.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Last Name\" field.");
    theForm.slastname.focus();
    return (false);
  }

  if (theForm.semail.value == "")
  {
    alert("Please enter a value for the \"Email\" field.");
    theForm.semail.focus();
    return (false);
  }

  if (theForm.semail.value.length < 3)
  {
    alert("Please enter at least 3 characters in the \"Email\" field.");
    theForm.semail.focus();
    return (false);
  }

  if (theForm.semail.value.length > 80)
  {
    alert("Please enter at most 80 characters in the \"Email\" field.");
    theForm.semail.focus();
    return (false);
  }

  if (theForm.stel.value == "")
  {
    alert("Please enter a value for the \"Phone\" field.");
    theForm.stel.focus();
    return (false);
  }

  if (theForm.stel.value.length < 5)
  {
    alert("Please enter at least 5 characters in the \"Phone\" field.");
    theForm.stel.focus();
    return (false);
  }

  if (theForm.stel.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Phone\" field.");
    theForm.stel.focus();
    return (false);
  }

  if (theForm.sreason.selectedIndex < 0)
  {
    alert("Please select one of the \"Reason\" options.");
    theForm.sreason.focus();
    return (false);
  }

  if (theForm.sreason.selectedIndex == 0)
  {
    alert("The first \"Reason\" option is not a valid selection.  Please choose one of the other options.");
    theForm.sreason.focus();
    return (false);
  }

  if (theForm.scomment.value == "")
  {
    alert("Please enter a value for the \"Message\" field.");
    theForm.scomment.focus();
    return (false);
  }

  if (theForm.scomment.value.length < 5)
  {
    alert("Please enter at least 5 characters in the \"Message\" field.");
    theForm.scomment.focus();
    return (false);
  }

  if (theForm.scomment.value.length > 500)
  {
    alert("Please enter at most 500 characters in the \"Message\" field.");
    theForm.scomment.focus();
    return (false);
  }

  if (theForm.strCAPTCHA.value == "")
  {
    alert("Please enter a value for the \"Verification Code\" field.");
    theForm.strCAPTCHA.focus();
    return (false);
  }

  if (theForm.strCAPTCHA.value.length < 5)
  {
    alert("Please enter at least 5 characters in the \"Verification Code\" field.");
    theForm.strCAPTCHA.focus();
    return (false);
  }


  var checkOK = "0123456789-";
  var checkStr = theForm.strCAPTCHA.value;
  var allValid = true;
  var validGroups = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Verification Code\" field.");
    theForm.strCAPTCHA.focus();
    return (false);
  }
  return (true);
}

