﻿//========Password Generator ===========//

function getRandomNum(lbound, ubound) {
    return (Math.floor(Math.random() * (ubound - lbound)) + lbound);
}

function getRandomChar() {
    var numberChars = "0123456789";
    var lowerChars = "abcdefghijklmnopqrstuvwxyz";
    var upperChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    var otherChars = "`~!@#$%^&*()-_=+[{]}\\|;:'\",<.>/? ";
    var charSet = 0;

    charSet += numberChars;
    charSet += lowerChars;
    charSet += upperChars;

    return charSet.charAt(getRandomNum(0, charSet.length));
}

function getPassword(length) {
    var rc = "";
    if (length > 0) rc = rc + getRandomChar();
    for (var idx = 1; idx < length; ++idx) {
        rc = rc + getRandomChar();
    }
    document.getElementById("mypassword_text").innerHTML = "<p style='font-size:13px'>" + rc + "</p>";
    return rc;
}
