window.addEvent('domready', function() {
	// You can skip the following two lines of code. We need them to make sure demos
	// are runnable on MooTools demos web page.
	if (!window.demo_path) window.demo_path = '';
	var demo_path = window.demo_path;
	// --
	$('newsLetterForm').addEvent('submit', function(e) {
		//Prevents the default submit event from loading a new page.
		e.stop();
		//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');
			log.removeClass('ajax-good-result');
			log.removeClass('ajax-bad-result');								
			log.set('html', response);
			
			if(response=='You are now Subscribed!'){
					log.addClass('ajax-good-result');
			}
			else if((response=='Please enter email address!')||(response=='Address already Subscribed!')||(response=='Invalid email address!')){
					log.addClass('ajax-bad-result');
			}			
		},					
		onFailure: function(response){
				log.addClass('ajax-bad-result');
				log.set('html', 'Error in address');
		}			
		});
		//Send the form.
		this.send();
	});
});