/* ************************************************************
Password Strength Factors and Weightings

password length:
level 0 (0 points):  less than 7 characters
level 1 (3 points):  between 7 and 10 characters

letters:
level 0 (0 points): no letters
level 1 (5 points): all letters are lower case
level 2 (7 points): letters are mixed case

numbers:
level 0 (0 points): no numbers exist
level 1 (5 points): one number exists

combinatons:
level 0 (1 points): letters and numbers exist
level 1 (1 points): mixed case letters
level 1 (2 points): letters, numbers 
level 1 (2 points): mixed case letters and numbers exist


************************************************************ */
function testPassword(passwd)
{
var description = new Array();
description[0] = "<table><tr><td><table cellpadding=0 cellspacing=2><tr><td height=4 width=30 bgcolor=#ff0000></td><td height=4 width=120 bgcolor=tan></td></tr></table></td><td> &nbsp;&nbsp;<b>Weakest</b></td></tr></table>";
description[1] = "<table><tr><td><table cellpadding=0 cellspacing=2><tr><td height=4 width=60 bgcolor=#990000></td><td height=4 width=90 bgcolor=tan></td></tr></table></td><td> &nbsp;&nbsp;<b>Weak</b></td></tr></table>";
description[2] = "<table><tr><td><table cellpadding=0 cellspacing=2><tr><td height=4 width=90 bgcolor=#990099></td><td height=4 width=60 bgcolor=tan></td></tr></table></td><td> &nbsp;&nbsp;<b>Improving</b></td></tr></table>";
description[3] = "<table><tr><td><table cellpadding=0 cellspacing=2><tr><td height=4 width=120 bgcolor=#000099></td><td height=4 width=30 bgcolor=tan></td></tr></table></td><td> &nbsp;&nbsp;<b>Strong</b></td></tr></table>";
description[4] = "<table><tr><td><table><tr><td height=4 width=150 bgcolor=#0000ff></td></tr></table></td><td> &nbsp;&nbsp;<b>Strongest</b></td></tr></table>";
description[5] = "<table><tr><td><table><tr><td height=4 width=150 bgcolor=tan></td></tr></table></td><td> &nbsp;&nbsp;<b>Begin Typing</b></td></tr></table>";

		var intScore   = 0
		var strVerdict = 0
		
		// PASSWORD LENGTH
		if (passwd.length==0 || !passwd.length)      // length 0
		{
			intScore = -1
		}
		else if (passwd.length>0 && passwd.length<7) // length between 1 and 6
		{
			intScore = -1
		}
		else if (passwd.length>6 && passwd.length<11) // length between 7 and 10
		{
			intScore = (intScore+3)
		}
		
		
		// LETTERS
		if (passwd.match(/[a-z]/))                              // [verified] at least one lower case letter
		{
			intScore = (intScore+5)
		}
		
		if (passwd.match(/[A-Z]/))                              // [verified] at least one upper case letter
		{
			intScore = (intScore+5)
		}
		
		// NUMBERS
		if (passwd.match(/\d+/))                                 // [verified] at least one number
		{
			intScore = (intScore+5)
		}
		
		// COMBOS
		if (passwd.match(/[a-z]/) && passwd.match(/[A-Z]/)) // [verified] both upper and lower case
		{
			intScore = (intScore+2)
		} 
		
		if (passwd.match(/\d/) && passwd.match(/\D/)) // [verified] both letters and numbers
		{
			intScore = (intScore+2)
		} 
		
		// [Verified] Upper Letters, Lower Letters, numbers
		if (passwd.match(/[a-z]/) && passwd.match(/[A-Z]/) && passwd.match(/\d/))
		{
			intScore = (intScore+2)
		}	
	
		if(intScore == -1)
		{
		   strVerdict = description[5];
		}
		else if(intScore > -1 && intScore < 6)
		{
		   strVerdict = description[0];
		}
		else if (intScore > 5 && intScore < 11)
		{
		   strVerdict = description[1];
		}
		else if (intScore > 10 && intScore < 18)
		{
		   strVerdict = description[2];
		}
		else if (intScore > 17 && intScore < 23)
		{
		   strVerdict = description[3];
		}
		else if (intScore > 23)
		{
		   strVerdict = description[4];
		}
	
	document.getElementById("Words").innerHTML= (strVerdict);
	
}
