$(function() {
   // Home page flters.
   /*$("select#recent-entries-filter").change(function() {
		filter_url = "/entries/recent_filter/" + $(this).val();
		$("div.entry-results div#recent-results").html('<div class="loader"><img src="/images/loader.gif" /></div>');
		$("div.entry-results div#recent-results").load(filter_url);
   });

   $("select#upcoming-entries-filter").change(function() {
		filter_url = "/entries/upcoming_filter/" + $(this).val();
		$("div.entry-results div#upcoming-results").html('<div class="loader"><img src="/images/loader.gif" /></div>');
		$("div.entry-results div#upcoming-results").load(filter_url);
   });*/
   
	$("input#view-all-upcoming-entries").click(function(event) {
		
		filter_url = "/entries/upcoming_get_all/";
		$("div.entry-results").html('<div class="loader"><img src="/images/loader.gif" /></div>');
   		$("div.entry-results").load(filter_url);
   		$("p.pagination").show();
		
		event.preventDefault();	
	});
   
   $("input#optional-search-filter-upcoming-entries").click(function(event) {
   		
		var filter_url = "/entries/upcoming_filter/";
		var data = {};
		
		data['country'] = $("select#optional-country").val();
		data['location'] = $("input#optional-location").val();
		data['keyword'] = $("input#optional-keyword").val();
		data['entry-type'] = $("select#upcoming-entries-filter").val();
		
   		$("div.entry-results").html('<div class="loader"><img src="/images/loader.gif" /></div>');
   		$("div.entry-results").load(filter_url, data);
   		$("p.pagination").hide();
		
		event.preventDefault();
   });
   
   $("input#view-all-recent-entries").click(function(event) {
		
		var filter_url = "/entries/recent_get_all/";
		$("div.entry-results").html('<div class="loader"><img src="/images/loader.gif" /></div>');
   		$("div.entry-results").load(filter_url);
   		$("p.pagination").show();
		
		event.preventDefault();	
	});
   
    $("input#optional-search-filter-recent-entries").click(function(event) {
   		
		var filter_url = "/entries/recent_filter/";
		var data = {};
		
		data['country'] = $("select#optional-country").val();
		data['location'] = $("input#optional-location").val();
		data['keyword'] = $("input#optional-keyword").val();
		data['entry-type'] = $("select#recent-entries-filter").val();
		
   		$("div.entry-results").html('<div class="loader"><img src="/images/loader.gif" /></div>');
   		$("div.entry-results").load(filter_url, data);
   		$("p.pagination").hide();
		
		event.preventDefault();
   });

	$("select#recent-entries-filter").change(function(event) {
		var filter_url = "/entries/recent_filter/";
		var data = {};

		data['country'] = $("select#optional-country").val();
		data['location'] = $("input#optional-location").val();
		data['keyword'] = $("input#optional-keyword").val();
		data['entry-type'] = $("select#recent-entries-filter").val();

   		$("div.entry-results").html('<div class="loader"><img src="/images/loader.gif" /></div>');
   		$("div.entry-results").load(filter_url, data);
   		$("p.pagination").hide();

		event.preventDefault();
	});
	
	$("select#optional-country").change(function(event) {
		var filter_url = "/entries/recent_filter/";
		var data = {};
		
		data['country'] = $("select#optional-country").val();
		data['location'] = $("input#optional-location").val();
		data['keyword'] = $("input#optional-keyword").val();
		data['entry-type'] = $("select#recent-entries-filter").val();
		
   		$("div.entry-results").html('<div class="loader"><img src="/images/loader.gif" /></div>');
   		$("div.entry-results").load(filter_url, data);
   		$("p.pagination").hide();
		
		event.preventDefault();
	});

	$("select#upcoming-entries-filter").change(function(event) {
		var filter_url = "/entries/upcoming_filter/";
		var data = {};

		data['country'] = $("select#optional-country").val();
		data['location'] = $("input#optional-location").val();
		data['keyword'] = $("input#optional-keyword").val();
		data['entry-type'] = $("select#upcoming-entries-filter").val();

   		$("div.entry-results").html('<div class="loader"><img src="/images/loader.gif" /></div>');
   		$("div.entry-results").load(filter_url, data);
   		$("p.pagination").hide();

		event.preventDefault();
	});

});
