function ClsLogin()
{
    this.ISLOGGED = false;
    this.USER = "";
    this.PWD = "";
    this.HASH = "";
}


ClsLogin.prototype.Login = function(user, pwd)
{
    var sUrl = "http://www.corex.es/whereis/whilogin.asmx";
//    var sUrl = "http://localhost:8081/whereis/whilogin.asmx";
    var sMethod = "Login";
    var sParams = "user=" + user + "&" + "pwd=" + pwd;

    try
    {
        if (mbDirectCalling)
        {
            lista = moWSCallers.WSDirectCall(sUrl, sMethod, sParams);
        }
        else
        {
            lista = moWSCallers.WSIndirectCall(sUrl, sMethod, sParams);
        }
        var xmlDoc = moXml.CreateDocument(lista);
        var items = moXml.SelectNodes(xmlDoc, "/LOGIN");
           
        this.ISLOGGED = false;
        this.USER = "";
        this.PWD = "";
        this.HASH = "";
        if (items.length == 1)
        {
            this.ISLOGGED = (moXml.SelectSingleNode(items[0], "LOGGED")=="T");
        
            if (this.ISLOGGED)
            {
                this.USER = moXml.SelectSingleNode(items[0], "USER");
                this.PWD = moXml.SelectSingleNode(items[0], "PWD");
                this.HASH = moXml.SelectSingleNode(items[0], "HASH");
                return true;
            }
            else
            {
                return false;
            }
        }
        else
        {
            return false;
        }
        
    }
    catch (ex)
    {
        return false;
    }
}


ClsLogin.prototype.ShowLogin = function()
{
//    if (!this.ISLOGGED)
    {
        //document.getElementById("spanLoading").style.display='none';
        ventana_modal = dhtmlmodal.open("login", "iframe", "login.html", "Identificacion de usuario", "width=320px,height=90px,center=1,resize=0,scrolling=0", "recal");
    }
}

var moLogin = new ClsLogin();

function AfterLogin()
{
    if (moLogin.ISLOGGED)
    {
        window.open("default.aspx?user=" + moLogin.USER + "&pwd=" + moLogin.PWD + "&hash=" + moLogin.HASH);
    }
    else
    {
//        alert("KO");
    }
}

function Cerrar_modal()
{
    if (ventana_modal != null)
    {
        ventana_modal.controls.onclick();
        ventana_modal = null;
    }
}