

	jQuery(function($) {

		

		Reestablecer();

	

	

	});

	

	  function showHidePreloader(show){

                if(show)

                    document.getElementById('loading').style.display='block';

                else

                    document.getElementById('loading').style.display='none';

            }

	

	

	function Reestablecer(){ 

	

		GetFilter();

		GetList(1, "0" ,"0");

		GetGrid(1, "0" ,"0");

	}

  

	function Paginate(pageNumber, ref){ 

		

		var select_pais = document.getElementById("filtropais").value;

		var select_actividad= document.getElementById("filtroactividad").value;

		

		if(ref == "List"){

				    showHidePreloader(true);

					GetList(pageNumber, select_pais ,select_actividad);

		}else if(ref == "Grid"){

					showHidePreloader(true);

					GetGrid(pageNumber, select_pais ,select_actividad);

		}else if(ref == null){

			showHidePreloader(true);

			GetList(pageNumber, select_pais ,select_actividad);

			GetGrid(pageNumber, select_pais ,select_actividad);

		}

		

		

	}

	

	

	

	function GetList(pageNumber, select_pais, select_actividad){

		

		jQuery.ajax({

		  

			

		  type: 'POST',

		  url: 'https://contractworkplaces.com/en/wp-admin/admin-ajax.php',

		  data: {

		  action: 'GenerarTabla',

		  pageNumber: pageNumber,

		  select_pais: select_pais,

		  select_actividad:select_actividad,

		  

		  },

			  success: function(data, textStatus, XMLHttpRequest){
			  
			  

			  jQuery("#ListContainer").html('');

			  jQuery("#ListContainer").append(data);

		  },

			  error: function(MLHttpRequest, textStatus, errorThrown){

			 // alert(errorThrown);

		  }

		});

		

	}

  

  

  function GetGrid(pageNumber, select_pais, select_actividad){

		

		jQuery.ajax({

		  

			

		  type: 'POST',

		  url: 'https://contractworkplaces.com/en/wp-admin/admin-ajax.php',

		  data: {

		  action: 'GenerarGrilla',

		  pageNumber: pageNumber,

		  select_pais: select_pais,

		  select_actividad:select_actividad,

		  

		  },

			  success: function(data, textStatus, XMLHttpRequest){
			  
			  //document.getElementById('loading').style.display='none';
			  jQuery("#GridContainer").html('');

			  jQuery("#GridContainer").append(data);

		  },

			  error: function(MLHttpRequest, textStatus, errorThrown){

			 // alert(errorThrown);

		  }

		});

		

	}

  

  

  function GetFilter(){

		

		jQuery.ajax({

		  type: 'POST',

		  url: 'https://contractworkplaces.com/en/wp-admin/admin-ajax.php',

		  data: {

		  action: 'GenerarFiltro',

		  },

			  success: function(data, textStatus, XMLHttpRequest){
			 

			  jQuery("#FilterContainer").html('');

			  jQuery("#FilterContainer").append(data);

		  },

			  error: function(MLHttpRequest, textStatus, errorThrown){

			 // alert(errorThrown);

		  }

		});

		

	}