
<!-- hide JS code
//This file local.js 
//The file contains functions for request brochure input validation
//Writtten by WT 
//October 2008

function validRequest(myform)  // validate request brichure user input
{
         var form_name=myform.name; 
         if (isBlank(myform.realname.value))    //  name valid?
          {
            alert("Please enter your name:");
            myform.realname.focus();
            return false;
          }

         if (isBlank(myform.address.value))    // address valid?
          {
            alert("Please enter your address:");
            myform.address.focus();
            return false;
          }

         if (isBlank(myform.city.value))    // city valid?
          {
            alert("Please enter city:");
            myform.city.focus();
            return false;
          }

         var msg="Please select a state:";
          if (!validateSelect(myform.state,msg))  // state selected?
          {
            return false
          }

         if (isBlank(myform.zip.value))    // zip valid?
          {
            alert("Please enter zip code:");
            myform.zip.focus();
            return false;
          }

        if (!validateEMail(myform.email.value)){
           myform.email.focus();
           return false; 
        }  

        return true;
}//end of request brochure validation

function validateText(text,msg) // valid the Text field
  {
  if (isBlank(text))               // text field blank?
    {
    alert(msg);
    return false
    }
  return true
  }

function isBlank(testStr) // check if a field is blank
{
  
  if (testStr.length == 0)                     // nothing entered?
    return true
  for (var i = 0; i <= testStr.length-1; i++)  // all spaces?
    if (testStr.charAt(i) != " ")
      return false
  return true 
}

function validateSelect(item,msg) //check if a selection is valid, working properly
{
     if (item.selectedIndex==0) //check if only the first item on the list is selected which starts with "Select..."
          {
             alert(msg); 
             item.focus();
             return false; 
          }
     return true;   
}  
 
function validateEMail(email) // Check if email is valid, not use here
  {
  if (isBlank(email))                       // email blank?
    {
    alert("Please enter your valid email address. A vaild email address should be in the format of emailname@somewhere.com")
    return false
    }
  var atsignPos = email.indexOf("@", 0)     // check for @
  if (atsignPos == -1)  
    {
    alert("Enter a valid email address with an @, please!")
    return false
    }
  if (email.indexOf(".", atsignPos) == -1)  // check for . after @      
    {
    alert("Enter a valid email domain after the @, please!")
    return false
    }
  return true
  }

// end JS hide -->
