function reset_all(id)
 {
 if(document.forms.length == 2)
   id=1;

 for(var j=0; j<=2; j++)
   {
   document.forms[id].elements[j].style.backgroundColor="white";
   document.forms[id].elements[j].value="";
   }
 }

function trim(thevalue)
  {
  var temp=thevalue;

  for (var j=0;j<=thevalue.length-1;j++)
    {
    if (temp.charAt(0)==' ')
      {
      temp=temp.substr(1,temp.length);
      }
    else
      {
      break;
      }
    }

  var temp2=temp;
  for (var j=temp.length-1;j>=0;j--)
    {
    if (temp2.charAt(j)==' ')
      {
      temp2=temp2.substr(0,temp2.length-1);
      }
    else
      {
      break;
      }
    }

  return temp2;
  }

//validates form returns true if all values are correct
function validateForm()
  {
  var namestr = document.getElementById("name");
  var emailstr = document.getElementById("email");

  var noerror=true;
  var error_str="";

  if(!(checkFullName(namestr.value)))
    {
    error_str += "Please Provide First and Last Name\n";
    }

  if(!(checkEmail(emailstr.value)))
    {
    error_str += "Please Provide Correct Email";
    }

  if(error_str.length > 0)
    {
    alert (error_str);
    return false
    }

  return true;
  }

function check_all(id)
  {
  if(document.forms.length == 2)
   id=1;

  var noerror=true;

  for (var j=0;j<=2;j++)
    {
    document.forms[id].elements[j].value=trim(document.forms[id].elements[j].value);
    if (document.forms[id].elements[j].value.length==0)
     	{
    	document.forms[id].elements[j].style.backgroundColor="#fcfa9e";
      noerror=false;
      }
    else
      document.forms[id].elements[j].style.backgroundColor="white";
    }

  if (noerror)
    {
    document.forms[id].target="blank";
    document.forms[id].submit();
    }
  else
    {
    dothis(0);
    }
  }

function checkFullName(str)
  {
  var filter= /^([a-zA-Z]+[ ]+[a-zA-Z ]+)$/;

  if (filter.test(str))
    return true;

  return false;
  }

function checkEmail(str)
  {
  document.forms[0].email.value=str;
  var filter=/^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

  if (filter.test(str))
    {
    return true;
    }

  return false;
  }

var errstring0="";

function check_all_phone()
  {
  errstring0="";
  var noerror=true;

  for (var j=0; j<=2; j++)
    {
    document.forms[0].elements[j].value=trim(document.forms[0].elements[j].value);
    document.forms[0].elements[j].style.backgroundColor="white";
   	}

  if (document.forms[0].elements[0].value.length==0)
    {
    document.forms[0].elements[0].style.backgroundColor="#fcfa9e";
    noerror=false;
    errstring0="Valid FullName is required.<br>";
    }
  else
    {
    if (!checkFullName(document.forms[0].elements[0].value))
      {
      document.forms[0].elements[0].style.backgroundColor="#fcfa9e";
      noerror=false;
    	errstring0="Valid fullname is required.<br>";
    	}

    if (document.forms[0].elements[1].value.length<12)
     	{
      document.forms[0].elements[1].style.backgroundColor="#fcfa9e";
      noerror=false;
      errstring0=errstring0 +"Valid telephone number is required.<br>";
      }

    document.forms[0].elements[2].value=trim(document.forms[0].elements[2].value);
    if (document.forms[0].elements[2].value.length>0)
      {
      if (!checkEmail(document.forms[0].elements[2].value))
        {
        document.forms[0].elements[2].style.backgroundColor="#fcfa9e";
        noerror=false;
        errstring0=errstring0 +"Valid e-mail number is expected.<br>;"
        }
      }
    }

  if (noerror)
    {
    show_thanks();
    //document.forms[0].submit();
    }
  else
    {
    dothis(0);
    }
  }

function formatalphastring(estring)
  {
  if (estring.value == "") return;

  var alpha = new String (estring.value);
  alpha = alpha.substring(0,30);

  if (alpha.match ("[a-zA-Z ]{60}") == null)
    {
    if (alpha.match ("[a-zA-Z ]{60}") == null)
      {
      var alphaAlpha = alphaChar = "", i;
      for (var i=0; i<alpha.length; i++)
        {
        alphaChar = alpha.substr (i,1);
        var filter=/^[a-zA-z ]$/i;
        if (filter.test(alphaChar))
          {
          alphaAlpha = alphaAlpha + alphaChar;
          }
        }

      alpha = "";
      for (i=0;i<alphaAlpha.length;i++)
        {
        alpha = alpha + alphaAlpha.substr (i,1)
        }
      }
    }

  if (alpha != estring.value)
    {
    estring.value = alpha;
    }
  }

function checkalphastring(estring)
  {
  if (estring.value == "")
    {
    return;
    }

  if (estring.value.match ("[A-Z ]") == null)
    {
    formatalphastring(estring);
    }
  }

function formatTelNo(telNo)
  {
  if (telNo.value == "") return;

  var phone = new String (telNo.value);
  phone = phone.substring(0,12);

  if (phone.match ("[0-9]{3}-[0-9]{3}-[0-9]{4}") == null)
    {
    if (phone.match ("[0-9]{2}-[0-9]{3}-[0-9]{4}|" + "[0-9]-[0-9]{3}-[0-9]{4}|" + "[0-9]{3}-[0-9]{2}-[0-9]{4}|" + "[0-9]{3}-[0-9]-[0-9]{4}") == null)
      {
      var phoneNumeric = phoneChar = "", i;
      for (i=0;i<phone.length;i++)
        {
        phoneChar = phone.substr (i,1);
        if (!isNaN (phoneChar) && (phoneChar != " "))
          {
		      phoneNumeric = phoneNumeric + phoneChar;
          }
        }

      phone = "";

      for (i=0;i<phoneNumeric.length;i++)
        {
        if (i == 0) phone = phone;
        if (i == 3) phone = phone + "-";
        if (i == 6) phone = phone + "-";

        phone = phone + phoneNumeric.substr (i,1)
        }
      }
    }

  else
    {
    phone = phone.substring (0,3) + "-" + phone.substring (4,7) + "-" + phone.substring(8,12);
    }

  if (phone != telNo.value) telNo.value = phone;
  }

function checkTelNo(telNo)
  {
  if (telNo.value == "")
    return;

  if (telNo.value.match ("[0-9]{3}-[0-9]{3}-[0-9]{4}") == null)
    formatTelNo(telNo);
  }

var whichone=-1;
var txt= "<font style='font-family:Verdana;font-size:8pt;font-weight:600;color:red'>Input Error<br><font style='font-family:Arial;font-size:8pt;font-weight:500;color:black'>Please reenter the fileds highlighted with yellow and resubmit.";

function dothis(th)
  {
  void(true);

  whichone=th;

  if (whichone==0)
    {
    config. Above		= true;
    config. Left		= false;
    config. OffsetX	= 12;
    config. OffsetY	= 27;
    }
  else
    {
    config. Above		= true;
    config. Left		= true;
    config. OffsetX = 170;
    config. OffsetY = 0;
    }

  Tip(txt, 500000,0, 330,0, CLOSEBTN, true);
  }