function supportBody() {
   document.getElementById('_lbl_10').style.display="none";
   document.getElementById('_fid_10').style.display="none"; 
}

function supportBody1() {
   document.getElementById('_lbl_10').style.display="none";
   document.getElementById('_fid_10').style.display="none"; 
   document.qdbform._fid_6.focus();
}

function dorequest() {
   if(document.getElementById('_fid_18').value == 10) {
      document.getElementById('_fid_10').style.display = 'block';
      document.getElementById('_lbl_10').style.display = 'block';
   }  else {
      document.getElementById('_fid_10').style.display = 'none';
      document.getElementById('_lbl_10').style.display = 'none';
   }
}

function validateEventForm(theForm) {
   if(theForm._fid_6.value == "") {
      alert('Please enter a value for the Name field.');
      theForm._fid_6.focus();
      return (false);
   }
   if(theForm._fid_7.value == "") {
      alert('Please enter a value for the Address field.');
      theForm._fid_7.focus();
      return (false);
   }
   if(theForm._fid_8.value == "") {
      alert('Please enter a value for the City field.');
      theForm._fid_8.focus();
      return (false);
   }
   if(theForm._fid_9.value == "") {
      alert('Please enter a value for the State field.');
      theForm._fid_9.focus();
      return (false);
   }
   if(theForm._fid_10.value == "") {
      alert('Please enter a value for the Zip Code field.');
      theForm._fid_10.focus();
      return (false);
   }
   if(theForm._fid_11.value == "") {
      alert('Please enter a value for the Phone field.');
      theForm._fid_11.focus();
      return (false);
   } else {
      if(checkInternationalPhone(theForm._fid_11.value)==false) {
         alert('Please enter a well-formed phone number for the Phone field.  A well-formed phone number is formatted as (555) 555-5555.');
         theForm._fid_11.focus();
         return (false);
      }
   }
   if(theForm._fid_12.value == "") {
      alert('Please enter a value for the Email field.');
      theForm._fid_12.focus();
      return (false);
   } else {
      checkemail = theForm._fid_12.value;
      AtPos = checkemail.indexOf("@");
      StopPos = checkemail.lastIndexOf(".");
      if (AtPos == -1 || StopPos == -1) {
         alert('Please enter a well-formed email address for the Email field.  A well-formed email is formatted as name@domain.');
         theForm._fid_12.focus();
         return (false);
      }
      if (StopPos < AtPos) {
         alert('Please enter a well-formed email address for the Email field.  A well-formed email is formatted as name@domain.');
         theForm._fid_12.focus();
         return (false);
      }
      if (StopPos - AtPos == 1) {
         alert('Please enter a well-formed email address for the Email field.  A well-formed email is formatted as name@domain.');
         theForm._fid_12.focus();
         return (false);
      } 
   }
   if(theForm._fid_13.value == "") {
      alert('Please enter a value for the Organization field.');
      theForm._fid_13.focus();
      return (false);
   }
   if(theForm._fid_14.value == "") {
      alert('Please enter a value for the Job Title field.');
      theForm._fid_14.focus();
      return (false);
   }
}

function validateSupportForm(theForm) {
   if(theForm._fid_6.value == "") {
      alert('Please enter a value for the "Name" field.');
      theForm._fid_6.focus();
      return (false);
   }
   if(theForm._fid_15.value == "") {
      alert('Please enter a value for the "Institution" field.');
      theForm._fid_15.focus();
      return (false);
   }
   if(theForm._fid_7.value == "") {
      alert('Please enter a value for the "Phone Number" field.');
      theForm._fid_7.focus();
      return (false);
   }
   else {
      if (checkInternationalPhone(theForm._fid_7.value)==false) {
         alert('Please enter a well-formed phone number for the Phone field.  A well-formed phone number is formatted as (555) 555-5555.');
         theForm._fid_7.focus();
         return (false);
      }
   }
   if(theForm._fid_8.value == "") {
      alert('Please enter a value for the "Email" field.');
      theForm._fid_8.focus();
      return (false);
      }
   else {
      checkemail = theForm._fid_8.value;
      AtPos = checkemail.indexOf("@");
      StopPos = checkemail.lastIndexOf(".");
      if (AtPos == -1 || StopPos == -1) {
         alert('Please enter a well-formed email address.  A well-formed email is formatted as name@domain.');
         theForm._fid_8.focus();
         return (false);
      }
      if (StopPos < AtPos) {
         alert('Please enter a well-formed email address.  A well-formed email is formatted as name@domain.');
         theForm._fid_8.focus();
         return (false);
      }
      if (StopPos - AtPos == 1) {
         alert('Please enter a well-formed email address.  A well-formed email is formatted as name@domain.');
         theForm._fid_8.focus();
         return (false);
      } 
   }
   if(theForm._fid_18.value == "10" && theForm._fid_10.value == "") { 
      alert('Please enter a value for the "Other Request" field.');
      theForm._fid_10.focus();
      return (false);
   }
}

