$(document).ready(function(){
	news_posting();
	$('#add_email_news_posting').click(function(){
		$('#news_posting_form').submit();
	});
});

function news_posting()
{
	var options = {
		type:			'POST',
		success:		post_submit_news_posting,
		url:			presets.siteURL() + 'news_posting',
		dataType:		'json'
	};
	
	$('#news_posting_form').submit(function(){
	    $(this).ajaxSubmit(options); 
	    return false;
	});
}

function post_submit_news_posting(json)
{
	if(!json.errors){
		jMessage(json.message, json.message_title, function(result){
			if(result) $('input[name="email_news_posting"]').val('');
		});		
	}else{
		jError(json.message, json.message_title);
	}
}
