<!--
function checks()
{
  var code="si;"
  var field = new Array;
  field[0] = "Stazione di partenza";
  field[1] = "Stazione di arrivo";
  field[2] = "Giorno";
  field[3] = "Mese";
  field[4] = "Anno";
  field[5] = "Ora";
  field[6] = "Minuti";
  var fino = document.forms[0].length;

  for (x=0;x<7;x++)
  {
    if (x<2)
    {
      if(document.forms[0].elements[x].type=="select-one")
      {
        var campo = document.forms[0].elements[x].selectedIndex;
      }
      else
      {
        var campo = document.forms[0].elements[x].value;
      }
      if (campo.length<2)
      {
        alert(field[x] +  ": digita almeno due caratteri.");
        code="no";
        break;
      }
    }
    else
    {
      var campo = "ok";
    }


    if ((document.forms[0].elements[x].value=="") || (campo.length<2))
    {
      if ((document.forms[0].elements[0].value=="" && document.forms[0].elements[1].value=="") || (document.forms[0].elements[0].length<2 && document.forms[0].elements[1].length<2))
      {
        alert("Stazione di partenza: digita almeno due caratteri.\nStazione di arrivo: digita almeno due caratteri.");
        code ="no"
        break;
      }
      else
      {
        alert(field[x] +  ": digita almeno due caratteri.")
        document.forms[0].elements[x].focus();
        code = "no"
        break;
      }
    }
    else
    {
      var sel1 = 0;
      var sel2 = 0;
      var val1;
      var val2;

      if(document.forms[0].elements[0].type=="select-one")
      {
        // Primo campo select
        sel1=1;
        val1 = document.forms[0].elements[0].selectedIndex;
      }

      if(document.forms[0].elements[1].type=="select-one")
      {
        // Secondo campo select
        sel2=1;
        val2 = document.forms[0].elements[1].selectedIndex;
      }

      if (sel1 == 1 && sel2 == 1)
      {
        if (document.forms[0].elements[0].options[val1].value==document.forms[0].elements[1].options[val2].value)
        {
          alert("Stazione di arrivo e di partenza coincidenti.");
          code ="no";
          break;
        }
      }

      if (sel1 == 0 && sel2 == 1)
      {
        if (document.forms[0].elements[0].value==document.forms[0].elements[1].options[val2].value)
        {
          alert("Stazione di arrivo e di partenza coincidenti.");
          code ="no";
          break;
        }
      }

      if (sel1 == 1 && sel2 == 0)
      {
        if (document.forms[0].elements[0].options[val1].value==document.forms[0].elements[1].value)
        {
          alert("Stazione di arrivo e di partenza coincidenti.");
          code ="no";
          break;
        }
      }

      if (sel1 == 0 && sel2 == 0)
      {
        if (document.forms[0].elements[0].value==document.forms[0].elements[1].value)
        {
          alert("Stazione di arrivo e di partenza coincidenti.");
          code ="no";
          break;
        }
      }
    }
  }
  if(code!="no")
  {
    if(!checkData())
    {
    }
    else
    {
      document.forms[0].submit();
    }
  }
}

function checkData ()
{
  var err = new Array;
  err[1] = "Stazione di partenza non indicata o di un solo carattere";
  err[2] = "Stazione di arrivo non indicata o di un solo carattere";
  err[3] = "Stazione di partenza e di arrivo coincidenti";
  err[4] = "Data non valida";
  err[5] = "Ora non valida";
  err[6] = "Mese non valido";
  err[7] = "Anno non valido";

  if(document.query.stazin.type=="select-one")
  {
    stazin  = document.forms[0].stazin.options[document.query.stazin.selectedIndex].value;
  }
  else
  {
    stazin  = document.query.stazin.value;
  }

  if(document.query.stazout.type=="select-one")
  {
    stazout  = document.forms[0].stazout.options[document.query.stazout.selectedIndex].value;
  }
  else
  {
    stazout  = document.query.stazout.value;
  }

  datag   = document.query.datag.value;
  datam  = document.query.datam.value;
  dataa   = document.query.dataa.value;

  timsh   = document.query.timsh.value;
  timsm   = document.query.timsm.value;
  msg = ""

  if (datag.length != 0 && datam.length != 0 && dataa.length != 0)
  {
    datag = parseInt(datag, 10);
    datam = parseInt(datam, 10);
    dataa = parseInt(dataa, 10);

    if (isNaN(datag) || isNaN(datam) || isNaN(dataa))
    {
      msg = err[4] +"1"
      alert(msg);
      return false;
    }
    if (datam < 1 || datam > 12)
    {
      msg = err[6]
      alert(msg);
      return false;
    }
    lm = new Array;
    lm[1] = 31; lm[2] = 28; lm[3] = 31; lm[4] = 30; lm[5] = 31; lm[6] = 30;
    lm[7] = 31; lm[8] = 31; lm[9] = 30; lm[10] = 31; lm[11] = 30; lm[12] = 31;
    if (0 == dataa % 4) { lm[2] = 29 }
    if (datag < 1 || datag > lm[datam])
    {
      msg = err[4] +"2"
      alert(msg);
      return false;
    }
  }
  var th = 0;
  nstaz = 18;
  return true;
}

function ora()
{
  date = new Date();
  giorno = date.getDate();
  mese =  date.getMonth() + 1;
  anno =  date.getFullYear();
  oras =  date.getHours();
  nav = navigator.appName;

  if(nav=="Netscape")
  {
    anno = anno + 1900;
  }

  //giorno = 23;

  //mese =  12;

  //anno =  2003;

  //oras =  13;

  document.query.timsh.value = oras;
  document.query.timsm.value = "00";

  document.query.datag.value = giorno;
  document.query.datam.value = mese;
  document.query.dataa.value = anno;

  //x = 0;
  //for (x=0;x<31;x++)
  //{
  //  if (document.query.elements[2].options[x].value==giorno)
  //  {
  //    document.query.elements[2].options[x].selected = true;
  //  }
  //}

  //x = 0;
  //for (x=0;x<12;x++)
  //{
  //  if (document.query.elements[3].options[x].value==mese)
  //  {
  //    document.query.elements[3].options[x].selected = true;
  //  }
  //}

  //x = 0;
  //for (x=0;x<1;x++)
  //{
  //  if (document.query.elements[4].options[x].value==anno)
  //  {
  //    document.query.elements[4].options[x].selected = true;
  //  }
  //}
}

var Help1 = null;
function showhelp1 () {
if(Help1 && !Help1.closed)
{
Help1.close();
Help1 = null;
}
Help1 = window.open("/it/statiche/pop_guida_2.htm","","width=400,height=400,resizable=1,scrollbars=1");
Help1.focus();
}

function keyprocess(e) {
	if (isNS)
	{
  if (e.keyCode==13)  {checks();}
	}

	 else
	{

  if (event.keyCode==13)  {checks();}
	}
}
var isNS = (navigator.appName == "Netscape");

function init() {

	if (isNS) { document.captureEvents(Event.MOUSEMOVE); }
	if (isNS) { document.captureEvents(Event.KEYDOWN); }


	document.onkeydown = keyprocess;

}
-->