
$(document).ready(function() { main() });


function main() {


// ------------------ ajax search initializing -------------------------------------------------------

// cancel form submission with return false
$("#reservationsform").submit(function() { return false; });

// call some function to handle Ajax request
$("#submitbutton").click(function(){ ajaxFormRequest(); })

// ---------------------------------------------------------------------------------------------------












}
// ---------------------------------------------------------------------------------------------------------------------------------------------------------
// --------------------------------------- end main function -----------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------------------------------------------









// ------------------------ ajax form request -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

function ajaxFormRequest(){

	var user       = $("#user").val();
	var email      = $("#email").val();
	var phone      = $("#phone").val();
	var besttime   = $("#besttime").val();
	var month      = $("#month").val();
	var dayofmonth = $("#dayofmonth").val();
	var ampm       = $("#ampm").val();
	var timeofday  = $("#timeofday").val();
	var guests     = $("#guests").val();
	var comments   = $("#comments").val();
		
        var datastring  = "user=" + user + "&email=" + email + "&phone=" + phone + "&besttime=" + besttime + "&month=" + month + "&dayofmonth=" + dayofmonth + "&ampm=" + ampm + "&timeofday=" + timeofday + "&guests=" + guests + "&comments=" + comments;

	jQuery.ajax({
		type: "POST",
		url: "files/reservationsform.php",
		dataType: "html",
		data: datastring,
		success: function(response){ $('#reservationsform').css('display', 'none');
			                     $('#appendresponse').html('').append(response);
		},
		error: function(){ alert("Error occured during Ajax request..."); }
	});
}
// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------





















