var nCrackrate = 1000; // Anzahl moeglicher Versuche das Passwort zu Knacken pro Sekunde
var nTreshholddays = 365 * 10; // Schwellwert, ab wann das Passwort als Sicher gilt
var nSteps = 10; // Anzahl der Schritte, die im CSS angehangen werden

function contains(strText, strPattern){
 for(i = 0; i < strText.length; i++){
  if(strPattern.indexOf(strText.charAt(i)) > -1) return true;
 }
 return false;
}

function checkPass(strPass, strId, strClassname, strTextId, aTexts){
 nCombinationCount = 0;

 strToCheck = "0123456789"; // ueberpruefen ob Ziffern vormmen
 if (contains(strPass, strToCheck)) nCombinationCount += strToCheck.length;
 strToCheck = "abcdefghijklmnopqrstuvwxyz"; // ueberpruefen ob kleine Buchstaben vorkommen
 if (contains(strPass, strToCheck)) nCombinationCount += strToCheck.length;
 strToCheck = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; // ueberpruefen ob grosse Buchstaben vorkommen
 if (contains(strPass, strToCheck)) nCombinationCount += strToCheck.length;
 strToCheck = ",;:-_=+|//?^&!.@$£#*()%~<>{}[]";// ueberspruefen ob Sonderzeichen vorkommen
 if (contains(strPass, strToCheck)) nCombinationCount += strToCheck.length;

 var nDays = ((Math.pow(nCombinationCount, strPass.length) / nCrackrate) / 2) / 86400; // Wieviele Tage bentigt man?
 var nStrongness = Math.round(nDays / nTreshholddays * 100); // Staerke errechnen
 if (nStrongness < (strPass.length * 5)) nStrongness += strPass.length * 5; // Zeichenlaenge fuer Staerke beruecksichtigen
 if (nStrongness > 100) nStrongness = 100; // Max 100% zulassen
 nStrongness = Math.round(nStrongness / (100 / nSteps)); // Max Schritte

 oId = document.getElementById(strId);
 oId.className = strClassname + "-" + nStrongness;

 otId = document.getElementById(strId);

 if(aTexts){
  nKey = Math.round((aTexts.length - 1) / nSteps * nStrongness);
  otId.innerHTML = aTexts[nKey];
 }
}
