var nCrackrate = 1000;		// Anzahl möglicher 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";			// überprüfen ob Ziffern vormmen
	if (contains(strPass, strToCheck)) nCombinationCount += strToCheck.length;
	strToCheck = "abcdefghijklmnopqrstuvwxyz";	// überprüfen ob kleine Buchstaben vorkommen
	if (contains(strPass, strToCheck)) nCombinationCount += strToCheck.length;
	strToCheck = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";	// überprüfen ob grosse Buchstaben vorkommen
	if (contains(strPass, strToCheck)) nCombinationCount += strToCheck.length;
	strToCheck = ",;:-_=+\|//?^&!.@$£#*()%~<>{}[]";// übersprüfen 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);				// Stärke errechnen
	if (nStrongness < (strPass.length * 5)) nStrongness += strPass.length * 5;		// Zeichenlänge für Stärke berücksichtigen
	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(strTextId);

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

