function pwdGen() {
  pwdlength = parseInt(document.getElementById('pwdform').pwdlength.value,10);
  var pwd = "";

  for(i=1; i<=pwdlength; i++) {
    k=0;
    while(k == 0) {
      r = Math.round(Math.random()*93);
      r+=33;

      if(r >= 48 && r<=57 && document.getElementById('pwdform').digits.checked == true) {
        k=1;
        pwd += String.fromCharCode(r);
      }
      if(r >= 97 && r<=122 && document.getElementById('pwdform').small.checked == true) {
        k=1;
        pwd += String.fromCharCode(r);
      }
      if(r >= 65 && r<=90 && document.getElementById('pwdform').big.checked == true) {
        k=1;
        pwd += String.fromCharCode(r);
      }
      if( ( (r >= 33 && r<=47) || (r >= 58 && r<=64) || (r >= 91 && r<=96) || (r >= 123 && r<=126) ) && document.getElementById('pwdform').special.checked == true) {
        k=1;
        pwd += String.fromCharCode(r);
      }
    }
    document.getElementById('pwdform').pwd.value = pwd;
  }
  return false;
}

function pwdLength(n) {
act = document.getElementById('pwdform').pwdlength.value;
  if((parseInt(act,10) + parseInt(n,10)) > 0) {
    document.getElementById('pwdform').pwdlength.value = parseInt(act,10) + parseInt(n,10);
  }
}
