$(function() {
	$('form input[type="submit"]').click( function() {
		var form = $(this).parents('form');
		var postData = form.serializeNoViewState();
		var postUrl = form.attr('action');
		$.ajax({
			type: 'GET',
			url: postUrl,
			data: postData,
			contentType: 'text/plain',
			beforeSend: function() {
				$('.loader', form).toggleClass('hide', false);
			},
			success: function(response) {
				// We ned to exmaine the response from the server here first to see if the request was processed okay. For now just display the success element.
				if (response == 'ok') {
					$('.success', form).toggleClass('hide', false);
				} else {
					$('.error', form).show();
				}
			},
			complete: function() {
				$('.loader', form).toggleClass('hide', true);
			}
		});
		return false;
	});
});
