function submitBlog() {
	$('blog_text').value = $('blog_text').value.strip();
	if ( $('blog_text').value.blank() ) {
		alert('You must enter blog text');
		return;
	}
	$('add_form').request({
		onComplete: function() {
			new Ajax.Updater('blog_entries',HOME_DIR+'blogs/all_blogs');
		},
		on404: function() {
			alert('Unable to submit blog');
		}
	});
}
var blogLoadMask = null;
function deleteBlogComment(blog_id,comment_id) {
	blogLoadMask = new Ext.LoadMask('blog_entries');
	blogLoadMask.show();
	new Ajax.Request(HOME_DIR+'blog_comments/delete/'+comment_id,{
		onComplete: function(t) {
			if ( ! t.responseJSON.success ) {
				blogLoadMask.hide();
				Ext.Msg.alert('Error',t.responseJSON.error.reasons);
			}
			else {
				new Ajax.Updater('blog_comments',HOME_DIR+'blog_comments/profile_list/'+blog_id,{
					onSuccess: function() {
						blogLoadMask.hide();
					}
				});
				new Ajax.Updater('blog_entry',HOME_DIR+'blogs/blog_entry/'+blog_id);
			}
		},
		onFailure: function(t) {
			blogLoadMask.hide();
			Ext.Msg.alert('Error','Unable to process your request');
		},
		evalJSON: true,
		sanitizeJSON: true
	});
}
function addBlogComment(blog_id) {
	if ( blogLoadMask == null ) {
		blogLoadMask = new Ext.LoadMask('blog_entries');
	}
	blogLoadMask.show();
	$('add_blog_comment').request({
		onComplete: function(t) {
			if ( t.responseJSON.success ) {
				new Ajax.Updater('blog_comments',HOME_DIR+'blog_comments/profile_list/'+blog_id,{
					onSuccess: function() {
						blogLoadMask.hide();
					}
				});
				new Ajax.Updater('blog_entry',HOME_DIR+'blogs/blog_entry/'+blog_id);
				$('comment_text').value = '';
			}
			else {
				Ext.Msg.alert('Error',t.responseJSON.error.reasons);
				blogLoadMask.hide();
			}
		},
		on404: function() {
			Ext.Msg.alert('Error','Not Found!');
			blogLoadMask.hide();
		},
		onFailure: function() {
			Ext.Msg.alert('Error','Failed!');
			blogLoadMask.hide();
		},
		evalJSON: true,
		sanitizeJSON: true
	});
}
function markBlogCommentAsSpam(blog_id,comment_id) {
	blogLoadMask = new Ext.LoadMask('blog_entries');
	blogLoadMask.show();
	new Ajax.Request(HOME_DIR+'blog_comments/spam/'+comment_id,{
		onComplete: function(t) {
			if ( ! t.responseJSON.success ) {
				blogLoadMask.hide();
				Ext.Msg.alert('Error',t.responseJSON.error.reasons);
			}
			else {
				$('spamlink_'+blog_id+'_'+comment_id).hide();
				blogLoadMask.hide();
			}
		},
		onFailure: function(t) {
			blogLoadMask.hide();
			Ext.Msg.alert('Error','Unable to process your request');
		},
		evalJSON: true,
		sanitizeJSON: true
	});
}
function markBlogAsSpam(blog_id) {
	blogLoadMask = new Ext.LoadMask('blog_entries');
	blogLoadMask.show();
	new Ajax.Request(HOME_DIR+'blogs/spam/'+blog_id,{
		onComplete: function(t) {
			if ( ! t.responseJSON.success ) {
				blogLoadMask.hide();
				Ext.Msg.alert('Error',t.responseJSON.error.reasons);
			}
			else {
				$('spamlink_'+blog_id).hide();
				blogLoadMask.hide();
			}
		},
		onFailure: function(t) {
			blogLoadMask.hide();
			Ext.Msg.alert('Error','Unable to process your request');
		},
		evalJSON: true,
		sanitizeJSON: true
	});
}