





var puntuacion = 0;


// Checks a string for a list of characters
function doesContain(strPassword, strCheck)
 {
    	nCount = 0; 
 
	for (i = 0; i < strPassword.length; i++) 
	{
		if (strCheck.indexOf(strPassword.charAt(i)) > -1) 
		{ 
	        	nCount++; 
		} 
	} 
 
	return nCount; 
} 




// Check password
function checkPassword(strPassword,caracteres)
{

puntuacion=0;
	
		var password_numeros = document.getElementById("password_numeros"); 
		var password_letras = document.getElementById("password_letras"); 
		var password_minimo = document.getElementById("password_minimo"); 
		var password_longitud = document.getElementById("password_longitud"); 
		
	
		password_longitud.innerHTML=strPassword.length;
	

		// Chequeo si tiene numeros
		strCheck = "0123456789";
		if (doesContain(strPassword, strCheck) > 0) 
		{ 
        	puntuacion=puntuacion+1;
			password_numeros.style.fontWeight="normal"
    	}
		else
		{
			password_numeros.style.fontWeight="bold"
		}

		// Chequeo si tiene letras
		strCheck = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
		if (doesContain(strPassword, strCheck) > 0) 
		{ 
        	puntuacion=puntuacion+1;
			password_letras.style.fontWeight="normal"
    	}
		else
		{
			password_letras.style.fontWeight="bold"
		}
	

	    if (strPassword.length>=caracteres)
		{
			puntuacion=puntuacion+1;
			password_minimo.style.fontWeight="normal"
		}
		else
		{
			password_minimo.style.fontWeight="bold"
		}

	
	return puntuacion;
}
 
// Runs password through check and then updates GUI 
function runPassword(strPassword, strFieldID,caracteres) 
{
	// Check password
	puntuacion = checkPassword(strPassword,caracteres);
	
	 // Get controls
    	var ctlBar = document.getElementById(strFieldID + "_bar"); 
    	var ctlText = document.getElementById(strFieldID + "_text");
    	if (!ctlBar || !ctlText)
    	return;
    	
    	// Set new width
		var longitud=strPassword.length*10;
		if (longitud>100)
		{
		longitud=100;
		}
		ctlBar.style.width = longitud + "%";
		
 
 	// Color and text
 	if (puntuacion > 2)
 	{
 		strText = "Seguro";
 		strColor = "#C3EFB3";
 	}
 	else
 	{
 		strColor = "#EF959D";
 		strText = "Inseguro";
 	}
	ctlBar.style.backgroundColor = strColor;
	ctlText.innerHTML = "<span style='color: #000000;'>&nbsp;" + strText + "</span>";
}
 
 
 
 // Runs password through check and then updates GUI 
function compararPasswords(nombre1,dato1,nombre2,dato2) 
{

	var ctlBar = document.getElementById(nombre2+ "_bar"); 
	var longitud=dato2.length*10;
	
	if (String(dato1).substring(0,dato2.length)==dato2)
	{
		if (dato2.length==dato1.length)
			{
				strColor = "#C3EFB3";
			}
		else
			{
				strColor = "#bbbbbb";
			}
	
	}
	 else
	{
		strColor = "#EF959D";
	}
	
	
	ctlBar.style.backgroundColor = strColor;
	
	if (longitud>100)
	{
		longitud=100;
	}
	ctlBar.style.width = longitud + "%";

}

 
 
 
 
 



