jQuery(document).ready( function($) {
	
	var read_message = mark_as_read_js.read_message;
	var unread_message = mark_as_read_js.unread_message;

	$(".mar_mark_as_read").click( function() {
		var post_id = $(this).attr('rel');
		var data = {
			action: 'mark_post_as_read',
			post_read: post_id
		};
		$.post(mark_as_read_js.ajaxurl, data, function(response) {
			if(mark_as_read_js.show_alerts == '1') {
				alert(read_message);
			}
			$('.mar_read_control_'+post_id).toggle();
	 	});
	 	return false;
	});
	$(".mar_mark_as_unread").click( function() {
		
		if(mark_as_read_js.show_alerts == '1') {
			if(confirm(unread_message)) {
				var post_id = $(this).attr('rel');
				var data = {
					action: 'mark_post_as_unread',
					del_post_id: post_id
				};
				$.post(mark_as_read_js.ajaxurl, data, function(response) {
					$('.mar_read_control_'+post_id).toggle();				
				});
			}
		} else {
			var post_id = $(this).attr('rel');
			var data = {
				action: 'mark_post_as_unread',
				del_post_id: post_id
			};
			$.post(mark_as_read_js.ajaxurl, data, function(response) {
				$('.mar_read_control_'+post_id).toggle();				
			});
		}
	 	return false;
	});
});