function finestra(url, ancho, alto, barra) {
	izquierda = (screen.width) ? (screen.width-ancho)/2 : 100
	arriba = (screen.height) ? (screen.height-alto)/2 : 100
	opciones = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=' + barra + ',resizable=0,width=' + ancho + ',height=' + alto + ',left=' + izquierda + ',top=' + arriba + ''
	window.open(url, 'popUp', opciones)
}

function nifIncorrecte()
{
	
	var validChars = "trwagmyfpdxbnjzsqvhlcke";
	var aux=document.frm.nif.value;
	var lastCharlocation=aux.length-1;
	var lastChar=aux.charAt(lastCharlocation).toLowerCase();
	var numero=aux.substring(0,lastCharlocation);
	if(validChars.indexOf(lastChar)==-1) return true;
	if(invalidNumber(numero)) return true;
    if(!match(numero,lastChar,validChars)) return true;
}


function invalidNumber(numero)
{
	var validNumbers="0123456789";
	var numeroInvalido=false;
	for (var i=0; i < numero.length; i++) 
	    {
			var current = numero.charAt(i);
			if(validNumbers.indexOf(current)!=-1) continue;
			numeroInvalido=true;
			break;
		}
     return numeroInvalido;
}


function match(numero,letra,tabla)
{
	var validNumber=parseFloat(numero);
	if(letra==tabla.charAt(validNumber%23)) return true;
	else return false;
}
