 var limit = 400;
 function update()
 {
   var old = document.frmSubmit.counter.value;
   document.frmSubmit.counter.value=document.frmSubmit.comments.value.length;
   if(document.frmSubmit.counter.value > limit && old <= limit) {
     document.frmSubmit.submitButton.disabled= true;
     alert('Too much data in the text box!');
     if(document.styleSheets) {
       document.frmSubmit.counter.style.fontWeight = 'bold';
       document.frmSubmit.counter.style.color = '#ff0000'; } }
   else if(document.frmSubmit.counter.value <= limit && old > limit
	   && document.styleSheets ) {
       document.frmSubmit.submitButton.disabled = false;
       document.frmSubmit.counter.style.fontWeight = 'normal';
       document.frmSubmit.counter.style.color = '#000000'; }
   }


  // advanced email validation with regular expression
  var testresults

  function checkemail()
  {
    var str=document.frmSubmit.fromWho.value
    var str2=document.frmSubmit.fromWho2.value
    
    // require 2 identical (and probably valid) email addresses
    if (str == str2)
    {

      var filter=/^[A-Z0-9._%-]+@[A-Z0-9.-]{2,16}\.[A-Z]{2,4}$/i
      if (filter.test(str))
        testresults=true
      else
      {
        testresults=false
        alert("Please input a valid email addresses!")
      }
    }
    else
    {
      testresults=false
      alert("Please input Matching Email addresses")
    }

    // require typing in numbers and letters in a graphic
    if (checkGraphicPass(frmSubmit.checkPass.value) == true)
      compareGraphicResults=true
    else
    {
      compareGraphicResults=false
      alert("Please type exactly what appears in the graphic")
    }

    // DIS-Allow any text that contains "http://" in ZipCode, name, or comments fields
    // check email field
      var jsEmail=frmSubmit.fromWho.value;
          jsEmail = jsEmail.toUpperCase();
      var iStringCheckEmail=jsEmail.indexOf("HTTP://");

    // check Name field
      var jsName=frmSubmit.Name.value;
          jsName = jsName.toUpperCase();
      var iStringCheckName=jsName.indexOf("HTTP://");

    // check Comments field
      var jsComments=frmSubmit.comments.value;
          jsComments = jsComments.toUpperCase();
      var iStringCheckComments=jsComments.indexOf("HTTP://");

    // check ZipCode field
      var jsZip=frmSubmit.zip.value;
          jsZip = jsZip.toUpperCase();
      var iStringCheckZip=jsZip.indexOf("HTTP://");

    // show alert if any of them have "HTTP://"
      if (iStringCheckEmail>=0 || iStringCheckName>=0 || iStringCheckComments>=0 || iStringCheckZip>=0)
      {
        checkForLinks = false;
        alert("No links allowed in ANY fields")
      }
      else
        checkForLinks = true;

      // validate zip code with regular expressions
      var zipString = frmSubmit.zip.value;

      var zipFilter=/^([0-9]{5,9})$/; // look for only either 5 or 9 numbers
      if (zipFilter.test(zipString))
        validZipCode=true;
      else
      {
        validZipCode=false
        alert("Please input a valid USA Zip Code!\nDo not include dashes.")
      }


    // require that ALL 3 conditions are == true
    countTrue = 0
    if (testresults == true)
      countTrue++;

    if (checkForLinks == true)
      countTrue++;

    if (compareGraphicResults == true)
      countTrue++;

    if (validZipCode == true)
      countTrue++;

    if (countTrue == 4)
      allresults = true;
    else
      allresults = false;

    return (allresults)
  }

  function checkbae()
  {
    if (document.layers||document.getElementById||document.all)
      return checkemail()
    else
      return true
  }
  
  function showOtherBusTypeBox()
  {
    if (document.getElementById("busType").value == 'Other')
    {
        document.getElementById('otherBusTypeText').style['visibility'] = 'visible';
        document.getElementById('otherBusType').style['visibility'] = 'visible';
    }
    else
    {
        document.getElementById('otherBusTypeText').style['visibility'] = 'hidden';
        document.getElementById('otherBusType').style['visibility'] = 'hidden';
    }

  }

// setStyleById: given an element id, style property and
// value, apply the style.
// args:
//  i - element id
//  p - property
//  v - value
//
function setStyleById(i, p, v)
{
	var n = document.getElementById(i);
	n.style[p] = v;
}

  

