<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="frmCatInterfaces.aspx.cs" Inherits="bajaWare.Interfaces.frmCatInterfaces" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

    <title><%=Application.Get("Nom_Sis") %> - Catalogos</title>
<!--    link href="css/StyleSheetNET.css" rel="stylesheet" type="text/css" -->
    <link href="../Styles/masterPage.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .style1
        {
            width: 261px;
        }
        .style2
        {
            width: 310px;
        }
        .updateProgress
        {
            border-width:1px; 
            border-style:solid; 
            background-color:#CCCCCC; 
            position:absolute; 
            width:130px; 
            height:50px;    
        }
        .updateProgressMessage
        {
            margin:3px; 
            font-family: Tahoma, Helvetica, sans-serif;
            font-size:small; 
            vertical-align: middle;
        }
        input, select, option
        {
            background-color: #EAEAE8;
        }
    </style>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolderContenido" runat="server">
    <div>
    </div>
    <table border="0" id="TblCatalogo" width="100%" cellpadding="0" cellspacing="0">
        <tr>
            <td colspan="3" align="center">
                <asp:Label runat="SERVER" ID="lblTitulo" Font-Bold="True" Font-Names="Tahoma" Font-Size="Large" ForeColor="#5D7B9D">Catálogo de Interfaces</asp:Label>  
                <asp:UpdatePanel runat="server" UpdateMode="Conditional" ID="UP_Msg">
                    <ContentTemplate>
                        <asp:Label runat="SERVER" ID="Msg" Font-Bold="True" Font-Names="Tahoma" Font-Size="XX-Small" ForeColor="ActiveCaption" Text=""></asp:Label>  
                    </ContentTemplate>
                </asp:UpdatePanel>
            </td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td align="center" style="width: 1047px">
                <table id="tblContenedor" border="0" cellpadding="0" cellspacing="0" width="90%">
                <!--## -->
                <tr id="TR_NUEVO" runat="server" >
                    <td align="right" style="width: 1000px"> 
                        <asp:UpdatePanel ID="UPANEL" runat="server" UpdateMode="Conditional">
                            <ContentTemplate >
                                <asp:Button ID="BtnNuevo" runat="server" Text="" CssClass="btnNuevo" Width="" OnClick="PopUpNuevo"/>
                            </ContentTemplate>
                        </asp:UpdatePanel> 
                        <cc1:UpdatePanelAnimationExtender ID="UpdatePanelAnimationExtender1" BehaviorID="animation2" runat="server" TargetControlID="UPANEL">
                            <Animations>
                                <OnUpdating>
                                    <Parallel duration="0">
                                        <%-- place the update progress div over the gridview control --%>
                                        <ScriptAction Script="onUpdating();" />  
                                     </Parallel>
                                </OnUpdating>
                                <OnUpdated>
                                    <Parallel duration="0">
                                        <%--find the update progress div and place it over the gridview control--%>
                                        <ScriptAction Script="onUpdated();" /> 
                                    </Parallel> 
                                </OnUpdated>
                            </Animations>
                        </cc1:UpdatePanelAnimationExtender> 
                    </td> 
                </tr> 
                <tr>
                    <td style="width: 1000px;">
                        <asp:UpdatePanel ID="updatePanel" runat="server" UpdateMode="Conditional">
                            <ContentTemplate>
                                <div style="width:800px; height:500px; overflow:auto;">
                                <asp:GridView ID="GV_Catalogos" runat="server" AllowPaging="True" AllowSorting="False"
                                    AutoGenerateColumns="True" CellPadding="4" 
                                    EmptyDataText="<b><h4>No existen Datos</h4></b>" ForeColor="#333333"  GridLines="None" 
                                    OnRowCreated="GV_Catalogos_RowCreated"
                                    OnRowDataBound="GV_Catalogos_RowDataBound" 
                                    OnSelectedIndexChanged="GV_Catalogos_SelectedIndexChanged"
                                    OnPageIndexChanging="GV_Catalogoss_PageIndexChanging"
                                     DataKeyNames = "intInterfaceid"
                                    Width="100%" HorizontalAlign="Center" CssClass="gvTD"  PageSize="15" >
                                    <HeaderStyle CssClass="gvHeader"/>
                                    <FooterStyle CssClass="gvFooter"/>
                                    <RowStyle CssClass="gvTD"/>
                                    <PagerStyle CssClass="gvPager"/>
                                    <AlternatingRowStyle BackColor="#DFDFDF"/>
                                    <EditRowStyle CssClass="gvERS" />
                                    <SelectedRowStyle CssClass="gvSRS"/>
                                    <Columns>
                                          <asp:TemplateField>
                                            
                                            <ItemTemplate>
                                                <asp:Panel ID="popupMenu" runat="server" style="display:none">
                                                    <div style="border:1px outset white;padding:2px;">
                                                       
                                                    </div>
                                                </asp:Panel>    
                                                <cc1:HoverMenuExtender ID="hoverMenu" runat="server"  
                                                    PopupControlID="PopupMenu"
                                                    PopupPosition="Right"
                                                    HoverCssClass="popupHover"
                                                    TargetControlID="PopupMenu"
                                                    PopDelay="200" />
                                            </ItemTemplate>
                                            <EditItemTemplate>
                                                    
                                                
                                            </EditItemTemplate>                                
                                            <HeaderStyle Width="0px" />
                                        </asp:TemplateField>
                                        <asp:TemplateField>
				                            <ItemTemplate>
				                                <asp:Button ID="btnViewDetails" runat="server" Text="" OnClick="BtnViewDetails_Click" CssClass="btnEditar" />
                                            </ItemTemplate>
                                            <ControlStyle Width="45px" />
                                            <HeaderStyle Width="45px" />
			                            </asp:TemplateField>
                                        <asp:TemplateField>
				                            <ItemTemplate>
				                                <asp:Button ID="lnkButtonDelete" runat="server" CommandName="Delete" Text=""  CssClass="btnEliminar" OnClick="EliminaRegistro" CommandArgument='<%# Convert.ToInt32(DataBinder.Eval(Container, "DataItemIndex")) + 1 %>'  OnClientClick="return Confirma();"/>
                                            </ItemTemplate>
                                            <ControlStyle Width="60px" />
                                            <HeaderStyle Width="60px" />
			                            </asp:TemplateField>
                                    </Columns>
                                   
                                    <PagerTemplate>
                                        <asp:Label ID="Label1" runat="server" Text="Muestra Filas:" />
                                        <asp:DropDownList ID="ddlPageSize" runat="server" AutoPostBack="true" OnSelectedIndexChanged="GV_Catalogos_SelectedIndexChanged">
                                            <asp:ListItem Value="5" />
                                            <asp:ListItem Value="10" />
                                            <asp:ListItem Value="15" />
                                        </asp:DropDownList>
                                        &nbsp;
                                        Pagina
                                        <asp:TextBox ID="txtGoToPage" runat="server" AutoPostBack="true" OnTextChanged="GoToPage_TextChanged" Width="40px" CssClass="gotopage" />
                                        de
                                        <asp:Label ID="lblTotalNumberOfPages" runat="server" />
                                        &nbsp;
                                        <asp:ImageButton ID="Button1" runat="server" CommandName="Page" ToolTip="Página Anterior" Width="25px" CommandArgument="Prev" CssClass="previous" ImageUrl="../Images/Grids/ButtonIrAAnterior.png"/>
                                        <asp:ImageButton ID="Button2" runat="server" CommandName="Page" ToolTip="Página Siguiente" Width="25px" CommandArgument="Next" CssClass="next" ImageUrl="../Images/Grids/ButtonIrASiguiente.png" />
                                    </PagerTemplate>
                                   
                                </asp:GridView>
                                </div>
                            </ContentTemplate>
                        </asp:UpdatePanel>
                        <cc1:UpdatePanelAnimationExtender ID="upae" BehaviorID="animation" runat="server" TargetControlID="updatePanel">
                            <Animations>
                                <OnUpdating>
                                    <Parallel duration="0">
                                        <%-- place the update progress div over the gridview control --%>
                                        <ScriptAction Script="onUpdating();" />  
                                     </Parallel>
                                </OnUpdating>
                                <OnUpdated>
                                    <Parallel duration="0">
                                        <%--find the update progress div and place it over the gridview control--%>
                                        <ScriptAction Script="onUpdated();" /> 
                                    </Parallel> 
                                </OnUpdated>
                            </Animations>
                        </cc1:UpdatePanelAnimationExtender>
                        <div id="updateProgressDiv" class="updateProgress" style="display:none;">
                            <div style="margin-top:13px;">
                                <asp:Image runat="server" id="ImageProgress" ImageUrl="../Images/Grids/simple.gif" />
                                <span class="updateProgressMessage">Cargando ...</span>
                            </div>
                        </div>
                        <asp:Button id="btnShowPopup" runat="server" style="display:none" />
                        

                        <cc1:ModalPopupExtender ID="mdlPopup" runat="server" TargetControlID="btnShowPopup" PopupControlID="pnlPopup" CancelControlID="btnClose" BackgroundCssClass="modalBackground"/>
                        <asp:Panel ID="pnlPopup" runat="server" Width="600px" style="display:none; background-color: White; border: solid 1px Black;">
                            <asp:Label ID="lblCustomerDetail" runat="server" Text=""  CssClass="gvHeader" Width="100%" ForeColor="White" Height="27px">
                                <b>NUEVO REGISTRO</b>
                            </asp:Label>    
                            <div id="Div1"  style=" text-align:center; height:110px; overflow:auto; vertical-align:top;border:1px solid #828FB6; BACKGROUND-ATTACHMENT: fixed;"    >
                                <asp:UpdatePanel ID="updPnlCustomerDetail" runat="server" UpdateMode="Conditional" >
                                    <ContentTemplate>
                                        <asp:Label id="EditMSG" ForeColor="White" Runat="Server" Text="Mensajes" BackColor="Red" BorderColor="White" Width="600px" Visible="false"/>
                                         <asp:DetailsView id="dvDetalleCatalogo"  Runat="Server"
                                            Width="97%" Height="104px" 
                                            HorizontalAlign="Center" CaptionAlign="Left" 
                                            CellPadding="4" ForeColor="#333333"
                                            AutoGenerateRows="False"
                                            GridLines="None" 
                                            DefaultMode ="Insert">
                                               <HeaderStyle CssClass="gvHeader"/>
                                            <FooterStyle CssClass="gvFooter"/>
                                            <RowStyle CssClass="gvTD"/>
                                            <PagerStyle CssClass="gvPager"/>
                                            <AlternatingRowStyle CssClass="gvARS" />
                                            <EditRowStyle CssClass="gvERS" />
                                    
                                            <Fields>
                                               <asp:TemplateField>
                                                    <EditItemTemplate>
                                                        <asp:Label runat="server" ID="lblInterfaces" Text="ID"  CssClass="captionTesoreria"></asp:Label>
                                                        <asp:TextBox runat="server" ID="intInterfaceid" Text="" ReadOnly="true" Width="50px" CssClass="captionTesoreria" />
                                                     </EditItemTemplate>                    
                                               </asp:TemplateField>
                                               
                                               <asp:TemplateField>
                                                    <EditItemTemplate>
                                                        <asp:Label runat="server" ID="lblDescipcion" Text="Descripción" CssClass="captionTesoreria"></asp:Label>
                                                        <asp:TextBox runat="server" ID="vchInterfaces" Text="" CssClass="captionTesoreria" MaxLength="60" />
                                                    </EditItemTemplate>
                                               </asp:TemplateField>
                                             </Fields>
                                            
                                        </asp:DetailsView>
                                    </ContentTemplate>                
                                </asp:UpdatePanel>
                            </div>                                 
                            <div class="popUpBottonSpace">
                                <asp:Button ID="btnActualiza" runat="server" Text="" Width="" CssClass="btnActualiza"  OnClick="AlmacenaNuevo" OnClientClick="return verificaDatos('I');"/> <!-- if(Valida('I')=='NOK')return false; else return true; -->
                                <asp:Button ID="btnClose" runat="server" Text=""  Width="" CssClass="btnCerrar" />               
                                 <asp:UpdatePanel ID="UPANEL2" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true" >
                                    <ContentTemplate >
                                        
                                    </ContentTemplate>
                                    <Triggers>
                                        <asp:AsyncPostBackTrigger ControlID="btnActualiza" EventName="Click" />
                                    </Triggers>
 
                                </asp:UpdatePanel>
                                <cc1:UpdatePanelAnimationExtender ID="UpdatePanelAnimationExtender2" BehaviorID="animation3" runat="server" TargetControlID="UPANEL2">
                                    <Animations>
                                        <OnUpdating>
                                            <Parallel duration="0">
                                                <%-- place the update progress div over the gridview control --%>
                                                <ScriptAction Script="onUpdating();" />  
                                             </Parallel>
                                        </OnUpdating>
                                        <OnUpdated>
                                            <Parallel duration="0">
                                                <%--find the update progress div and place it over the gridview control--%>
                                                <ScriptAction Script="onUpdated();" /> 
                                            </Parallel> 
                                        </OnUpdated>
                                    </Animations>
                                </cc1:UpdatePanelAnimationExtender>
                            </div>             
                        </asp:Panel>
                        <asp:Button id="btnShowPopup2" runat="server" style="display:none" />
                        <cc1:ModalPopupExtender ID="mdlPopup2" runat="server" TargetControlID="btnShowPopup2" PopupControlID="pnlPopup2" CancelControlID="Button6" BackgroundCssClass="modalBackground" />
                        <asp:Panel ID="pnlPopup2" runat="server" Width="600px" style="display:none; background-color: White; border: solid 1px Black;">
                            <asp:Label ID="Label2" runat="server" Text="" CssClass="gvHeader" Width="100%" ForeColor="White" Height="27px">
                            
                                <b>ACTUALIZACION DE REGISTRO</b>
                            </asp:Label>
                             
                            <div id="Div2"  style="margin:none; text-align:center; width:auto; height:110px; overflow:auto; vertical-align:top; border:1px solid #828FB6; BACKGROUND-ATTACHMENT: fixed;"  >                         
                                <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                                    <ContentTemplate>
                                    <asp:Label id="EditMSG1" ForeColor="White" Runat="Server" Text="Mensajes" BackColor="Red" BorderColor="White" Width="600px" Visible="false"/>
                                        <asp:DetailsView ID="dvEditaCatalogo" runat="server" Width="97%" Height="104px" HorizontalAlign="Center" CaptionAlign="Left" CellPadding="4" ForeColor="#333333" GridLines="None" 
                                        AutoGenerateRows ="False" DefaultMode="Insert" DataKeyNames="intInterfaceid"  >
                                            
                                              <HeaderStyle CssClass="gvHeader"/>
                                            <FooterStyle CssClass="gvFooter"/>
                                            <RowStyle CssClass="gvTD"/>
                                            <PagerStyle CssClass="gvPager"/>
                                            <AlternatingRowStyle CssClass="gvARS" />
                                            <EditRowStyle CssClass="gvERS" />

                                            <Fields>
                                               <asp:TemplateField HeaderText="ID">
                                                    <EditItemTemplate>
                                                        <asp:TextBox runat="server" ID="intInterfaceid" Text="" ReadOnly="true" Width="50px" CssClass="captionTesoreria" />
                                                    </EditItemTemplate>                    
                                               </asp:TemplateField>
                                               <asp:TemplateField HeaderText="Descripción">
                                                    <EditItemTemplate>
                                                        <asp:TextBox runat="server" ID="vchInterfaces" Text="" CssClass="captionTesoreria" MaxLength="60" />
                                                    </EditItemTemplate>
                                               </asp:TemplateField>
                                             </Fields>
                                           
                                        </asp:DetailsView>
                                      </ContentTemplate>                
                                </asp:UpdatePanel>
                            </div> 
                            <div class="popUpBottonSpace">
                                <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
                                    <ContentTemplate >
                                        
                                        <asp:Label ID="lblAcepta_Detalle" runat="server" Text="" ForeColor="white" BackColor="red" width="100%" Visible="false" ></asp:Label>
                                        
                                    </ContentTemplate>
                                        
                                </asp:UpdatePanel>
                                <asp:Button ID="Button4" runat="server" Text="" Width="" CssClass="btnActualiza" OnClick="ActualizaRegistro"  OnClientClick ="return verificaDatos('U');"/> <!-- if(Valida('U')=='NOK')return false; else return true; -->
                                <asp:Button ID="Button6" runat="server" Text=""  Width="" CssClass="btnCerrar"   />
                                <cc1:UpdatePanelAnimationExtender ID="UpdatePanelAnimationExtender3" BehaviorID="animationp" runat="server" TargetControlID="UpdatePanel2">
                                    <Animations>
                                        <OnUpdating>
                                            <Parallel duration="0">
                                                <%-- place the update progress div over the gridview control --%>
                                                <ScriptAction Script="onUpdating();" />  
                                             </Parallel>
                                        </OnUpdating>
                                        <OnUpdated>
                                            <Parallel duration="0">
                                                <%--find the update progress div and place it over the gridview control--%>
                                                <ScriptAction Script="onUpdated();" /> 
                                            </Parallel> 
                                        </OnUpdated>
                                    </Animations>
                                </cc1:UpdatePanelAnimationExtender>
                            </div>             
                        </asp:Panel> 
                    </td> 
                </tr> 
            </table> 
            </td> 
            <asp:HiddenField ID="hdnInterfaces" runat="server" Value="0" />
            <td>&nbsp;</td>
        </tr> 
    </table>

