$(document).ready(function(){
	//standard AJAX mail form submission (requires mail2_plus.php, and captcha)
	//add form name to selector for submit event, the rest will take care of itself!
	$("input[type=submit]").removeAttr("disabled");
	$("#kayak_form").submit(function(e){
		e.preventDefault();
		var form = $(this);
		var btn = $(this).find("input[type=submit]");
		btn.attr("disabled","disabled");
		$.post("ajax/kayak-submit.php",form.serialize(),function(data){
			var err = data.split("|");
			if (err[0] == "error") {
				alert(err[1]);
			} else {
				window.location = "thankyou.php";
			}
			btn.removeAttr("disabled");
		});
	});
	
	$(".del_signup").live("click",function(e){
		e.preventDefault();
		var container = $(this).parents("tr");
		var id = extractId($(this).attr("id"));
		var doit = confirm("Are you sure you want to delete this signup entry?");
		if (doit == true) {
			$.post("ajax/delete-signup.php",{"id":id},function(data){
				var err = data.split("|");
				if (err[0] == "error") {
					alert(err[1]);
				} else {
					container.detach();
				}
			});
		}
	});
});

function extractId(id){
	newid = id.split("_");
	return newid[1];
}
