function showPasswordStrengthMeter()
{
    var insertPt=document.getElementById('password_strength_row');
    insertPt.style.visibility="visible";
    insertPt.style.display="table-row";
    
    var insertPt2=document.getElementById('password_match_row');
    insertPt2.style.visibility="visible";
    insertPt2.style.display="table-row";
}

function hidePasswordStrengthMeter()
{
    var insertPt=document.getElementById('password_strength_row');
    insertPt.style.visibility="hidden";
    insertPt.style.display="none";

    var insertPt2=document.getElementById('password_match_row');
    insertPt2.style.visibility="hidden";
    insertPt2.style.display="none";
}

/* This function is derived from mozilla.org source code  
 * http://lxr.mozilla.org/seamonkey/source/security/manager/pki/resources/content/password.js
 */

function getPasswordStrength()
{
// Here is how we weigh the quality of the password
// number of characters
// numbers
// non-alpha-numeric chars
// upper and lower case characters
  var pw=document.getElementById('password').value;
//  alert("password='" + pw +"'");

//length of the password
  var pwlength=(pw.length);
  if (pwlength>5)
    pwlength=5;


//use of numbers in the password
  var numnumeric = pw.replace (/[0-9]/g, "");
  var numeric=(pw.length - numnumeric.length);
  if (numeric>3)
    numeric=3;

//use of symbols in the password
  var symbols = pw.replace (/\W/g, "");
  var numsymbols=(pw.length - symbols.length);
  if (numsymbols>3)
    numsymbols=3;

//use of uppercase in the password
  var numupper = pw.replace (/[A-Z]/g, "");
  var upper=(pw.length - numupper.length);
  if (upper>3)
    upper=3;


  var pwstrength=((pwlength*10)-20) + (numeric*10) + (numsymbols*15) + (upper*10);

  // make sure we're give a value between 0 and 100
  if ( pwstrength < 0 ) {
    pwstrength = 0;
  }
  
  if ( pwstrength > 100 ) {
    pwstrength = 100;
  }

  if (pwstrength > 95) {
    pwRating = Locale.getString('verySecurePassword');
    ratingColor = "#008000";
  } else if (pwstrength > 75) {
    pwRating = Locale.getString('securePassword');
    ratingColor = "#6699cc";
  } else if (pwstrength > 50) {
    pwRating = Locale.getString('mediocrePassword');
    ratingColor = "#f5ac00";
  } else {
    pwRating = Locale.getString('insecurePassword');
    ratingColor = "#aa0033";
  }

  document.getElementById('password_strength_meter').innerHTML = pwRating;
  document.getElementById('password_strength_meter').style.color = ratingColor;
  document.getElementById('password_strength_meter').style.fontWeight = "bold";
}

function checkPasswordMatch()
{
  var pw=document.getElementById('password').value;
  var pw2=document.getElementById('password2').value;

  if (pw == pw2) {
    ratingColor = "#008000";
    pwRating = Locale.getString('PasswordsMatch');
  } else {
    ratingColor = "#aa0033";
    pwRating = Locale.getString('PasswordsDoNotMatch');
  }
  document.getElementById('password_match_status').innerHTML = pwRating;
  document.getElementById('password_match_status').style.color = ratingColor;
}
