// Password strength meter v1.0
// Matthew R. Miller - 2007
// www.codeandcoffee.com
// Based off of code from  http://www.intelligent-web.co.uk

// Settings
// -- Toggle to true or false, if you want to change what is checked in the password
var bCheckNumbers = true;
var bCheckUpperCase = true;
var bCheckLowerCase = true;
var bCheckPunctuation = true;
var nPasswordLifetime = 365;
 

function passwordStrength(password)

{

        var desc = new Array();

        desc[0] = "Weak";
        desc[1] = "Okay";
        desc[2] = "Medium";
        desc[3] = "Strong";
        desc[4] = "Strongest";



        var score   = 0;

        //if password bigger than 6 give 1 point
        if (password.length > 6) score++;



        //if password has both lower and uppercase characters give 1 point 
        if ( ( password.match(/[a-z]/) ) && ( password.match(/[A-Z]/) ) ) score++;



        //if password has at least one number give 1 point
        if (password.match(/\d+/)) score++;



        //if password has at least one special caracther give 1 point
        if ( password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/) ) score++;



        //if password bigger than 12 give another 1 point
        if (password.length > 12) score++;



         document.getElementById("passwordDescription").innerHTML = desc[score];
         document.getElementById("passwordStrength").className = "strength" + score;

}