﻿// JScript File

var mobjFuntionAfterLogin 
            
// Is Signed In ?
function IsSignedIn(objWhereToReturn)
{
    // Save the funtion intendent to execute            
    mobjFuntionAfterLogin = objWhereToReturn;

    // Check to the WS if the user is signed in
    WebService.IsLogedIn(IsLogedInSucceededCallback);
}
            
function IsLogedInSucceededCallback(result, eventArgs)
{
    if (result==true)
    {
        mobjFuntionAfterLogin();
    }
    else
    {
        ShowSignIn();
    }
}        

function ShowSignIn()
{
    window.scrollTo(0,0);
    ShowPopUpOpacity('divUserSignIn',350,350);
}

// Sign in button from the login div
function SignIn() {
    WebService.Login(document.getElementById("txtUsername").value, document.getElementById("txtPassword").value,'PopUp',SignInSucceededCallback);
}

function SignInSucceededCallback(result, eventArgs)
{
    if (result==true)
    {
        ClosePopUpOpacity('divUserSignIn');
        mobjFuntionAfterLogin();
    }
    else
    {
        var objElem = document.getElementById("LoginError");
        objElem.innerHTML = 'Incorrect username or password.';
    }
}


