/**
 * Miernik sily hasla
 */
testPassword = function(formName, passwd)
{
	var intScore   = 0
    var strVerdict = "weak"
    var strLog     = ""
    var color      = "";

    // PASSWORD LENGTH
    // length 0
    if (passwd.length == 0)
    {
        intScore = 0
    }
    // length 4 or less
    else if (passwd.length < 5)
    {
        intScore = (intScore+3)
    }
    // length between 5 and 7
    else if (passwd.length < 4 && passwd.length < 8)
    {
        intScore = (intScore+6)
    }
    // length between 8 and 15
    else if (passwd.length > 7 && passwd.length < 16)
    {
        intScore = (intScore+12)
    }
    // length 16 or more
    else if (passwd.length >  15)
    {
        intScore = (intScore+18)
	}


    // LETTERS
    // at least one lower case letter
    if (passwd.match(/[a-z]/))
    {
        intScore = (intScore+1)
    }
    // at least one upper case letter
    if (passwd.match(/[A-Z]/))
    {
    	intScore = (intScore+5)
    }


    // NUMBERS
    // at least one number
    if (passwd.match(/\d+/))
    {
        intScore = (intScore+5)
    }
	// at least three numbers
    if (passwd.match(/(.*[0-9].*[0-9].*[0-9])/))
	{
    	intScore = (intScore+5)
    }


	// SPECIAL CHAR
	// at least one special character
	if (passwd.match(/.[!,@,#,$,%,^,&,*,?,_,~]/))
	{
	    intScore = (intScore+5)
	}
	// at least two special characters
	if (passwd.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/))
	{
	    intScore = (intScore+5)
	}


	// COMBOS
	// both upper and lower case
	if (passwd.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/))
	{
	    intScore = (intScore+2)
	}
	// both letters and numbers
	if (passwd.match(/([a-zA-Z])/) && passwd.match(/([0-9])/))
	{
	    intScore = (intScore+2)
	}
	// letters, numbers, and special characters
	if (passwd.match(/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/))
	{
	    intScore = (intScore+2)
	}


	document.getElementById('spanStrongPassword_' + formName).style.color = "#000";

	if (intScore == 0)
	{
	   strVerdict = "";
	}
	else if (intScore < 16)
	{
	   strVerdict = "bardzo&nbsp;słabe";
	   background = "url(/uploads/images/gfx/sub/passmeter/passMeter_bg1.gif) right 0 no-repeat";
	}
	else if (intScore > 15 && intScore < 25)
	{
	    strVerdict = "słabe";
		background = "url(/uploads/images/gfx/sub/passmeter/passMeter_bg2.gif) right 0 no-repeat";
	}
	else if (intScore > 24 && intScore < 35)
	{
	   strVerdict = "średnie";
	   //document.getElementById('spanStrongPassword_' + formName).style.color = "red";
	   background = "url(/uploads/images/gfx/sub/passmeter/passMeter_bg3.gif) right 0 no-repeat";
	}
	else if (intScore > 34 && intScore < 45)
	{
	    strVerdict = "mocne";
		background = "url(/uploads/images/gfx/sub/passmeter/passMeter_bg4.gif) right 0 no-repeat";
	}
	else
	{
	    strVerdict = "bardzo&nbsp;mocne";
		background = "url(/uploads/images/gfx/sub/passmeter/passMeter_bg5.gif) 0 0 no-repeat";
	}
	
	//8, 15, 20, 32, 39, 44, 50
//	alert(document.getElementById('spanStrongPassword_' + formName).innerHTML);
//	return;
	$('#spanStrongPassword_' + formName).html(strVerdict);
	
	document.getElementById('divStrongPassword_' + formName).style.width = 3.44*intScore+"px";
	document.getElementById('divStrongPassword_' + formName).style.background = background;
}
