// Preload Images
img1 = new Image(16, 16);  
img1.src="/img/spinner.gif";

img2 = new Image(220, 19);  
img2.src="/img/loader-bar.gif";

img3 = new Image(16, 16);  
img3.src="/img/exclamation.gif";

	window.addEvent('domready', function() {

	$('contact_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...
		$('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 $('contact_form') element).
		this.set('send', { onComplete: function(response) {
												
			$('ajax_loading').setStyle('display','none');

	        if(response == 'OK')
			{
              $('status').set('html', '<div id="finished">Thank You.<br />' +
              '<img align="absmiddle" src="/img/loader-bar.gif" style="border:none; margin:0; padding:0;" />' +
              '<br /> Please wait while add your certificate to the shopping cart...</div>');

			setTimeout('finished()', 1500);
			}
			else
			{
			  $('login_response').set('html', response);
			  // Show the login button
			  $('submit').setStyle('display','block');
			}
			
		}});

		// Send the form.
		this.send();
	});
});

function finished()
{
	window.location = "http://www.premiermedspa.com/cart.php";
	/*$('status').set('html', '<div id="finished" style="text-align:left; font-size:14px; font-weight:normal;">Thank You. Your product has been added to your <a href="cart.php">shopping cart</a>.</div>');*/
}