// JavaScript Document
$(document).ready(function() {
      $("#btnIngreso").click(function (){
	       iniciar();  
       }); 
      $("#password").keypress(function(e) {
         if(e.keyCode == 13) {
               iniciar();
         }
       });

	   alerta();	
           descripcion();
});



var $vOpcionRe="";

function descripcion(){
	// modal dialog init: custom buttons and a "close" callback reseting the form inside
	var $vOpcionReg= $( "#bDescripcion" ).dialog({
	autoOpen: false,
	modal: true,
        height: 130,
	width: 500	     
    });
}
function alerta(){
	// modal dialog init: custom buttons and a "close" callback reseting the form inside
	$vOpcionRe= $( "#bMensaje" ).dialog({
	autoOpen: false,
	modal: true,
        height: 146,
	width: 500,
	buttons: {
         Aceptar: function() {
           
             $( this ).dialog( "close" );
		 }
           
	}	     
    });
}
function iniciar(){

      var vUsuario=$('#usuario').get(0).value;
      var vPassword=$('#password').get(0).value;
      var vOp="IS"
	  
      _Usuario="usuario="+vUsuario; 
      _Password="password="+vPassword;
      _Op="op="+vOp;

      var datos=_Op+"&"+_Usuario+"&"+_Password;
   
      $.ajax({
          url: "PuertoNuevo/_Php/_Consultas/_Session.php?",  
          type: 'POST',
          async: true,
          data: datos,
          /*beforeSend: function(data) {                    
          $('#error').html("Espere! estamos registrando...");   
          $verror.dialog("open");
                      
          },
          */
          success:function(respuesta) {
            if(respuesta==1){
                setTimeout ("redireccionar()", 1000);
            }else{
			  // alert("Usuario no valido");
	        $vOpcionRe.dialog( "open" );
          } 
			
       }
    });	
}

function redireccionar(){
    var pagina="PuertoNuevo/indexpn.html";
    location.href=pagina;	
}

