﻿window.onload = init

function init()
{
	if(typeof(CargaClientsIds)!="undefined")
	    CargaClientsIds();
	    
	Set_Event_Submit();
	OcultarInfoStatus();
	SetScroll(); //tiene que estar duplicada
	ShowAlert();
	SetFocus();
	SetScroll(); //tiene que estar duplicada
	AskConfirm();	
	OpenWindow();
	
	document.onkeypress=document_onkeypress; //CANCELACION DEL RETORNO DE CARRO


	if (typeof (APP_cmbReglamentos) != "undefined") {
	    if (APP_cmbReglamentos != null) {
	        APP_cmbReglamentos.onchange = cmbReglamentos_onchange;
	    }
	}

}

function document_onkeypress(e){
    
    var KeyCode = -1;
    
    //EXPLORER O FIREFOX
    if (!e) {var e = window.event;}
    
    if(window.event)
        KeyCode = e.keyCode;
    else if(e.which)
        KeyCode = e.which;

	if (KeyCode==13){ //CANCELACION DEL RETORNO DE CARRO
		var srcId = null;
		
		//EXPLORER O FIREFOX
		if(e.srcElement)
            srcId = e.srcElement.id;
        else if(e.target) 
            srcId = e.target.id;
            
		// El evento se cancela si srcId es cadena vacia
		if (srcId.length > 0){
			
			//FORMA 1 DE RESOLVERLO PARA LAS TEXTAREAS
			// El evento no se cancela en las cajas de texto multilinea
			var IdsMultilinea = "";
			//IdsMultilinea = IdsMultilinea + " " + "txtObservaciones";
			if (IdsMultilinea.indexOf(srcId) >= 0){
				if(e.returnValue)e.returnValue=true;
				return true;
			}
			
			//FORMA 2 DE RESOLVERLO PARA LAS TEXTAREAS
			// El evento no se cancela en las cajas de texto multilinea
			var control = document.getElementById(srcId);
			if (control!=null){
				var sTag = control.tagName.toUpperCase();
				if (sTag == 'TEXTAREA'){
					if(e.returnValue)e.returnValue=true;
					return true;
				}
			}

            // El evento no se cancela si el foco esta en los botones de la toolbar
			var PatronIdsBotones = "tlbar_btn_a";			
			if (srcId.indexOf(PatronIdsBotones) >= 0){
				if(e.returnValue)e.returnValue=true;
				return true;
			}	
			
			// El evento no se cancela si el foco esta sobre un boton del formulario
			var IdsBotones = "";
			//IdsBotones = IdsBotones + " " + "btnMostar";
			if (IdsBotones.indexOf(srcId) >= 0){
				if(e.returnValue)e.returnValue=true;
				return true;
			}			
		}
		
		//Cuando pulsen INTRO en un control de un panel filtro buscador
		//se emula el botón de Buscar (Lupa de la toolbar)
		if (typeof(APP_panelFiltro)!="undefined"){			
			__MydoPostBack__MySubmit("ctl00$tlbarPpal","Buscar");
		}	
		
		//En los demas casos se cancela el INTRO
		e.preventDefault? e.preventDefault() : e.returnValue = false;
		return false;
	}
}




function cmbReglamentos_onchange() {
    __MydoPostBack__MySubmit(APP_cmbReglamentos.id, "");
}