function sendForm(formID, action){
	if(!action)
		action = "actions.php";
	$('#result').html('');
	$('#' + formID).addClass('loading');
	$.post(action, $("#" + formID).serialize(), function(data){
			$('#'+formID).removeClass('loading');
			switch(jQuery.trim(data)){
				case 'created':
					$('#' + formID).html('<div class="success">Thank you!<br>Your request was successfully submitted.</div>');
					break;
				case 'exists':
					$('#result').html('<div class="error_mess">Error: this username already exists!</div>');
					break;
				case 'empty_user_login':
					$('#result').html('<div class="error_mess">Error: cannot create a user with an empty user name!</div>');
					break;
				case 'existing_user_email':
					$('#result').html('<div class="error_mess">Error: this email address already exists!</div>');
					break;	
				
				default:
					$('#result').html('<div class="error_mess">An error occurred. Error code: ' + data + '</div>');
					break;
			}
	});
	
	return false;
}

function sendXML(){
	var is_valid;
	is_valid = $("#new-user").valid();
	if( !is_valid){
		return false;
	}
	$('#result').html('');
	$('#wrapper').addClass('overlay');
	$('#loading').addClass('loading');
	$.post('/actions.php', $("#new-user").serialize(), function(data){
		$("#loading").removeClass('loading');
		$("#wrapper").removeClass('overlay');
		var out = jQuery.parseJSON(data);
		var resp	= out.Response.Result;
		if( resp == 'R' ){
			alert('rejected: ' +  out.Response.RejectionReason);
		}else if( resp == 'A'){
			window.location = out.Response.RedirectUrl;
		}else if( resp == 'bad'){
			$('#result').html(out.errors);
		}else{
			alert( out.Response.RejectionReason );
		}
		
		//$('#result').html(data);
	});
}
