window.addEvent('domready', function() {
	
	/*Register Form*/
	$('registerForm').addEvent('submit', function(e) {
	//Prevents the default submit event from loading a new page.
	new Event(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 $('addNewsForm') element).
	this.set('send', {onComplete: function(response) { 
		log.removeClass('ajax-loading');
		//get vars
		var status = JSON.decode(response);
		//validate that all proceed as planned CODE: 1 = TRUE
		if (status.code == 1){
			//Display a message of congratulations
			log.set('html', status.message);
			//redirect
			window.location = 'index.php?page=account&new=1';
		}
		else
		{
			//display the Errors
			log.set('html', status.message);
		}
		
	}});
	//Send the form.
	this.send();
	});
	
});
