// JavaScript Document

function realizarBusqueda()
{			
	 $.ajax({ 
				url: 'usuario_verificarSesion.php', 
				data: 'scrTip=1',
				beforeSend: inicioEnvio,
				dataType: "html",
				success: function(datos)
				{
					if(datos == "@@400@@") //Error sesion 
					{
						abrirPopMensaje('popup_error.php', true, 700, 230);
					}
					else if(datos == "@@401@@") //Error crossite
					{
						mostrarErrorXssSesion(datos);	
					}
					else 
					{
						document.getElementById('formBusqueda').submit();
					}
				}
		}); 
		
}
	
function validarEnter(e) 
{
   var key;

   if(window.event)
      key = window.event.keyCode;   //IE
   else
      key = e.which;                //firefox

	if(key == 13 )
	{	
    realizarBusqueda();
	}
}	

function paginarAjaxList(pagina, numeroFilas,archivo)
{		
	document.getElementById("pagina").value = pagina;
	document.getElementById("numeroFilas").value = numeroFilas;	
	
	if(document.getElementById("busqueda").value != "")
		$("#buscarReg").val(document.getElementById("busqueda").value);
		
	var vars = $("#formBusqueda").serialize();
	$.ajax({ 
		 type: "POST",
		 url: archivo,
		 data: vars+"&scrTip=1",
		 dataType: "html",
		 beforeSend: inicioEnvio,
		 success:function(datos){ 
				var cont = document.getElementById("listadoResultados");
				cont.innerHTML = datos;
		 } 
	}); 
}

//paginacion para resultados usuario
function paginarAjaxListUsuariosResult(pagina, numeroFilas, urlScript, parametros)
  {
	$.ajax({ 
 	  type: "POST",
	  url: urlScript,
	  data: "pagina="+pagina+"&numeroFilas="+numeroFilas+parametros+"&scrTip=1",
	  dataType: "html",
	  //beforeSend: inicioEnvio,
	  success:function(datos){ 
	     if(datos == "@@400@@" || datos == "@@401@@") //Error sesion o crossite
		 {
		   mostrarErrorXssSesion(datos);
		 }
		 else
		 {
		   var cont = document.getElementById("listadoResultados");
		   cont.innerHTML = datos;
		 }
	  } 
	}); 
  }

function inicioEnvio()
{
	var x=$("#resultado_buscar");
  x.html('<img src="img/ajax-loader.gif">');
}