$(function() {
	$('#recent_form').submit(function() {
		var inputs = [];
		$(':input', this).each(function() {
			if($(this).attr("checked") && !($(this).attr("disabled")))  {
			inputs.push(this.name + '=' + escape(this.value));
			}
		})
	  
		jQuery.ajax({
			data: inputs.join(unescape('%26')),
			url: this.action,
			timeout: 2000,
			error: function() {$("p.status").html("Error. There was a problem, please try again.").show();},
			success: function(r) { 
				if (r == "Success=true") {
					$("p.status").html("Checked item(s) added to your trip planner.").show();
					$(':input', this).each(function() {
						if($(this).attr("checked"))  {
							$(this).attr({disabled: "disabled",value: ""});						
						}
					});
				}
				else if (r == "Success=false") {$("p.status").html("Submission failed. Please ensure that you have checked an item and try again.").show(20);}
			}
		})
		return false;
	})
})
