﻿addEvent(window, "load", init);
        
        
        function addEvent(obj,evType,fn){if(obj.addEventListener){obj.addEventListener(evType,fn,false);return true;}else if(obj.attachEvent){var r=obj.attachEvent("on"+evType,fn); return r;}else{return false;}};        
        
        function init(){
            document.getElementById('datos').style.display='block';
            document.getElementById('txtUsuario').text = "";
            document.getElementById('txtUsuario').focus();
            
            if (Csg.isOpera()){
                addEvent(document.getElementById('txtCbo'), "keypress", TecladoCbo);
                addEvent(document.getElementById('txtUsuario'), "keypress", TecladoUsuario);
                addEvent(document.getElementById('txtPass'), "keypress", TecladoClave);    
                                
            }
            addEvent(document.getElementById('txtCbo'), "keydown", TecladoCbo);
            addEvent(document.getElementById('txtUsuario'), "keydown", TecladoUsuario);
            addEvent(document.getElementById('txtPass'), "keydown", TecladoClave);
            
        }

        function TecladoCbo(e){
            var a=document.getElementById('txtUsuario');
            if (e.keyCode){ code = e.keyCode; if(code==13){e.returnValue=false;a.focus();}}
            if ( e['which']){code = e['which'];if(code==13){e.preventDefault();e.stopPropagation();a.focus();}}
        }

        
        function TecladoUsuario(e){
            document.getElementById('divError').style.visibility='hidden';var a=document.getElementById('txtPass');
            if (e.keyCode){ code = e.keyCode; if(code==13){e.returnValue=false;a.focus();}}
            if ( e['which']){code = e['which'];if(code==13){e.preventDefault();e.stopPropagation();a.focus();}}
        }

        function TecladoClave(e){
            var a=document.getElementById('btnLogin')
            if (e.keyCode){ code = e.keyCode; if(code==13){e.returnValue=false;if(a){a.click()}}}
            if ( e['which']){code = e['which'];if(code==13){e.preventDefault();e.stopPropagation();a.onclick();}}
            
            
        }
