function pwdStrength(password, minLength)
{
    var strengthWords = ["too short", "ok, but not great", "pretty good", "nice one!"];
    var strengthColours = ["#dd2929", "#cc553d", "#c4cc3d", "#3fcc3d"];
    var strength = 0;

    if(password.length >= minLength) {
        strength++;

        var matchHasNonAlpha = /.*[^a-zA-Z].*/;
        if(password.match(matchHasNonAlpha) != null) {
            strength++;
        }
	    
        var matchHasUpper = /.*[A-Z].*/;
        var matchHasLower = /.*[a-z].*/;
        if((password.match(matchHasUpper) != null) && (password.match(matchHasLower) != null)){
            strength++;
        }
        
        if((password.length >= 8) && (strength < 2)) {
            strength++;
        }
    }

    strength = Math.min(strength, 3);

    var strengthElem = lmGetElementById("pw-strength");
    if(strengthElem != null) {
        strengthElem.style.background = strengthColours[strength];
        strengthElem.firstChild.nodeValue = strengthWords[strength];
    }

    //var strengthTextElem = lmGetElementById("pw-strength-text");
    //if(strengthTextElem != null) {
    //    strengthTextElem.firstChild.nodeValue = "Password Strength:";
    //}
}

function lmGetElementById(id)
{
    try{
        return document.getElementById(id);
    } catch(e) {};
}