<script language="javascript" type="text/javascript" >
    com = {};
    com.RIEM = {};
    com.RIEM.catalogos = {};
    com.RIEM.catalogos.isWaiting = false;
    com.RIEM.catalogos.valid = null;
    com.RIEM.catalogos.tipo = null;
    function onUpdating() {
        // get the update progress div
        var updateProgressDiv = $get('updateProgressDiv');

        //  get the gridview element
        // var gridView = $get('GV_Catalogos');
        var gridView = document.getElementById('ContentPlaceHolderContenido_GV_Catalogos');

        // make it visible
        updateProgressDiv.style.display = '';

        // get the bounds of both the gridview and the progress div
        var gridViewBounds = Sys.UI.DomElement.getBounds(gridView);
        var updateProgressDivBounds = Sys.UI.DomElement.getBounds(updateProgressDiv);

        //  center of gridview
        var x = gridViewBounds.x + Math.round(gridViewBounds.width / 2) - Math.round(updateProgressDivBounds.width / 2);
        var y = gridViewBounds.y + Math.round(gridViewBounds.height / 2) - Math.round(updateProgressDivBounds.height / 2);

        //    set the progress element to this position
        Sys.UI.DomElement.setLocation(updateProgressDiv, x, y);
    }

    function onUpdated() {
        // get the update progress div
        var updateProgressDiv = $get('updateProgressDiv');
        // make it invisible
        updateProgressDiv.style.display = 'none';
    }
    //------------------------------------------------------------------------------------------------            
    //  Funciones para el Paginado del Grid View principal
    var _isResizing;
    //  a reference to the header column that is being resized
    var _element;
    //  an array of all of the tables header cells
    var _ths;

    var _aux;

    function pageLoad(args) {
        //  get all of the th elements from the gridview
        //_ths = $get('GV_Catalogos').getElementsByTagName('TH');
        _aux = document.getElementById('ContentPlaceHolderContenido_GV_Catalogos');
        _ths = _aux.getElementsByTagName('TH');
        //_ths = document.getElementsByTagName('TH');
        //  if the grid has at least one th element
        if (_ths.length > 1) {

            for (i = 0; i < _ths.length; i++) {
                //  determine the widths
                _ths[i].style.width = Sys.UI.DomElement.getBounds(_ths[i]).width + 'px';

                //  attach the mousemove and mousedown events
                if (i < _ths.length - 1) {
                    $addHandler(_ths[i], 'mousemove', _onMouseMove);
                    $addHandler(_ths[i], 'mousedown', _onMouseDown);
                }
            }

            //  add a global mouseup handler            
            $addHandler(document, 'mouseup', _onMouseUp);
            //  add a global selectstart handler
            $addHandler(document, 'selectstart', _onSelectStart);
        }
    }

    function _onMouseMove(args) {
        if (_isResizing) {

            //  determine the new width of the header
            var bounds = Sys.UI.DomElement.getBounds(_element);
            var width = args.clientX - bounds.x;

            //  we set the minimum width to 1 px, so make
            //  sure it is at least this before bothering to
            //  calculate the new width
            if (width > 1) {

                //  get the next th element so we can adjust its size as well
                var nextColumn = _element.nextSibling;
                var nextColumnWidth;
                if (width < _toNumber(_element.style.width)) {
                    //  make the next column bigger
                    nextColumnWidth = _toNumber(nextColumn.style.width) + _toNumber(_element.style.width) - width;
                }
                else if (width > _toNumber(_element.style.width)) {
                    //  make the next column smaller
                    nextColumnWidth = _toNumber(nextColumn.style.width) - (width - _toNumber(_element.style.width));
                }

                //  we also don't want to shrink this width to less than one pixel,
                //  so make sure of this before resizing ...
                if (nextColumnWidth > 1) {
                    _element.style.width = width + 'px';
                    nextColumn.style.width = nextColumnWidth + 'px';
                }
            }
        }
        else {
            //  get the bounds of the element.  If the mouse cursor is within
            //  2px of the border, display the e-cursor -> cursor:e-resize
            var boundsEl = Sys.UI.DomElement.getBounds(args.target);
            if (Math.abs((boundsEl.x + boundsEl.width) - (args.clientX)) <= 2) {
                args.target.style.cursor = 'e-resize';
            }
            else {
                args.target.style.cursor = '';
            }
        }
    }

    function _onMouseDown(args) {
        //  if the user clicks the mouse button while
        //  the cursor is in the resize position, it means
        //  they want to start resizing.  Set _isResizing to true
        //  and grab the th element that is being resized
        if (args.target.style.cursor == 'e-resize') {
            _isResizing = true;
            _element = args.target;
        }
    }

    function _onMouseUp(args) {
        //  the user let go of the mouse - so
        //  they are done resizing the header.  Reset
        //  everything back
        if (_isResizing) {

            //  set back to default values
            _isResizing = false;
            _element = null;

            //  make sure the cursor is set back to default
            for (i = 0; i < _ths.length; i++) {
                _ths[i].style.cursor = '';
            }
        }
    }

    function _onSelectStart(args) {
        // Don't allow selection during drag
        if (_isResizing) {
            args.preventDefault();
            return false;
        }
    }

    function _toNumber(m) {
        //  helper function to peel the px off of the widths
        return new Number(m.replace('px', ''));
    }
    function Confirma() {
        return confirm('¿Esta seguro que desea eliminar este Registro?');
    }
    function ValidaExistenciaJS() {
        var Respuesta = _Catalogos.ValidaExistencia();
        return Respuesta
    }

    function verificaDatos(tipo) {
        if (com.RIEM.catalogos.isWaiting) {
            return false;
        } else if (com.RIEM.catalogos.valid == null) {
            com.RIEM.catalogos.isWaiting = true;
            com.RIEM.catalogos.tipo = tipo;
            PageMethods.ValidaDatos(onValidaDatosComplete);
            return false;
        } else {
            var valid = com.RIEM.catalogos.valid;
            com.RIEM.catalogos.valid = null;
            return valid;
        }

    }
    function onValidaDatosComplete(result) {
        var mRespuesta = result.split("#");
        var lon = eval(mRespuesta[0]);
        var tipo = com.RIEM.catalogos.tipo;
        var btnAccion = document.getElementById((tipo == "I") ? "ContentPlaceHolderContenido_btnActualiza" : "ContentPlaceHolderContenido_Button4");
        com.RIEM.catalogos.isWaiting = false;
        com.RIEM.catalogos.valid = false;
        btnAccion.disabled = false;
        if (mRespuesta[0] == "NOK") {
            alert("<<< MENSAJE DEL SISTEMA >>>\n\n" + mRespuesta[1])
            // Foco al Objeto
            return;
        } else {
            var k = 4;
            for (var i = 1; i <= lon; i++) {
                var matriz = mRespuesta[i].split("|");
                var dv
                if (tipo == "U") {
                    dv = $get("ContentPlaceHolderContenido_dvEditaCatalogo_" + matriz[0])
                }
                else {
                    dv = $get("ContentPlaceHolderContenido_dvDetalleCatalogo_" + matriz[0])
                }
                var valor = ""
                //alert(dv.id + "\n" + dv.innerHTML + "\n" + dv.value + "\n" + dv.text )
                //Si es llave Primaria
                if (matriz[3] == "S" && tipo == "U") {
                    valor = dv.innerHTML
                }
                else {
                    valor = dv.value
                }
                //Si no tiene Valor
                if (valor == "") {
                    alert("<<< MENSAJE DEL SISTEMA >>>\nEl Dato " + matriz[1] + " es Obligatorio. ")
                    dv.style.background = "red";
                    dv.focus();
                    return;
                }
                switch (matriz[2]) {
                    case "NE":
                        if (isNaN(valor)) { alert("<<< MENSAJE DEL SISTEMA >>>\nEl Dato " + matriz[1] + " debe ser Númerico. "); dv.focus(); return; }
                        break;
                }
                //alert(valor)
            }
        }
        com.RIEM.catalogos.valid = true;
        btnAccion.click();
        // http://geekswithblogs.net/dotNETvinz/archive/2008/09/11/forcing-button-click-event-to-fire-up-when-pressing-enter-again.aspx
        // http://forums.asp.net/p/1043708/1461136.aspx
        // verificaDatos(tipo);
        //    return;
    }

    function Valida(tipo) {
        //Valida que no exista el registro
        //var Existe = ValidaExistenciaJS();
        //if(Existe == "NOK"){
        //alert("<<< MENSAJE DEL SISTEMA >>>\n\nLa clave del registro existe, por favor proporcione un clave nueva.")
        //return "NOK"
        //}

        //lanza peticion a server
        // ADSISPLUS.Catalogos
        document.getElementById("btnActualiza").disabled = true;
        com.RIEM.catalogos.isWaiting = true;
        PageMethods.ValidaDatos(onValidaDatosComplete);
        //com.RIEM.catalogos.tipo
        return "NOK";
        var Respuesta = PageMethods.ValidaDatos();
        var mRespuesta = Respuesta.value.split("#");
        var lon = eval(mRespuesta[0]);
        //alert(lon)
        //alert(Respuesta.value)
        if (mRespuesta[0] == "NOK") {
            alert("<<< MENSAJE DEL SISTEMA >>>\n\n" + mRespuesta[1])
            // Foco al Objeto
            return "NOK"
        } else {

            var k = 4;
            for (var i = 1; i < lon; i++) {
                var matriz = mRespuesta[i].split("|");
                var dv
                if (tipo == "U") {
                    dv = $get("dvEditaCatalogo_" + matriz[0])
                }
                else {
                    dv = $get("dvDetalleCatalogo_" + matriz[0])
                }
                var valor = ""
                //alert(dv.id + "\n" + dv.innerHTML + "\n" + dv.value + "\n" + dv.text )
                //Si es llave Primaria
                if (matriz[3] == "S" && tipo == "U") {
                    valor = dv.innerHTML
                }
                else {
                    valor = dv.value
                }
                //Si no tiene Valor
                if (valor == "") {
                    alert("<<< MENSAJE DEL SISTEMA >>>\nEl Dato " + matriz[1] + " es Obligatorio. ")
                    dv.style.background = "red";
                    dv.focus();
                    return "NOK"
                }
                switch (matriz[2]) {
                    case "NE":
                        if (isNaN(valor)) { alert("<<< MENSAJE DEL SISTEMA >>>\nEl Dato " + matriz[1] + " debe ser Númerico. "); dv.focus(); return "NOK"; }
                        break;
                }
                //alert(valor)
            }
        }
        return "OK"
    }
    function alfanumerico(obj) {
        var tecla = window.event.keyCode;
        //alert(tecla)
        if (tecla >= 64 && tecla <= 90 || 97 <= tecla && tecla <= 122 || 46 <= tecla && tecla <= 57 || tecla == 32 || tecla == 209 || tecla == 241 || tecla == 92 || tecla == 47 || tecla == 58) {
        } else {
            window.event.keyCode = 0;
        }
    }
    var nav4 = window.Event ? true : false;
    function acceptNum(evt) {
        // NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57	
        var key = nav4 ? evt.which : evt.keyCode;
        return (key <= 13 || (key >= 48 && key <= 57));
    }
    var nav5 = window.Event ? true : false;
    function acceptNumDecimal(evt) {
        // NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57	
        var key = nav5 ? evt.which : evt.keyCode;
        return (key <= 13 || (key >= 46 && key <= 57));
    }
</script>
</asp:Content>