function validateForm(theForm) {
   if(theForm.email.value == "") {
         alert('Please enter a well-formed email address.  A well-formed email is formatted as name@domain.');
      theForm.email.focus();
      return (false);
   }
   else {
      checkemail = theForm.email.value;
      AtPos = checkemail.indexOf("@");
      StopPos = checkemail.lastIndexOf(".");
      if (AtPos == -1 || StopPos == -1) {
         alert('Please enter a well-formed email address.  A well-formed email is formatted as name@domain.');
         theForm.email.focus();
         return (false);
      }
      if (StopPos < AtPos) {
         alert('Please enter a well-formed email address.  A well-formed email is formatted as name@domain.');
         theForm.email.focus();
         return (false);
      }
      if (StopPos - AtPos == 1) {
         alert('Please enter a well-formed email address.  A well-formed email is formatted as name@domain.');
         theForm.email.focus();
         return (false);
      } 
   }
}

function validateMembershipForm(theForm) {
   if(theForm.membership_type.selectedIndex == 0) {
      alert('Please select a Membership Type.');
      theForm.membership_type.focus();
      return (false);
   }
   if(theForm.school_name.value == "") {
      alert('Please enter a value for the School Name field.');
      theForm.school_name.focus();
      return (false);
   }
   if(theForm.address1.value == "") {
      alert('Please enter a value for the Address Line 1 field.');
      theForm.address1.focus();
      return (false);
   }
   if(theForm.city.value == "") {
      alert('Please enter a value for the City field.');
      theForm.city.focus();
      return (false);
   }
   if(theForm.state.selectedIndex == 0) {
      alert('Please select a State.');
      theForm.state.focus();
      return (false);
   }
   if(theForm.zip.value == "") {
      alert('Please enter a value for the Zip Code field.');
      theForm.zip.focus();
      return (false);
   }
   if(theForm.website.value == "") {
      alert('Please enter a value for the Website field.');
      theForm.website.focus();
      return (false);
   }
   if(theForm.institution_type.selectedIndex == 0) {
      alert('Please select an Institution Type.');
      theForm.institution_type.focus();
      return (false);
   }
   if(theForm.institution_type.selectedIndex == 5) {
      if(theForm.other_institution_type.value == "") {
         alert('Please enter a value for the Other Institution Type field.');
         theForm.other_institution_type.focus();
         return (false);
      }
   }
   if(theForm.primary_contact_name.value == "") {
      alert('Please enter a value for the Primary Contact Name field.');
      theForm.primary_contact_name.focus();
      return (false);
   }
   if(theForm.primary_contact_title.value == "") {
      alert('Please enter a value for the Primary Contact Title field.');
      theForm.primary_contact_title.focus();
      return (false);
   }
   if(theForm.primary_contact_phone.value == "") {
      alert('Please enter a value for the Primary Contact Phone field.');
      theForm.primary_contact_phone.focus();
      return (false);
   }
   if(theForm.primary_contact_phone.value != "") {
      if (checkInternationalPhone(theForm.primary_contact_phone.value)==false) {
         alert('Please enter a well-formed phone number for the Primary Contact Phone field.  A well-formed phone number is formatted as (555) 555-5555.');
         theForm.primary_contact_phone.focus();
         return (false);
      }
   }
   if(theForm.primary_contact_fax.value == "") {
      alert('Please enter a value for the Primary Contact Fax field.');
      theForm.primary_contact_fax.focus();
      return (false);
   }
   if(theForm.primary_contact_fax.value != "") {
      if (checkInternationalPhone(theForm.primary_contact_fax.value)==false) {
         alert('Please enter a well-formed phone number for the Primary Contact Fax field.  A well-formed phone number is formatted as (555) 555-5555.');
         theForm.primary_contact_fax.focus();
         return (false);
      }
   }
   if(theForm.primary_contact_email.value == "") {
      alert('Please enter a value for the Primary Contact Email field.');
      theForm.primary_contact_email.focus();
      return (false);
   }
   if(theForm.primary_contact_email.value != "") {
      checkemail = theForm.primary_contact_email.value;
      AtPos = checkemail.indexOf("@");
      StopPos = checkemail.lastIndexOf(".");
      if (AtPos == -1 || StopPos == -1) {
         alert('Please enter a well-formed email address for the Primary Contact Email field.  A well-formed email is formatted as name@domain.');
         theForm.primary_contact_email.focus();
         return (false);
      }
      if (StopPos < AtPos) {
         alert('Please enter a well-formed email address for the Primary Contact Email field.  A well-formed email is formatted as name@domain.');
         theForm.primary_contact_email.focus();
         return (false);
      }
      if (StopPos - AtPos == 1) {
         alert('Please enter a well-formed email address for the Primary Contact Email field.  A well-formed email is formatted as name@domain.');
         theForm.primary_contact_email.focus();
         return (false);
      } 
   }
   if(theForm.secondary_contact_name.value == "") {
      alert('Please enter a value for the Secondary Contact Name field.');
      theForm.secondary_contact_name.focus();
      return (false);
   }
   if(theForm.secondary_contact_title.value == "") {
      alert('Please enter a value for the Secondary Contact Title field.');
      theForm.secondary_contact_title.focus();
      return (false);
   }
   if(theForm.secondary_contact_phone.value == "") {
      alert('Please enter a value for the Secondary Contact Phone field.');
      theForm.secondary_contact_phone.focus();
      return (false);
   }
   if(theForm.secondary_contact_phone.value != "") {
      if (checkInternationalPhone(theForm.secondary_contact_phone.value)==false) {
         alert('Please enter a well-formed phone number for the Secondary Contact Phone field.  A well-formed phone number is formatted as (555) 555-5555.');
         theForm.secondary_contact_phone.focus();
         return (false);
      }
   }
   if(theForm.secondary_contact_email.value == "") {
      alert('Please enter a value for the Secondary Contact Email field.');
      theForm.secondary_contact_email.focus();
      return (false);
   }
   if(theForm.secondary_contact_email.value != "") {
      checkemail = theForm.secondary_contact_email.value;
      AtPos = checkemail.indexOf("@");
      StopPos = checkemail.lastIndexOf(".");
      if (AtPos == -1 || StopPos == -1) {
         alert('Please enter a well-formed email address for the Secondary Contact Email field.  A well-formed email is formatted as name@domain.');
         theForm.secondary_contact_email.focus();
         return (false);
      }
      if (StopPos < AtPos) {
         alert('Please enter a well-formed email address for the Secondary Contact Email field.  A well-formed email is formatted as name@domain.');
         theForm.secondary_contact_email.focus();
         return (false);
      }
      if (StopPos - AtPos == 1) {
         alert('Please enter a well-formed email address for the Secondary Contact Email field.  A well-formed email is formatted as name@domain.');
         theForm.secondary_contact_email.focus();
         return (false);
      } 
   }
}

// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s) {   
   var i;
   for (i = 0; i < s.length; i++) {   
      // Check that current character is number.
      var c = s.charAt(i);
      if (((c < "0") || (c > "9"))) return false;
   }
   // All characters are numbers.
   return true;
}

function stripCharsInBag(s, bag) {   
   var i;
   var returnString = "";
   // Search through string's characters one by one.
   // If character is not in bag, append to returnString.
   for (i = 0; i < s.length; i++) {   
      // Check that current character isn't whitespace.
      var c = s.charAt(i);
      if (bag.indexOf(c) == -1) returnString += c;
   }
   return returnString;
}

function checkInternationalPhone(strPhone) {
   s=stripCharsInBag(strPhone,validWorldPhoneChars);
   return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}
