/**
 * function call_ObtenerDatos() 
 * para obtener los datos del usuario segun un login y un password 
 * mediante el agente de AJAX
 */

    /**
    * Funci�n que llama a la funci�n de php
    * que nos devolver� los datos de un usuario seg�n su login y password
    */
    function call_ObtenerDatos()
    {
        document.getElementById('divMsg').innerHTML = '<IMG src="./img/cargando.gif"><FONT face="arial" size="2">Obteniendo datos...';    
        var sLogin      = document.getElementById('txt_login').value;
        var sPassword   = document.getElementById('txt_password').value;
        
        if( (sLogin!="") && (sPassword!="") )
        {
            document.getElementById('divMsg').innerHTML = 'Buscando...';    
            //agent.call('', 'datos_usuarios__ObtenerDatos', 'callback_obtenerDatos', sLogin, sPassword);
            $.get("modules/datos_usuarios/datos_usuarios.php", {
                func: "datos_usuarios__ObtenerDatos",
                param1: sLogin,
                param2: sPassword },
                function(data){
                callback_obtenerDatos(data);
                });
        }
        else
        {
            alert("Debes introducir los valores para el Usuario y la Clave.");
            document.getElementById('divMsg').innerHTML = '';
        }
    }
    function callback_obtenerDatos(str)
    {
        document.getElementById('divMsg').innerHTML = '';    
        aValores = str.split('|');
        aValores[0] = removeChar(aValores[0]);                
        if( (aValores[0]==='true') || (aValores[0]===true) )
        {
            document.getElementById('divBordeDatosUsuario').style.border        = "1px solid #999999";
            document.getElementById('divBordeDatosUsuario').style.background    = "#EEEEEE";
            document.getElementById('divBordeDatosUsuario').style.padding       = "5px";                        
        
            document.getElementById('NOMBRE').value     = aValores[1];
            document.getElementById('APELLIDO1').value  = aValores[2];
            document.getElementById('APELLIDO2').value  = aValores[3];
            document.getElementById('EMAIL').value      = aValores[4];
            if(aValores[5]!="")
            {
                document.getElementById('TIPO_NIF_PASAPORTE').value = aValores[5];
            }
            document.getElementById('VALOR_NIF_PASAPORTE').value= aValores[6];
            document.getElementById('TELEFONO').value   = aValores[7];
            document.getElementById('MOVIL').value      = aValores[8];    
            document.getElementById('hPkUsuario').value = aValores[9];  //Identificador del usuario
            document.getElementById('FK_PAIS').value    = aValores[10];
    
            document.getElementById('txt_login').value      = "";
            document.getElementById('txt_password').value   = "";
    
            if(aValores[9]!="")
            {
                document.getElementById('USUARIO').disabled  = true;
                document.getElementById('PASSWORD').disabled = true;
                
            }    
            else
            {
                document.getElementById('USUARIO').disabled  = false;
                document.getElementById('PASSWORD').disabled = false;
            }
        }
        else
        {
            alert(aValores[1]);
        }        
        eval(document.getElementById('funcionJsAfterObtenerDatos').value);
    }