// description = Password Generator
// copypizded from http://javascript.internet.com/passwords/password-generator.html

var AkelPad=new ActiveXObject("AkelPad.document");
//AkelPad.ReplaceSel('Test');

function getRandomNum(lbound, ubound) {
return (Math.floor(Math.random() * (ubound - lbound)) + lbound);
}

function getRandomChar(number, lower, upper, other, extra) {
var numberChars = "0123456789";
var lowerChars = "abcdefghijklmnopqrstuvwxyz";
var upperChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var otherChars = "`~!@#$%^&*()-_=+[{]}\\|;:'\",<.>/? ";
var charSet = extra;
if (number == true)
charSet += numberChars;
if (lower == true)
charSet += lowerChars;
if (upper == true)
charSet += upperChars;
if (other == true)
charSet += otherChars;
return charSet.charAt(getRandomNum(0, charSet.length));
}

function getPassword(length, extraChars, firstNumber, firstLower, firstUpper, firstOther,
latterNumber, latterLower, latterUpper, latterOther) {
   var rc = "";
   if (length > 0)
   rc = rc + getRandomChar(firstNumber, firstLower, firstUpper, firstOther, extraChars);
   for (var idx = 1; idx < length; ++idx) {
   rc = rc + getRandomChar(latterNumber, latterLower, latterUpper, latterOther, extraChars);
   }
   return rc;
}

function getRandomInt(min, max)
{
  return Math.floor(Math.random() * (max - min + 1)) + min;
}

var pLength = getRandomInt(12,19);
var extraChars = '';

var firstNumber = true;
var firstLower = true;
var firstUpper = true;
var firstOther = false;

var latterNumber = true;
var latterLower = true;
var latterUpper = true;
var latterOther = false;

AkelPad.ReplaceSel(getPassword(pLength, extraChars, firstNumber, firstLower,
firstUpper, firstOther, latterNumber, latterLower,
latterUpper, latterOther));
