function FormValueCheck(id, mode) { type = document.getElementById(id).getAttribute('type'); if (type == 'checkbox' && !document.getElementById(id).checked) { valToUse = ''; } else { valToUse = document.getElementById(id).value } value = sha1Hash(valToUse); mode1_value = 'VAL' + id + '_1_' + value; mode2_value = 'VAL' + id + '_2_' + value; mode2_pre = 'VAL' + id + '_2_'; check_group = 'VAL' + id; items = getElementsByLinkValue(document, 'div', check_group); for(i=0; i=6) { while (i < len) { chr = document.getElementById('password').value.charAt(i) if (chr.match(reglowercase)) { pts = pts + 2; lowercase = true; letters = true; } else if (chr.match(regnumbers)) { pts = pts + 1; numbers = true; } else if (chr.match(reguppercase)) { pts = pts + 2; uppercase = true; letters = true; } else { pts = pts + 4; non = true; } i++; } //Bonuses if (uppercase && lowercase) { pts = pts + 2; } else { suggestion = 'case'; } if (letters && numbers) { pts = pts + 3; if (non) { pts = pts + 5; } else { suggestion = 'AlphaNonNumeric'; } } else { suggestion = 'letters_numbers'; } //Penalities pn = true; if (document.getElementById('password').value.match(regNumAtEnd)) { pts = pts - 3; suggestion = 'NumAtEnds'; pn = false; } else if (document.getElementById('password').value.match(regNumAtBegin)) { pts = pts - 3; suggestion = 'NumAtEnds'; pn = false; } else if (document.getElementById('password').value.match(regCapFirst)) { pts = pts - 2; suggestion = 'CapFirst'; pn = false; } else if (document.getElementById('password').value.toLowerCase().match(regUsername) && document.getElementById('username').value.length >= 6) { pts = pts - 10; suggestion = 'UsernameInP'; pn = false; } else if (document.getElementById('password').value.toLowerCase().match(regFirstname) && document.getElementById('first_name').value.length >= 3) { pts = pts - 10; suggestion = 'NameInP'; pn = false; } else if (document.getElementById('password').value.toLowerCase().match(regLastname) && document.getElementById('last_name').value.length >= 3) { pts = pts - 10; suggestion = 'NameInP'; pn = false; } } else { pts = 0; suggestion = 'characters'; } //Tally if (pts >= 25 && pn) { set_strength('Excellent', '#24973A', 'none', pts); } else if (pts >= 20) { set_strength('Strong', '#A3EDB8', suggestion, pts); } else if (pts >= 15) { set_strength('Fair', '#DEF031', suggestion, pts); } else if (pts >= 10) { set_strength('Weak', '#FF0000', suggestion, pts); } else { set_strength('Too Short', '#000000', suggestion, 6); } } function set_strength(strength, color, tip, pts) { var bar_length = pts / 25 * 100; if (bar_length > 100) { bar_length = 100; } document.getElementById('password_strength_bar').style.width = bar_length + '%'; document.getElementById('password_strength_bar').style.background = color; document.getElementById('password_strength_status').innerHTML = ''+strength+'
Password Suggestions:

'+hints[tip]; } /* var store; var box; var boxValue; var data; var sn; var SearchBox; var SearchBoxFrame; var BoxSelected; var ResultList; var AutoPopSelection; var AutoPopSelect; var AutoPopTotal; var FirstResult; var LastKey; var Change; function CheckUpdate() { if (boxValue != box.value) { if (!SearchBox) { SearchBox = document.createElement('div'); SearchBox.className = 'AutoPopResults'; SearchBox.style.width = box.clientWidth + 'px'; box.parentNode.insertBefore(SearchBox, box.nextSibling); } if (!SearchBoxFrame) { SearchBoxFrame = document.createElement('iframe'); SearchBoxFrame.style.display = 'none'; document.body.appendChild(SearchBoxFrame); } SearchBox.style.display = 'block'; store.value = ''; Change = true; SearchBoxFrame.src = '/_jsclasses/AutoPopData.php?data='+data+'&search='+box.value+'&sn='+sn; } else { Change = false; } AutoPopSelection = 0; AutoPopSelect = false; boxValue = box.value; CheckTO = setTimeout('CheckUpdate()',500); box.onblur = function() { setTimeout('KillCheck()',100) }; SearchBox.onfocus = function () { BoxSelected = true; } SearchBox.onblur = function () { BoxSelected = false; } box.onkeydown = OnPress; } function StartCheck(newBox, newData, newSn) { store = document.getElementById(newBox.id.substring(8)); box = newBox; data = newData; sn = newSn; CheckUpdate(); } function KillCheck(e) { if (!BoxSelected) { clearTimeout(CheckTO); CheckTO = false; SearchBox.innerHTML = ''; SearchBox.style.display = 'none'; } } function OnPress(e) { var code; if (!e) var e = window.event; if (e.keyCode) code = e.keyCode; else if (e.which) code = e.which; var character = code; LastKey = code; if (character == 13) { KillCheck(); return false; } else if (character == 40) { move = 1; } else if (character == 38) { move = -1; } else if (character == 9) { move = 0; clearTimeout(CheckTO); CheckTO = false; KillCheck(); box.focus(); } else { move = 0; if (!CheckTO) { CheckUpdate(); } } if (move != 0) { AutoPopMoving = setTimeout('AutoPopMove('+move+')', 0); clearTimeout(CheckTO); CheckTO = false; } } function AutoPopMove(move) { if (AutoPopTotal > AutoPopSelection + move && AutoPopSelection + move >= 0) { if (AutoPopSelect) { ResultList[AutoPopSelection].className = 'AutoPopUnselected'; AutoPopSelection += move; } else { AutoPopSelect = true; } ResultList[AutoPopSelection].className = 'AutoPopSelected'; box.value = ResultList[AutoPopSelection].innerHTML; store.value = ResultList[AutoPopSelection].id.substring(6); } else if (AutoPopTotal == 1) { AutoPopSelection = 0; ResultList[0].className = 'AutoPopSelected'; box.value = ResultList[0].innerHTML; store.value = ResultList[0].id.substring(6); } } function HighlightSelection(iStart, iLength) { iStart = box.value.length; if (iStart > 0) { iLength = FirstResult.length; box.value = FirstResult; boxValue = FirstResult; if (box.createTextRange) { var oRange = box.createTextRange(); oRange.moveStart("character", iStart); oRange.moveEnd("character", iLength - box.value.length); oRange.select(); } else if (box.setSelectionRange) { box.setSelectionRange(iStart, iLength); } box.focus(); } }; */ function GeneratePassword(obj) { chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; pass = ""; for(x=0;x<6;x++) { i = Math.floor(Math.random() * 62); pass += chars.charAt(i); } document.getElementById(obj).type = 'text'; document.getElementById(obj).value = pass; } function sha1Hash(msg) { // constants [4.2.1] var K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6]; // PREPROCESSING msg += String.fromCharCode(0x80); // add trailing '1' bit to string [5.1.1] // convert string msg into 512-bit/16-integer blocks arrays of ints [5.2.1] var l = Math.ceil(msg.length/4) + 2; // long enough to contain msg plus 2-word length var N = Math.ceil(l/16); // in N 16-int blocks var M = new Array(N); for (var i=0; i>> 30) * 8; M[N-1][15] = ((msg.length-1)*8) & 0xffffffff; // set initial hash value [5.3.1] var H0 = 0x67452301; var H1 = 0xefcdab89; var H2 = 0x98badcfe; var H3 = 0x10325476; var H4 = 0xc3d2e1f0; // HASH COMPUTATION [6.1.2] var W = new Array(80); var a, b, c, d, e; for (var i=0; i>>(32-n)); } // // extend Number class with a tailored hex-string method // (note toString(16) is implementation-dependant, and // in IE returns signed numbers when used on full words) // Number.prototype.toHexStr = function() { var s="", v; for (var i=7; i>=0; i--) { v = (this>>>(i*4)) & 0xf; s += v.toString(16); } return s; } var TempValue; function ClearLabel(field, label) { TempValue = label; if (field.value == label) { field.value = ''; } field.onblur = CheckLabel; } function CheckLabel(e) { field = GetTarget(e); if (field.value.length < 1 || field.value == 'undefined' || field.value == '') { field.value = TempValue; } TempValue = ''; } function CheckRequired(formId) { if (!formId) { formId = 'form'; } var error = false; requiredFields = getElementsByClassName(document.getElementById(formId), 'div', 'required'); for(i=0; i