window.addEvent('domready', function() {
	
	/*---Add Category Form---*/
	$('registrySearchForm').addEvent('submit', function(e) {
	//Prevents the default submit event from loading a new page.
	new Event(e).stop();
	//e.stop();
	//Empty the log and show the spinning indicator.
	var log = $('log_res_Search').empty().addClass('ajax-loading');
	//Set the options of the form's Request handler. 
	//("this" refers to the $('addCatForm') 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);
			/*parent.tb_remove();
			parent.location.reload(1);*/
			//redirect
			var searchString = status.message
			window.location = searchString;
		}
		else
		{
			//display the Errors
			log.set('html', status.message)
			
		}
		
	}});
	//Send the form.
	this.send();
	});
	
});
