  function check_pw(uid,firstname,surname,formname,inputfield,outputfield)
  {
    var securityindex = 10;
    var char_old;
    var char_new;
    var charEqual = true;
    var i;
    var pwd = document.forms[formname].elements[inputfield].value;

    // Länge prüfen, min. 8 Zeichen, max. 20 Zeichen
    if(pwd.length < 8 || pwd.length > 20) {
        securityindex = securityindex - 20;
    }
    // Kennwort auf unerlaubte Zeichen prüfen
    if(pwd.match(/[^a-zA-Z0-9\*\+-\/%~&\|@\\#\$€\<\>\(\)\{\}\[\]´`\^_\.,;:!\?]/g)) {
        securityindex = securityindex - 20;
    }
    // auf gleiche aufeinanderfolgende Zeichen prüfen
    char_new = pwd.charAt(pwd.length - 1);
    for(i=0 ; i<pwd.length - 1; i++) {
        char_old = pwd.charAt(i);
        if(char_new == char_old && charEqual == true) {
            charEqual = true;
        }
        else
        {
            charEqual = false;
        }
    }
    if(charEqual == true) {
        securityindex = securityindex - 20;
    }
    // Kennwort auf Anzahl der Sonderzeichen prüfen
    var Ergebnis;
    Ergebnis = pwd.match(/[\+-/%~&|@\\#\*\$€\<\>\(\)\{\}\[\]´`\^_\.,;:!\?]/g);
    if(Ergebnis && Ergebnis.length < 2) {
       securityindex = securityindex - 5;
    }
    else if (Ergebnis == null) {
       securityindex = securityindex - 5;
    }

    if(securityindex <= 0 ) {
       document.forms[formname].elements[outputfield].style.backgroundColor = "#D61919";
    }
    else if (securityindex <= 9)
    {
       document.forms[formname].elements[outputfield].style.backgroundColor = "#F18218";
    }
    else
    {
       document.forms[formname].elements[outputfield].style.backgroundColor = "#3BB312";
    }
  }
  
function colorBoxStr(elemId, passwordStr){
	passwordStr = parseInt(passwordStr);
	if (passwordStr == 0){
		document.getElementById(elemId).style.backgroundColor = '#D61919';
		document.getElementById("submitBtn").style.visibility = "hidden";
	}
	if (passwordStr > 0 && passwordStr <= 3){
		document.getElementById(elemId).style.backgroundColor = '#F18218';
		document.getElementById("submitBtn").style.visibility = "visible";
	}
	if (passwordStr > 3){
		document.getElementById(elemId).style.backgroundColor = '#3BB312';
		document.getElementById("submitBtn").style.visibility = "visible";
	}
}
function checkStrength(elem, password, name){
	var elemId = elem.id;
	var strength = 0;
    var valid = true;
    
	//pw enthält ungültige Sonderzeichen, enthält den Nachnamen, enthält gleiche aufeinanderfolgende Zeichen (aa), ist zu kurz oder zu lang ...
	if( password.match(/[^a-zA-Z0-9\*\+-\/%~&\|@\\#\$€\<\>\(\)\{\}\[\]´`\^_\.,;:!\?]/g) != null || 
        password.indexOf(name) >= 0  ||
        password.match(/(.)\1{2,}/) != null ||
        password.length <= 7 || 
        password.length >= 20 ) {
        // ... ist das Passwort ungültig
        valid = false;
    }
    
    // pwd ist gültig, also ermitteln wir die Stärke 
    if( valid ) {
    
        // enthält das pwd Zahlen?
        if( password.match(/[0-9]+/) != null ) {
            strength++;
        }
        
        // enthält das pwd Kleinbuchstaben?
        if( password.match(/[a-z]+/) != null ) {
            strength++;
        }
        
        // enthält das pwd Großbuchstaben?
        if( password.match(/[A-Z]+/) != null) {
            strength++;
        }
        
        // enthält das pwd Sonderzeichen?
        var sonderzeichen = password.match(/[\*\+-\/%~&\|@\\#\$€\<\>\(\)\{\}\[\]´`\^_\.,;:!\?]+/g);
        if( sonderzeichen != null) {
            //strength++;
			
            // sogar mehr als nur 1 Sonderzeichen? das gibt Ex-trapunkte..
            if( sonderzeichen[0].length > 1 ) {
                strength= strength + 3;
            }
        }		
    }
	colorBoxStr(elemId, strength);	
}
