
$(document).ready(function() { main() });


function main() {


// ------------------ ajax search initializing -------------------------------------------------------

// cancel form submission with return false
$("#contactform").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 areacode   = $("#areacode").val();
	var phone      = $("#phone").val();
	var besttime   = $("#besttime").val();
	var comments   = $("#comments").val();

        var datastring  = "user=" + user + "&email=" + email + "&areacode=" + areacode + "&phone=" + phone + "&besttime=" + besttime + "&comments=" + comments;

	jQuery.ajax({
		type: "POST",
		url: "files/contactusform.php",
		dataType: "html",
		data: datastring,

		success: function(response){ $('#contactform').css('display', 'none');
			                     $('#appendresponse').html('').append(response);
		},
		error: function(){ alert("Error occured during Ajax request..."); }
	});
}
// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------





















