﻿
var acceso = {

    start: function(){
        $('user').addEvent('keydown', function(e){
                    if (e.key == 'enter'){
                        $('clave').focus();
                    }
                });
        $('clave').addEvent('keydown', function(e){
                    if (e.key == 'enter'){
                        acceso.enviar(0);
                    }
                });

        $('user').focus();
        informa.start();
    },

    enviar:function(id)
    {
    
	    if($('user').value.replace( '/^\s*/', "" ).replace( '/\s*$/', "" )=='' || $('clave').value.replace( '/^\s*/', "" ).replace( '/\s*$/', "" )=='' ){
		    informa.aviso('Los datos no son correctos',2);
		    return;
	    }

        var strval = 'us=' + encodeURIComponent($('user').value) + '&ps=' + encodeURIComponent($('clave').value) + '&id=' + id.toString();
        if (window.location.search != ''){
            strval+='&'+window.location.search.substring(1).replace('&','&amp;');
        }
        request.get_htm('/services/func.aspx?op=1','',strval,'')
    }
}

window.addEvent('load', acceso.start)
