 function updatePasswordStrength(page)
    {
        var strength = 0;
        if(page==1)
        {
            var password = document.SignIn.SUserPsw.value;
            var email_words = document.SignIn.UserEmail.value;
            var user_name = document.SignIn.TheUserName.value;
        }
        else if(page==2)    
        {
            var password = document.ChangePsw.UserNewPsw.value;
            var email_words = "";
            var user_name = ""
        }    
        // easy_guesses: strings that should not be used in password
        var easy_guesses = new Array();
              easy_guesses.push('password'); 
              easy_guesses.push('blogTV');
        email_words.match(/\w+/g); // contiguous words contained in email
        if (email_words)
            easy_guesses = easy_guesses.concat(email_words);
        
        easy_guesses.push(user_name);
        
       locase_matches = password.match(/[a-z_]/g); // lowercase and '_' matches
       digit_matches = password.match(/[0-9]/g);   // numeric matches
       upcase_matches = password.match(/[A-Z]/g);  // uppercase matches
       special_matches = password.match(/\W/g);    // special matches (not in a-z, A-Z, 0-9, _)
       
       if (password.length > 6)
       { 
            // for less than 6, leave strength at 0 since password too short
            // 1 point for each character more than 5
            strength += password.length - 5;
            // 1 point for each upcase character mixed with lowercase
            if (locase_matches && upcase_matches)
                strength += upcase_matches.length;
            // 1 point for each numeric character mixed with lowercase
            if (locase_matches && digit_matches)
                strength += digit_matches.length;
            // 1 point for each special characters
            if (special_matches)
                strength += special_matches.length;
            // 2 bonus points if mix of letters, numbers and special
            if ((locase_matches || upcase_matches) && special_matches && digit_matches)
                strength += 2;
        }
        // Reset strength to 0 if any easy guess in password (easy guess should be more than 3 chars)
        
        for (var i=0; i < easy_guesses.length; ++i)
        {
            if (easy_guesses[i].length>3 && (password.indexOf(easy_guesses[i])!=-1))
            { 
                strength=0;
                break;
            }
        }
        
        var pstrength_elem = document.getElementById('password_strength');
        var pstrength_text = document.getElementById('password_strength_text');
        
        if (password.length==0)
        {
            pstrength_elem.className = 'password_empty';             
            pstrength_text.innerHTML = 'None';
        }
        else if (strength<3)
        {
            pstrength_elem.className = 'password_weak';
            pstrength_text.innerHTML = 'Weak';
        }
        else if (strength<7)
        {
            pstrength_elem.className = 'password_fair';
            pstrength_text.innerHTML = 'Fair';
        }
        else if (strength<10)
        {
            pstrength_elem.className = 'password_good';
            pstrength_text.innerHTML = 'Good';
        }
        else
        {
            pstrength_elem.className = 'password_strong';
            pstrength_text.innerHTML = 'Strong';
        }
    }
