function g( id ) {
    return document.getElementById( id );
}
function toggle( id ) {
    var z = g( id );
    if ( z.style.display == '' ) {
        return z.style.display = 'none';
    }
    return z.style.display = '';
}

var Login = {
    oldvalue: ""
    ,completionvalue: ""
    ,completiontimer: null
    ,precomplete: function () {
        clearTimeout(Login.completiontimer);
    }
    ,progress: function () {
        g('theform').style.display = 'none';
        g('loading').style.display = '';
        Animations.Pulse(g('logo'));
        Animations.Shrink(g('box'));
    }
    ,gocomplete: function () {
        textfield = g("login");
        nowvalue = textfield.value;
        if (Login.oldvalue.length != nowvalue.length - 1) {
            Login.oldvalue = textfield.value;
            // alert('not typing');
            return;
        }
        for (i in suggestions) {
            if (suggestions[i].substring(0, nowvalue.length).toLowerCase() == nowvalue.toLowerCase() && suggestions[i].length != nowvalue.length) {
                Login.oldvalue = nowvalue;
                // Salert(Login.oldvalue);
                Login.completionvalue = nowvalue + suggestions[i].substring(nowvalue.length);
                Login.completiontimer = setTimeout("Login.docompletion()", 300);
                return;
            }
        }
        Login.oldvalue = textfield.value;
    }
    ,docompletion: function() {
        textfield = g("login");
        nowvalue = textfield.value;
        textfield.value = Login.completionvalue;
        textfield.selectionStart = nowvalue.length;
        textfield.selectionEnd = Login.completionvalue.length;
    }
};
