function limpiar(form) {
    form.terminal.selectedIndex  = 0;
    form.tipo.selectedIndex      = 0;
    form.estado.selectedIndex    = 0;
    form.criterio1.selectedIndex = 0;
    form.criterio2.selectedIndex = 0;
    form.dataTipo.selectedIndex  = 0;
    form.ordenar.selectedIndex   = 0;
    form.valor1.value            = "";
    form.valor2.value            = "";
    form.dataInici.value         = "";
    form.dataFinal.value         = "";
}

function validarMatricula(matricula) {
    if (matricula == null)    return true;
    if (matricula.length==0)  return true;
    if (matricula.length!=11) return false;

    var matric1 = matricula.substring(0,matricula.length-1).toUpperCase();
    var control = matricula.substring(matricula.length-1);
    var tipo= ["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];
    var valor= [0,1,2,3,4,5,6,7,8,9,10,12,13,14,15,16,17,18,19,20,21,23,24,25,26,27,28,29,30,31,32,34,35,36,37,38];
    var total=0;

    var cod = [matric1.charAt(0),matric1.charAt(1),matric1.charAt(2),matric1.charAt(3),matric1.charAt(4),matric1.charAt(5),matric1.charAt(6),matric1.charAt(7),matric1.charAt(8),matric1.charAt(9)]; 

    if (cod[3]!="U") return false;

    var iniciMatricula = matric1.substring(0,4);
    if(iniciMatricula == "HLCU") {
        cod[1] = "C";
        cod[2] = "L";
    }
         
    for(i=0;i<10;i++) {
        for(j=0;j<36;j++) {
            if(cod[i]== tipo[j]) {
                // SUMATORIO (valorDigito * 2 elevado a valorDigito)
                var spow = 1;
                for (k=i;k>0;k--) spow = 2*spow;
                total = total + (valor[j]*spow);
            }
        }
    }

    total = total%11;
    if (total==10) total=0;
    if (total==control) 
        return true;
    else 
        return false;
}

function validarCorreo(dirCorreo) {
    if (dirCorreo == null)           return false;
    if (dirCorreo.length<5)          return false;
    if (dirCorreo.indexOf("@") <= 0) return false;
    if (dirCorreo.indexOf(".") <= 0) return false;
    return true;
}
