<!--

var upperLetter = 1;
var lowerLetter = 2;
var digit = 3;
var punctuation = 4;

var minLength = 7;

function AlertWeekPassword(pwd, msg)
{
    if( CheckPasswordLength(pwd, minLength) && CheckPasswordCharacter(pwd, "3", true) )
    {
       return;
    }
    else if( CheckPasswordLength(pwd, minLength) && CheckPasswordCharacter(pwd, "2", true) )
    {
       return;
    }
    else if( CheckPasswordLength(pwd, 1, false) )
    {
       alert(msg);
    }
}	

function CheckPassword(pwd, weak, medium, strong)
{
    var weakStyle = weak.style;
    var mediumStyle = medium.style;
    var strongStyle = strong.style;

	weakStyle.color = "#adadad";
	weakStyle.background = "#FFFFFF";
	mediumStyle.color = "#adadad";
	mediumStyle.background = "#FFFFFF";
	strongStyle.color = "#adadad";
	strongStyle.background = "#FFFFFF";

    if( CheckPasswordLength(pwd, minLength) && CheckPasswordCharacter(pwd, "3", true) )
    {
		strongStyle.color = "#000";
		strongStyle.background = "#0c6";
    }
    else if( CheckPasswordLength(pwd, minLength) && CheckPasswordCharacter(pwd, "2", true) )
    {
		mediumStyle.color = "#000";
		mediumStyle.background = "#ff9";
    }
    else if( CheckPasswordLength(pwd, 1, false) )
    {
		weakStyle.color = "#000";
		weakStyle.background = "#f00";
    }
}

function CheckPasswordLength(pwd, length)
{
	if ((pwd == null) || isNaN(length))
	{
		return false;
	}
	else if (pwd.length < length)
	{
		return false;
	}
	return true;
}

function CheckPasswordCharacter(pwd, count, additional)
{
	var characterTypes = new Array(5);
	characterTypes[upperLetter] = false;
	characterTypes[lowerLetter] = false;
	characterTypes[digit] = false;
	characterTypes[punctuation] = false;

	var typeCount = 0;

	if ((pwd == null) || isNaN(count))
	{
		return false;
	}

	for(var index = 0; index < pwd.length; index++)
	{
		var type = GetPasswordCharacterType(pwd.charAt(index))
		characterTypes[type] = true;
	}

	for(var index = 1; index < characterTypes.length; index++)
	{
		if (characterTypes[index])
		{
			typeCount++;
		}
	}

	if (typeCount < count)
	{
		return false;
	}

	if (additional)
	{
		if(characterTypes[digit] && (characterTypes[upperLetter] || characterTypes[lowerLetter]))
		{
			return true;
		}
		else
		{
			return false;
		}
		 
	}

	return true;
}

function GetPasswordCharacterType(ch)
{
	if((ch >= 'A') && (ch <= 'Z'))
	{
		return upperLetter;
	}

	if((ch >= 'a') && (ch <= 'z'))
	{
		return lowerLetter;
	}
	if((ch >= '0') && (ch <= '9'))
	{
		return digit;
	}

	if ("!@#$%^&*()_+-='\";:[{]}\|.>,</?`~".indexOf(ch) >= 0)
	{
		return punctuation;
	}

	return 0;

}

//-->
