/*
Credits: Bit Repository
URL: http://www.bitrepository.com/web-programming/ajax/login-form.html
*/

// Preload Images
img1 = new Image(16, 16);  
img1.src="images/spinner.gif";

img2 = new Image(190, 13);  
img2.src="images/loader-bar.gif";

	window.addEvent('domready', function() {

	$('login').addEvent('submit', function(e) {
		// Prevents the default submit event from loading a new page.
		e.stop();

		// Show the spinning indicator when pressing the submit button...
		$('ajax_loading').setStyle('display','block');

		// Hide the submit button while processing...
		$('submit').setStyle('display','none');

		// Set the options of the form's Request handler.
		// ("this" refers to the $('login') element).
		this.set('send', { onComplete: function(response) {
			$('ajax_loading').setStyle('display','none');

	if(response == 'OK')
			{
              $('status').set('html', '<div id="logged_in">Username and password correct!<br /> <br />' +
              '<img align="absmiddle" src="images/loader-bar.gif">' +
              '<br /><br /> Please wait while we log you in...</div>');

			setTimeout('updateLogin()', 3000);
			}
			else
			{
			  $('login_response').set('html', response);
			  // Show the login button
			  $('submit').setStyle('display','block');
			}
		}});

		// Send the form.
		this.send();
	});


	$('registershort').addEvent('submit', function(e) {
		// Prevents the default submit event from loading a new page.
		e.stop();

		// Show the spinning indicator when pressing the submit button...
		$('register_ajax_loading').setStyle('display','block');

		// Hide the submit button while processing...
		$('register_submit').setStyle('display','none');

		// Set the options of the form's Request handler.
		// ("this" refers to the $('login') element).
		this.set('send', { onComplete: function(registerresponse) {
			$('register_ajax_loading').setStyle('display','none');
var register_response = registerresponse;
	if(register_response == 'yes')
			{
              $('register_status').set('html', '<div id="registered">Thankyou for registering!<br /> <br />' +
              '<img align="absmiddle" src="images/loader-bar.gif">' +
              '<br /><br /> Please wait while we submit your details...</div>');

			setTimeout('updateRegistration()', 3000);
			}
			else
			{
			  $('registration_response').set('html', registerresponse);
			  // Show the login button
			  $('register_submit').setStyle('display','block');
			}
		}});

		// Send the form.
		this.send();
	});



	
	
	
	
	
	$('booking_form').addEvent('submit', function(e) {
		// Prevents the default submit event from loading a new page.
		e.stop();

		// Show the spinning indicator when pressing the submit button...
		$('booking_ajax_loading').setStyle('display','block');

		// Hide the submit button while processing...
		$('booking_submit').setStyle('display','none');

		// Set the options of the form's Request handler.
		// ("this" refers to the $('login') element).
		this.set('send', { onComplete: function(bookingresponse) {
			$('booking_ajax_loading').setStyle('display','none');
var booking_response = bookingresponse;
	if(booking_response == 'yes')
			{
              $('booking_status').set('html', '<div id="registered">Thankyou for enquiring for a booking! We will get back to you as soon as possible.<br /> <br />' +
              '<img align="absmiddle" src="images/loader-bar.gif">' +
              '<br /><br /> Please wait while we submit your details...</div>');

			}
			else
			{
			  $('booking_response').set('html', bookingresponse);
			  // Show the login button
			  $('submit').setStyle('display','block');
			}
		}});

		// Send the form.
		this.send();
	});




function go_to_private_page()
{
window.location = 'index.php'; // Members Area
}
										 });
