// JavaScript Document

function obtenerDigito(valor){
  valores = new Array(1, 2, 4, 8, 5, 10, 9, 7, 3, 6);
  control = 0;
  for (i=0; i<=9; i++)
    control += parseInt(valor.charAt(i)) * valores[i];
  control = 11 - (control % 11);
  if (control == 11) control = 0;
  else if (control == 10) control = 1;
  return control;
}



function numerico(valor){
  cad = valor.toString();
  for (var i=0; i<cad.length; i++) {
    var caracter = cad.charAt(i);
	if (caracter<"0" || caracter>"9")
	  return false;
  }
  return true;
}



function validar(f) {
  if (f.cb1.value == ""  || f.cb2.value == "" ||
      f.cb3.value == "" || f.cb4.value == "")
    //alert("Por favor, introduzca los datos de su cb4");
	  return false;
  else {
    if (f.cb1.value.length != 4 || f.cb2.value.length != 4 ||
        f.cb3.value.length != 2 || f.cb4.value.length != 10)
     // alert("Por favor, introduzca correctamente los datos de su cb4;"
	 //   + " no están completos");
	  return false;
    else {
      if (!numerico(f.cb1.value) || !numerico(f.cb2.value) ||
          !numerico(f.cb3.value) || !numerico(f.cb4.value))
      //  alert("Por favor, introduzca correctamente los datos de su "
      //   + "cb4; no son numericos");
	 	  return false;
      else {
        if (!(obtenerDigito("00" + f.cb1.value + f.cb2.value) ==
              parseInt(f.cb3.value.charAt(0))) || 
            !(obtenerDigito(f.cb4.value) ==
              parseInt(f.cb3.value.charAt(1))))
     //     alert("Los dígitos de control no se corresponden con los demás"
      //      + " números de la numero");
		  return false;
	    else
       //   alert ("CCC correcto");
	   return true;
	   	  
      }
    }
  }

}



//form.submit();