window.addEvent('domready', function(){
	$('contact_form').addEvent('submit', function(e) {
		/**
	 	* Prevent the submit event
	 	*/
		new Event(e).stop();
 
		/**
	 	* This empties the log and shows the spinning indicator
	 	*/
		var response = $('form_response').empty();
		
		new Fx.Slide('copyright').hide();
		new Fx.Slide('form_image').hide();
		new Fx.Slide('contact_form', {duration: 1500}).slideOut();
		
 
		/**
	 	* send takes care of encoding and returns the Ajax instance.
	 	* onComplete removes the spinner from the log.
	 	*/
		this.send({
			update: response,
			onComplete: function() {
				new Fx.Slide('form_response', {duration: 1500}).slideIn();
				new Fx.Slide('copyright', {duration: 1500}).slideIn();
			}
		});
	});
});

/*<%= form_remote_tag :url => { :action => 'submit' }, :html => {:id => "contact_form"},
	:loading => update_page { |page| page[:loading].show;
		 						     page[:submit_div].replace "<div id=\"sending-email\">Sending email</p>"
							},
	:complete => update_page { |page| page[:loading].hide;
									  page[:copyright].hide;
		 							  page[:contact_form].visual_effect :drop_out, :duration => 1;
									  page[:form_response].hide;
		 							  page[:form_response].visual_effect :appear, :duration => 2, :queue => 'end';
									  page[:copyright].visual_effect :appear, :duration => 0.1, :queue => 'end';
		
		 							  
		
		
		 },
	:failure => update_page { |page| page[:form_response].replace_html "<h3 class=\"error\">An error occurred with your submission. Please try again later.</h3>" } %>
	*/