<?php use_helper('UrlFunctions'); ?>
<script>
mostrarCargaImg = function(){ $('#s_ImagenLoad')[0].style.display = 'inline'; }
ocultarCargaImg = function(){ $('#s_ImagenLoad')[0].style.display = 'none'; }

mostrarMensajeError = function( s_MensajeError )
{
    $( "#resultContent" ).html( '<div id="mensaje_error_content" class="error">' + s_MensajeError + '</div>' );
    setTimeout( function(){ $( "#mensaje_error_content" ).fadeOut( 800 ).fadeIn( 800 ).fadeOut( 500 ).fadeIn( 500 ).fadeOut( 300 ); }, 4000 );
}
</script>
<script>
ejecutarGuardar = function()
{
	mostrarCargaImg();
	var strFormSerialize = $( 'form' ).serialize();
	                      
    executeAjaxJson( 
                        "<?php echo buildUrl( 'addemp/saveCompania', "block=001" ) ?>", 
                        //a_Params.join( "&" ), 
                        strFormSerialize,
                        function( o_json )
                        {
                            //console.log( o_json );
                            if( o_json.error )
                            {
                                ocultarCargaImg();
                                mostrarMensajeError( o_json.mensaje_error );
                                return false;
                            }
                            if( o_json.type_sub )
                            {
                                location.href = "<?=buildUrl( 'user/list', "block=001")?>";
                            }
                           
                        } 
                   );
}
</script>
<table class="cuerpo" width="98%" border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td height="0">
            <table border="0" cellpadding="0" cellspacing="0" width="100%">
                <tr>
                    <td class="titleBody">
                        <span class="subtitle">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:::&nbsp;Nuevo Tipo de Baja</span>
                    </td>
                    <td align="right" valign="baseline">
                        &nbsp;
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td valign="top">
            <form id="form1" name="form1" method="POST" onsubmit=""  enctype="multipart/form-data">
                <input type="hidden" name="TypeProc" id="TypeProc" value="1">
                <table class="" width="100%" style="margin-left: 20px;">
                    <tr>
                        <td valign="top">
                            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                                               
                                <tr>
                                    <td class="marco marcoTitle">
                                        <table class="" width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
                                            <tr>
                                                <td width="100%" valign="top">
                                                
                                                    <table width="100%">
                                                        <tr>
                                                            <td width="50%" valign="top" >
                                                            
                                                                <fieldset class="formGen" style="margin-top:0px">
                                                                    <!--<legend class="fielsettex">Datos Generales</legend> -->
                                                                    
                                                                    <div id="resultContent" style=""></div>
                                                                    
                                                                    <table border="0" cellspacing="6" cellpadding="0">
                                                                        <tr>
                                                                            <td nowrap="nowrap" width="10%" class="cabecera"><label class="label req" for="Empresa" >Empresa</label></td>
                                                                            <td nowrap="nowrap"><select name="Empresa" id="Empresa" class="combo"/></select></td>
                                                                            <td nowrap="nowrap" width="8%" class="cabecera">&nbsp;</td>
                                                                        </tr>
                                                                        <tr>
                                                                            <td nowrap="nowrap" width="10%" class="cabecera"><label class="label req" for="Rol" >Rol</label></td>
                                                                            <td nowrap="nowrap"><input class="text required" type="text" name="DescripcionCorta" id="DescripcionCorta" size="45" maxlength="200" value=""  onblur="this.value=this.value.toUpperCase();"/></td>
                                                                            <td nowrap="nowrap" width="8%" class="cabecera">&nbsp;</td>
                                                                        </tr>
                                                                        <tr>
                                                                            <td nowrap="nowrap" width="10%" class="cabecera"><label class="label req" for="Nombre" >Nombre</label></td>
                                                                            <td nowrap="nowrap"><input class="text required" type="text" name="Nombre" id="Nombre" size="45" maxlength="20" value=""/></td>
                                                                            <td nowrap="nowrap" width="8%" class="cabecera">&nbsp;</td>
                                                                        </tr>
                                                                        <tr>
                                                                            <td nowrap="nowrap" width="10%" class="cabecera"><label class="label req" for="Correo" >Correo</label></td>
                                                                            <td nowrap="nowrap"><input class="text" type="text" name="Correo"  size="45" maxlength="200" value="" /></td>
                                                                            <td nowrap="nowrap" width="8%" class="cabecera">&nbsp;</td>
                                                                        </tr>
                                                                        <tr>
                                                                            <td nowrap="nowrap" width="10%" class="cabecera"><label class="label req" for="Usuario" >Usuario</label></td>
                                                                            <td nowrap="nowrap"><input class="text" type="text" name="Usuario" id="Usuario" maxlength="" size="35" style="height: 25px;" title="Seleccione archivo."/></td>
                                                                            <td nowrap="nowrap" width="8%" class="cabecera">&nbsp;</td>
                                                                        </tr>
                                                                        <tr>
                                                                            <td nowrap="nowrap" width="10%" class="cabecera"><label class="label req" for="Contrasena" >Contraseña</label></td>
                                                                            <td nowrap="nowrap"><input class="text" type="password" name="Contrasena" id="Contrasena" size="45" maxlength="20" value=""  onblur="this.value=this.value.toUpperCase();"/></td>
                                                                            <td nowrap="nowrap" width="8%" class="cabecera">&nbsp;</td>
                                                                        </tr>
                                                                        <tr>
                                                                            <td nowrap="nowrap" width="10%" class="cabecera"><label class="label req" for="RContrasena" >Repetir Contraseña</label></td>
                                                                            <td nowrap="nowrap"><input class="text" type="password" name="RContrasena" id="RContrasena" rows="3" size="45" maxlength="20" /></td>
                                                                            <td nowrap="nowrap" width="8%" class="cabecera">&nbsp;</td>
                                                                        </tr>
                                                                    </table>
                                                                </fieldset>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                    
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <table width="100%" border="0" style="margin-top: 10px;">
                                            <tr>
                                                <td align="right" width="55%">
                                                    <input type="hidden" name="TypeSub" id="TypeSub" value="1"/>
                                                    <input type="button" class="button" value="Cancelar" onclick="location.href='<?php echo buildUrl( 'addemp/list', 'block=001' ) ?>'">
                                                    <input type="submit" class="button" value="Grabar" onclick="">
                                                    <input type="submit" class="button" value="Grabar y Siguiente" onclick="$('#TypeSub').val('0');">
                                                </td>
                                                <td width="45%">
                                                    <div id="s_ImagenLoad" style="display: none;"><img src="<?php echo Constantes::ROOT_DIR_APP ?>web/images/progress.gif" border="0"/>&nbsp;<label class="laber req">Grabando...</label></div>
                                                    &nbsp;
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </form>
        </td>
    </tr>
    
    
</table>

<script>
$.validator.setDefaults
(
    {
        submitHandler: function( form ) 
        {
            ejecutarGuardar();
        }
    }
);
$( "#form1" ).validate();
</script>