  function GoBackTo(l)
  {
    var o, f, v;
	
	v = document.getElementById("validated");
	if(v) v.value = 0;

    o = document.getElementById("destination");
    o.value = l;
	
    f = document.getElementById("form");
    f.submit();
  }

  function GoForwardTo(l)
  {
    var o, f, v;

	v = document.getElementById("validated");
	if(v) v.value = 1;

    if(window.ValidateForm)
      if(!ValidateForm(document.getElementById("form")))
        return;

    o = document.getElementById("destination");
    o.value = l;
	
    f = document.getElementById("form");
    f.submit();
  }

  function CheckIfEmpty(o)
  {
    if(o.value.replace(/^\s*|\s*$/g,"") == "")
    {
      o.style.backgroundColor = "#ffa0a0";
      return(false);
    }
    return(true);
  }

  function CheckState(o)
  {
    var str = o.value.replace(/^\s*|\s*$/g,"");
	
    switch(str.toUpperCase())
    {
      case 'AL': case 'AK': case 'AZ': case 'AR': case 'CA': case 'CO': case 'CT': case 'DE': case 'DC':
      case 'FL': case 'GA': case 'HI': case 'ID': case 'IL': case 'IN': case 'IA': case 'KS': case 'KY':
      case 'LA': case 'ME': case 'MD': case 'MA': case 'MI': case 'MN': case 'MS': case 'MO': case 'MT':
      case 'NE': case 'NV': case 'NH': case 'NJ': case 'NM': case 'NY': case 'NC': case 'ND': case 'OH':
      case 'OK': case 'OR': case 'PA': case 'RI': case 'SC': case 'SD': case 'TN': case 'TX': case 'UT':
      case 'VT': case 'VA': case 'WA': case 'WV': case 'WI': case 'WY':
 
      case 'ALABAMA': case 'ALASKA': case 'ARIZONA': case 'ARKANSAS': case 'CALIFORNIA': case 'COLORADO': case 'CONNECTICUT': case 'DELAWARE': case 'DISTRICT OF COLUMBIA':
      case 'FLORIDA': case 'GEORGIA': case 'HAWAII': case 'IDAHO': case 'ILLINOIS': case 'INDIANA': case 'IOWA': case 'KANSAS': case 'KENTUCKY':
      case 'LOUISIANA': case 'MAINE': case 'MARYLAND': case 'MASSACHUSETTS': case 'MICHIGAN': case 'MINNESOTA': case 'MISSISSIPPI': case 'MISSOURI': case 'MONTANA':
      case 'NEBRASKA': case 'NEVADA': case 'NEW HAMPSHIRE': case 'NEW JERSEY': case 'NEW MEXICO': case 'NEW YORK': case 'NORTH CAROLINA': case 'NORTH DAKOTA': case 'OHIO':
      case 'OKLAHOMA': case 'OREGON': case 'PENNSYLVANIA': case 'RHODE ISLAND': case 'SOUTH CAROLINA': case 'SOUTH DAKOTA': case 'TENNESSEE': case 'TEXAS': case 'UTAH':
      case 'VERMONT': case 'VIRGINIA': case 'WASHINGTON': case 'WEST VIRGINIA': case 'WISCONSIN': case 'WYOMING':

        return(true);
    }
    o.style.backgroundColor = "#ffa0a0";
    return(false);
  }

  function ResetBox(o)
  {
    o.style.backgroundColor = "#ffffff";
  }

function NumbersOnly(myfield, e)
{
  var key;
  var keychar;

  if(window.event) key = window.event.keyCode;
  else if (e) key = e.which;
  else return(true);

  keychar = String.fromCharCode(key);

  if((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27))
    return(true);

  if((("0123456789.-()/ ").indexOf(keychar) > -1))
   return(true);

  return(false);
}

function NumbersOnlyStrict(myfield, e)
{
  var key;
  var keychar;

  if(window.event) key = window.event.keyCode;
  else if (e) key = e.which;
  else return(true);

  keychar = String.fromCharCode(key);

  if((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27))
    return(true);

  if((("0123456789").indexOf(keychar) > -1))
   return(true);

  return(false);
}

function CheckEmail(o)
{
 var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
 if(filter.test(o.value))
   return(true);

 o.style.backgroundColor = "#ffa0a0";
 return(false);
}

function CheckCreditCard(o)
{  // v2.0
  var ccNumb = o.value;
  var valid = "0123456789"  // Valid digits in a credit card number
  var iCCN;  // integer of ccNumb
  var sCCN = ccNumb.toString();  // string of ccNumb
  var iTotal = 0;  // integer total set at zero
  var temp;  // temp variable for parsing string
  var calc;  // used for calculation of each digit
  var tCCN;

  sCCN = sCCN.replace(/^\s+|\s+$/g,'');  // strip spaces

  tCCN = "";
  // Determine if the ccNumb is in fact all numbers
  for (var j=0; j < sCCN.length; j++)
  {
    temp = "" + sCCN.substring(j, j+1);
    if(valid.indexOf(temp) != "-1")
      tCCN = tCCN + temp;
  }
  sCCN = tCCN;
  iCCN = parseInt(sCCN);

  // Determine if it is the proper length 
  if(sCCN.length < 15 || sCCN.length > 16) // 15 or 16 for Amex or V/MC
  {
    o.style.backgroundColor = "#ffa0a0";
    return(false);
  }
  
  // ccNumb is a number and the proper length - let's see if it is a valid card number
  for(var i=sCCN.length;i>0;i--){  // LOOP throught the digits of the card
    calc = parseInt(iCCN) % 10;  // right most digit
    calc = parseInt(calc);  // assure it is an integer
    iTotal += calc;  // running total of the card number as we loop - Do Nothing to first digit
    i--;  // decrement the count - move to the next digit in the card
    iCCN = iCCN / 10;                               // subtracts right most digit from ccNumb
    calc = parseInt(iCCN) % 10 ;    // NEXT right most digit
    calc = calc *2;                                 // multiply the digit by two
    // Instead of some screwy method of converting 16 to a string and then parsing 1 and 6 and then adding them to make 7,
    // I use a simple switch statement to change the value of calc2 to 7 if 16 is the multiple.
    switch(calc){
      case 10: calc = 1; break;       //5*2=10 & 1+0 = 1
      case 12: calc = 3; break;       //6*2=12 & 1+2 = 3
      case 14: calc = 5; break;       //7*2=14 & 1+4 = 5
      case 16: calc = 7; break;       //8*2=16 & 1+6 = 7
      case 18: calc = 9; break;       //9*2=18 & 1+8 = 9
      default: calc = calc;           //4*2= 8 &   8 = 8  -same for all lower numbers
    }                                               
    iCCN = iCCN / 10;  // subtracts right most digit from ccNum
    iTotal += calc;  // running total of the card number as we loop
  }  // END OF LOOP
  if ((iTotal%10)==0)  // check to see if the sum Mod 10 is zero
    return(true)  // This IS (or could be) a valid credit card number.

  o.style.backgroundColor = "#ffa0a0";
  return(false);  // This could NOT be a valid credit card number
}
