b64arrays();

var pwRequest = {

    info  : {
        txt : [
            "ohje",
            "na ja",
            "schon besser",
            "nicht schlecht",
            "krass"
        ],
        col : [
            "#f00",
            "#c30",
            "#963",
            "#693",
            "#3c0"
        ]
    },
    
    getInput : function(f)
    {
        $('info').innerHTML = "Passwort: "+f.password.value;
        var pw = b64d2t(utf8t2d(f.password.value));
        new Ajax.Request(
            "pw_check.php?pass="+pw,
            {   
                onSuccess:function(r)
                {
                    pwRequest.showScore(parseFloat(r.responseText));
                }
            }
        );
    },
    
    showScore : function(r)
    {
        var idx = 0;
        if (r <  3) { idx = 0; }
        if (r >= 3) { idx = 1; }
        if (r >= 5) { idx = 2; }
        if (r >= 6) { idx = 3; }
        if (r >= 7) { idx = 4; }
        var out = "Bewertung: "+this.info.txt[idx]+" -- Score: "+r;
        $('pass').innerHTML = out;
        $('pass').style.color = this.info.col[idx];
        if (idx == 4) Effect.Shake('pass');
    },
    
    pwTipp : function()
    {
        new Ajax.Request(
            "pw_tipp.php",
            {   
                onSuccess:function(r)
                {
                    $('tipp').style.display = "none";
                    $('tipp').innerHTML = "PW-Tipp: "+r.responseText;
                    Effect.Appear('tipp');
                }
            }
        );
    },
    
    showInput : function()
    {
        with ($('info').style)
        {
            display = (display=="none") ? "block" : "none";
        }
    }
};
