function nif(dni){

                dni = dni.toUpperCase();

                numero = dni.substr(0,dni.length-1);
                numero = numero.replace('X','0');
                //alert(numero);

                let = dni.substr(dni.length-1,1);
                numero = numero % 23;
                letra='TRWAGMYFPDXBNJZSQVHLCKET';
                letra=letra.substring(numero,numero+1);

                if (letra!=let){
                               //alert('Dni erroneo');
                               return false;
                }

                //alert("Dni OK");
                return true;

}

function cmail(email){ 
 var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ 
 return email.match(re) 
}

function abre_ventanuko(urle,ancho,alto,barras,nomventana)
{
	var nombre
	if (nomventana==undefined) {nombre='ventanuko'}
	else {nombre=nomventana}
	window.open(urle,nombre,"toolbar=no,resizable=no,location=no,directories=no,status=no,menubar=no,scrollbars="+barras+",top=0,left=0,innerWidth="+ancho+",width="+ancho+",height="+alto);
}

function colocaBoton(ruta,link)
{

    var newImg = new Image();
    newImg.src = "img/"+ruta+".png";
    var altura = newImg.height;
    var anchura = newImg.width;
 
    document.write('<a href="'+link+'"><img width="'+anchura+'" height="'+altura+'" src="img/'+ruta+'.png" onmouseout="document.getElementById(\''+ruta+'\').src = \'img/'+ruta+'.png\';" onmouseover="document.getElementById(\''+ruta+'\').src = \'img/'+ruta+'_R.png\';" id="'+ruta+'" /></a>');
}

function colocaBotonJPG(ruta,link)
{
    document.write('<a href="'+link+'"><img src="img/'+ruta+'.jpg" onmouseout="document.getElementById(\''+ruta+'\').src = \'img/'+ruta+'.jpg\';" onmouseover="document.getElementById(\''+ruta+'\').src = \'img/'+ruta+'_R.jpg\';" id="'+ruta+'" /></a>');
}

function colocaBotonBlank(ruta,link)
{
    document.write('<a target="_blank" href="'+link+'"><img src="img/'+ruta+'.png" onmouseout="document.getElementById(\''+ruta+'\').src = \'img/'+ruta+'.png\';" onmouseover="document.getElementById(\''+ruta+'\').src = \'img/'+ruta+'_R.png\';" id="'+ruta+'" /></a>');
}

function changeInputType(oldObject, oType) {
    var newObject = document.createElement('input');
    newObject.type = oType;
    if(oldObject.size) newObject.size = oldObject.size;
    if(oldObject.value) newObject.value = oldObject.value;
    if(oldObject.name) newObject.name = oldObject.name;
    if(oldObject.id) newObject.id = oldObject.id;
    if(oldObject.className) newObject.className = oldObject.className;
    oldObject.parentNode.replaceChild(newObject,oldObject);
    return newObject;
}

function getHTTPObject() {
    var xmlhttp;
    /*@cc_on
    @if (@_jscript_version >= 5)
       try {
          xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
       } catch (e) {
          try {
             xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
          } catch (E) { xmlhttp = false; }
       }
    @else
    xmlhttp = false;
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
       try {
          xmlhttp = new XMLHttpRequest();
       } catch (e) { xmlhttp = false; }
    }
    return xmlhttp;
}

function rellenarDias(ultimodia){
                                            
    var diaSeleccionado = (document.forms.formRegistro.dia.selectedIndex);
    if (diaSeleccionado == -1) diaSeleccionado = 0;

    document.forms.formRegistro.dia.options.length = 0;

    for(i=1;i<=ultimodia;i++){
    
        var elOptNew = document.createElement('option');
        elOptNew.text = i;
        elOptNew.value = i;                                                
    
        try {
        document.forms.formRegistro.dia.add(elOptNew, null); // standards compliant; doesn't work in IE
        }
        catch(ex) {
        document.forms.formRegistro.dia.add(elOptNew); // IE only
        }                                                                                                
    
    }
    
    if (diaSeleccionado>document.forms.formRegistro.dia.options.length) diaSeleccionado = 0;
    else document.forms.formRegistro.dia.selectedIndex = diaSeleccionado;
  
}

function rellenarMes(){

    for(i=1;i<=12;i++){
    
        var elOptNew = document.createElement('option');
        elOptNew.text = i;
        elOptNew.value = i;                                                
    
        try {
        document.forms.formRegistro.mes.add(elOptNew, null); // standards compliant; doesn't work in IE
        }
        catch(ex) {
        document.forms.formRegistro.mes.add(elOptNew); // IE only
        }                                                                                                
    
    }                                            

}

function rellenarAnyos(){

    for(i=1900;i<=2010;i++){
    
        var elOptNew = document.createElement('option');
        elOptNew.text = i;
        elOptNew.value = i;
        if(i==1970) elOptNew.selected = true;                                                
    
        try {
        document.forms.formRegistro.anyo.add(elOptNew, null); // standards compliant; doesn't work in IE
        }
        catch(ex) {
        document.forms.formRegistro.anyo.add(elOptNew); // IE only
        }                                                                                                
    
    }                                            

}

function daysInMonth(month,year) {
    var dd = new Date(year, month, 0);
    return dd.getDate();
}                 

function cambiaDias(){
    rellenarDias(daysInMonth(document.forms.formRegistro.mes.selectedIndex+1,document.forms.formRegistro.anyo.selectedIndex+1900));
}  

var numb = "0123456789";
var alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
var alphanumb = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
function res(t,v){
    var w = "";
    for (i=0; i < t.value.length; i++) {
    x = t.value.charAt(i);
    if (v.indexOf(x,0) != -1)
    w += x;
    }
    t.value = w;
}
