var bCheckNumbers = true;var bCheckUpperCase = true;var bCheckLowerCase = true;var bCheckPunctuation = true;var nPasswordLifetime = 365;function checkPassword(strPassword){nCombinations = 0;if (bCheckUpperCase){strCheck = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";if (doesContain(strPassword, strCheck) > 0) { nCombinations += strCheck.length; }}if (bCheckLowerCase){strCheck = "0123456789abcdefghijklmnopqrstuvwxyz";if (doesContain(strPassword, strCheck) > 0) { nCombinations += strCheck.length; }}if (bCheckPunctuation){strCheck = ";:-_=+\|//?^&!.@$£#*()%~<>{}[]";if (doesContain(strPassword, strCheck) > 0) { nCombinations += strCheck.length; }}var nDays = ((Math.pow(nCombinations, strPassword.length) / 500) / 2) / 86400;var nPerc = nDays / nPasswordLifetime;return nPerc;}function runPassword(strPassword, strFieldID) {nPerc = checkPassword(strPassword);var ctlBar1 = document.getElementById(strFieldID + "_bar1");var ctlBar2 = document.getElementById(strFieldID + "_bar2");var ctlBar3 = document.getElementById(strFieldID + "_bar3");var ctlText = document.getElementById(strFieldID + "_text");if (!ctlBar1 || !ctlBar2 || !ctlBar3 || !ctlText)return;var nRound = Math.round(nPerc * 100);if (nRound < (strPassword.length * 5)) { nRound += strPassword.length * 5; }if (nRound >= 95){strText = "عالی";strColor = "#3bce08";ctlBar3.style.backgroundColor = strColor;ctlBar2.style.backgroundColor = strColor;ctlText.innerHTML = "<span style='color: " + strColor + ";'>" + strText + "</span>";}else if (50 <= nRound < 95){strText = "متوسط";strColor = "#3bce08";ctlBar2.style.backgroundColor = strColor;ctlText.innerHTML = "<span style='color: " + strColor + ";'>" + strText + "</span>";ctlBar3.style.backgroundColor = '';}if(nRound < 50 ){strColor = "#3bce08";strText = "ضعیف";ctlBar1.style.backgroundColor = strColor;ctlText.innerHTML = "<span style='color: " + strColor + ";'>" + strText + "</span>";ctlBar2.style.backgroundColor = '';	}if(strPassword == ''){ctlBar1.style.backgroundColor = '';ctlText.innerHTML='';}}function doesContain(strPassword, strCheck){nCount = 0; for (i = 0; i < strPassword.length; i++) {if (strCheck.indexOf(strPassword.charAt(i)) > -1) { nCount++; }} return nCount; }