var aua = {
		
	registration : {
		message: function(data)
		{
			if ($('#registration-form form input[type="submit"]').parent('p').find('span').length == 0)
				$('#registration-form form input[type="submit"]').parent('p').prepend('<span style="float:left; line-height: 40px; text-transform: none;"></span>');
			
			$('#registration-form form input[type="submit"]').parent('p').find('span').html(data);
		},
		
		submit: function(errorMsg)
		{
			var _data = "";
						
			aua.registration.message('<img src="' + SITE_LAYOUT_URL + 'images/elements/loader.gif' + '" />');
			
			$('#registration-form form input[type!="submit"], #registration-form form textarea').each(function () {
				if ($(this).attr('name').length > 0)
					_data += "&" + $(this).attr('name') + "=" + $(this).val();
			});			
			
			$.ajax({
				url: SITE_URL + 'ajax/registo/submeter/',
				type: 'POST',
				dataType: 'json',
				data: _data.substring(1),
				success: function(data) {					
					aua.registration.message('&raquo; ' + data[1]);
					
					if (data[0] == true)
					{
						$(':input','#registration-form form')
						 .not(':button, :submit, :reset, :hidden')
						 .val('')
						 .removeAttr('checked')
						 .removeAttr('selected');
					}
				},
				error: function(data) {
					console.log(data);
					aua.registration.message('&raquo; ' + errorMsg);
				}
			});
			
			return false;
		}
	}
}
