<script type="text/jscript">
function Valtext(e) {
    key = e.keyCode || e.which;
    tecla = String.fromCharCode(key).toLowerCase();
    letras = " áéíóúabcdefghijklmnñopqrstuvwxyz";
    especiales = [8, 37, 39, 46];

    tecla_especial = false
    for(var i in especiales) {
        if(key == especiales[i]) {
            tecla_especial = true;
            break;
        }
    }

    if(letras.indexOf(tecla) == -1 && !tecla_especial)
        return false;
}

function ValNumero(e) {
    key = e.keyCode || e.which;
    tecla = String.fromCharCode(key).toLowerCase();
    letras = "0123456789";
    especiales = [8, 37, 39, 46];

    tecla_especial = false
    for(var i in especiales) {
        if(key == especiales[i]) {
            tecla_especial = true;
            break;
        }
    }

    if(letras.indexOf(tecla) == -1 && !tecla_especial)
        return false;
}
	
	$(document).ready(function(){
		$("#rif").blur(function(){
			$.post("miarchivo5.php", {"rif":$("#rif").val()}, function(data){
				if(data.nombre){
				$("#rif").val("");
				alert("Rif ya Registrado");	
				}
			},"json");
		});
	});
</script>


	<?php
		if (isset($con))
		{
	?>
	<!-- Modal -->
	<div class="modal fade" id="nuevoProveedor" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
	  <div class="modal-dialog" role="document">
		<div class="modal-content">
		  <div class="modal-header">
			<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
			<h4 class="modal-title" id="myModalLabel"><i class='glyphicon glyphicon-edit'></i> Agregar nuevo Proveedor</h4>
		  </div>
		  <div class="modal-body">
			<form class="form-horizontal" method="post" id="guardar_proveedor" name="guardar_proveedor">
			<div id="resultados_ajax"></div>
	
              <div class="form-group">
              <label for="nombre" class="col-sm-3 control-label">Rif</label>
				<div class="col-sm-8">
				<table>
					<tr>
						<td class='col-xs-2'>
        		        	<select class="col-sm-2 form-control" id="tipo" name="tipo" required>
	 					    	<option value="J-">J</option>
                        		<option value="V-">V</option>
		                        <option value="G-">G</option>
        		                <option value="E-">E</option>
                		    </select>
						 </td>
						 <td class='col-xs-6'>
							<input type="text" class="col-sm-6 form-control" id="rif" name="rif" maxlength="9" required onKeyPress="return ValNumero(event)">
						</td>
					</tr>
				</table>
				</div>
			  </div>
              <div class="form-group">
				<label for="nombre" class="col-sm-3 control-label">Razon Social</label>
				<div class="col-sm-8">
				  <input type="text" class="form-control" id="nombre" name="nombre" maxlength="250" required>
				</div>
			  </div>
			   <div class="form-group">
				<label for="direccion" class="col-sm-3 control-label">Dirección</label>
				<div class="col-sm-8">
					<textarea class="form-control" id="direccion" name="direccion" maxlength="250"></textarea>
				</div>
			  </div>
              
              <div class="form-group">
				<label for="telefono" class="col-sm-3 control-label">Teléfono</label>
				<div class="col-sm-8">
				  <input type="text" class="form-control" id="telefono" name="telefono" maxlength="20" onKeyPress="return ValNumero(event)" >
				</div>
			  </div>
			  
			  <div class="form-group">
				<label for="email" class="col-sm-3 control-label">Correo</label>
				<div class="col-sm-8">
					<input type="email" class="form-control" id="email" name="email" >
				  
				</div>
			  </div>
			 
			  
		  </div>
		  <div class="modal-footer">
			<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
			<button type="submit" class="btn btn-primary" id="guardar_datos">Guardar datos</button>
		  </div>
		  </form>
		</div>
	  </div>
	</div>
	<?php
		}
	?>