// Passwort-Staerke pruefen
function checkPasswordStrength(value) {
	var strength = '';
	
	var hasLetters = value.match(/[a-zA-Z]+/);
	var hasNumbers = value.match(/[0-9]+/);
	var hasPunctuation = value.match(/[^a-zA-Z0-9]+/);
	var hasCasing = value.match(/[a-z]+.*[A-Z]+|[A-Z]+.*[a-z]+/);
	var div = document.getElementById('pw1');
	
	if (!value.length) {
		strength = '<a href="?site=pwgen" target="_blank">Passwort-Generator</a>';
	} else if (value.length < 6) {
		strength = '<font color="red">unsicher</font>';
	} else if ( hasLetters && hasNumbers && hasPunctuation && hasCasing && value.length > 8 ) {
		strength = '<font color="green">sicher</font>';
	}  else {
		var count = (hasLetters ? 1 : 0) + (hasNumbers ? 1 : 0) + (hasPunctuation ? 1 : 0) + (hasCasing ? 1 : 0);
		strength = count > 1 ? '<font color="orange">mittelm&auml;&szlig;ig</font>' : '<font color="red">unsicher</font>';
	}
	
	div.innerHTML = strength;
}

// Gleichheit beider Passwoerter ueberpruefen
function confirmBothPasswords(value1,value2) {
    var div = document.getElementById('pw2');
    match = "";

    if (value1 == "" || value2 == "") {
        match = "";
    }
    else {
        if (value1 != value2) {
            match = '<font color="red">Passw&ouml;rter stimmen nicht &uuml;berein!</font>';
        }
        else {
            match = '<font color="green">Passw&ouml;rter stimmen &uuml;berein!</font>';
        }
    }
	
	div.innerHTML = match;
}

