﻿var login_usr, login_pwd, redir_url, register_url, login_btn, login_ajax_wait;
var login_fail_img, login_ok_img;
var loginFailed_url;
var hypFlagID;
function doLogin(evt) {
    evt.preventDefault();
    evt.stopPropagation();
    //
    Sys.UI.DomElement.setVisible(login_btn, false);
    Sys.UI.DomElement.setVisible(login_ajax_wait, true);
    //
    if (redir_url == '') redir_url = null;
    Sys.Services.AuthenticationService.login(login_usr.value, login_pwd.value, false, ''/* custom info */, redir_url/* redirectUrl*/, onLoginCompleted, onLoginError);
}
function onLoginCompleted(authenticated) {
    Sys.UI.DomElement.setVisible(login_ok_img, authenticated);
    Sys.UI.DomElement.setVisible(login_fail_img, !authenticated);
    //
    Sys.UI.DomElement.setVisible(login_ajax_wait, false);
    Sys.UI.DomElement.setVisible(login_btn, true);
    //
    setTimeout(function() {
        if (!authenticated)
            location.href = register_url;
        else {
            location.reload(false);
        }
    }, 750);
}
function onLoginError(error) {
}
var flagTimeoutID;
function flag_rollOver(sender, args) {
    clearTimeout(flagTimeoutID);
    Sys.UI.DomElement.setVisible($get(hypFlagID), true);
    Sys.UI.DomElement.setVisible($get("flagDescription"), false);
}
function flag_rollOut(sender, args) {
    flagTimeoutID = setTimeout(hideFlagHyp, 500);
}
function hideFlagHyp() {
    Sys.UI.DomElement.setVisible($get(hypFlagID), false);
    Sys.UI.DomElement.setVisible($get("flagDescription"), true);
}
            