﻿// Archivo JScript
	function NifCorrecto(sNif)
	{
		var NumNif
		var LetraNif
	
		//Extraemos la letra del Nif por un lado y los numeros del Nif por otro
		var Cadena
		Cadena=sNif
	
		LetraNif=""
		NumNif=""
	
		for (var x=0; x<Cadena.length;x++)
		{
			c= Cadena.substring(x,x+1)
			if (c<"0"||c>"9") 
			{
				LetraNif=LetraNif + c
			}
			else
			{
				NumNif=NumNif + c
			}
		} 
		ASC= NumNif % 23;
		
		if ( ASC == 0) 
		{ 
			sLetra="T"; 
			sLetraB="t";
		}
		if ( ASC == 1) 
		{ 
			sLetra="R"; 
			sLetraB="r";
		}
		if ( ASC == 2) 
		{
			sLetra="W"; 
			sLetraB="w";
		}
		if ( ASC == 3) 
		{
			sLetra="A"; 
			sLetraB="a";
		}
		if ( ASC == 4) 
		{ 
			sLetra="G"; 
			sLetraB="g";
		}
		if ( ASC == 5) 
		{ 
			sLetra="M"; 
			sLetraB="m";
		}
		if ( ASC == 6) 
		{
			sLetra="Y"; 
			sLetraB="y";
		}
		if ( ASC == 7) 
		{ 
			sLetra="F"; 
			sLetraB="f";
		}
		if ( ASC == 8) 
		{
			sLetra="P"; 
			sLetraB="p";
		}
		if ( ASC == 9) 
		{ 
			sLetra="D"; 
			sLetraB="d";
		}
		if ( ASC == 10) 
		{ 
			sLetra="X"; 
			sLetraB="x";
		}
		if ( ASC == 11)
		{
			sLetra="B"; 
			sLetraB="b";
		}
		if ( ASC == 12) 
		{
			sLetra="N"; 
			sLetraB="n";
		}
		if ( ASC == 13) 
		{
			sLetra="J"; 
			sLetraB="j";
		}
		if ( ASC == 14) 
		{
			sLetra="Z"; 
			sLetraB="z";
		}
		if ( ASC == 15) 
		{
			sLetra="S"; 
			sLetraB="s";
		}
		if ( ASC == 16) 
		{
			sLetra="Q"; 
			sLetraB="q";
		}
		if ( ASC == 17) 
		{
			sLetra="V"; 
			sLetraB="v";
		}
		if ( ASC == 18)
		{
			sLetra="H"; 
			sLetraB="h";
		}
		if ( ASC == 19) 
		{
			sLetra="L"; 
			sLetraB="l";
		}
		if ( ASC == 20) 
		{
			sLetra="C"; 
			sLetraB="c";
		}
		if ( ASC == 21) 
		{
			sLetra="K"; 
			sLetraB="k";
		}
		if ( ASC == 22) 
		{
			sLetra="E"; 
			sLetraB="e";
		}
		if ( ASC == 23)
		{
			sLetra="T"; 
			sLetraB="t";
		}
	
		//Validacion de Letra
		if (sLetra==LetraNif)
		{
			return (true);
		}
		else
		{
			if (sLetraB==LetraNif)
			{
				return (true);
			}	
			else
			{
				return (false);
			}
		}
	}


