		window.addEvent('domready', function(e) {
				//add onSubmit event to each form
				$('form').addEvent('submit', function(e) {
		  	 		//Prevents the default submit event from loading a new page.
					e.stop();

					var errors = 0;
					//validate all required fields
					$('form').getElements('.validate').each(function(input) {
						if(input.value == '') { 
							input.addClass('error').morph({ 'border-color': '#f00', 'background-color': '#ffebe8' });
							errors++; 
						}
						else if(input.hasClass('error') && input.value != '') { 
							input.removeClass('error').morph({ 'border-color': '#ccc', 'background-color': '#fff' });
						}
					});
					if(errors) {
						$('log_res').empty();
						$('log_res').set('html','<h3>Please fill in required fields identified in red</h3>' );
						return errors;
					}
					else {
						//Empty the log and show the spinning indicator.
						var log = $('log_res').empty().addClass('ajax-loading');
						//Set the options of the form's Request handler. 
						//("this" refers to the $('myForm') element).
						this.set('send', {onComplete: function(response) { 
						log.removeClass('ajax-loading');
						$('single_content').empty();
						$('single_content').set('html',response);
						//log.set('html', response);
						}});
						//Send the form.
						this.send();	
					}
			});
		});