// JavaScript Document

function editcomments(){
		$('.comment').wrap('<a class="delcomment" onclick="deletecomment($(this).children(0).attr(\'id\'))" />)');
	}
	
function deletecomment(comment){
	var answer = confirm("Really delete this comment?")
	if (answer){
		$.post('../admin/blogcontroller.php', {commentid: comment, func: 'delcomment'},
		function(data){
			$('#'+comment).parent().fadeOut(
			function(){
					('#'+comment).parent().remove();	
			});
		});
	}
	else{
		
	}
}

function deleteblog(blogid){
	var answer = confirm("Really delete this blog?")
	if (answer){
		$.post('../admin/blogcontroller.php', {blogid: blogid, func: 'delblog'},
		function(data){
			$('.blogtext').fadeOut(
				function(){
					$('.blogtext').html('Blog Deleted');
					$('.blogtext').fadeIn();
				}
			)
		});
	}
	else{
		
	}
}

function editblog(blogid){
	blogtitle = $('#blogtitle').val();
	blogtext = $('#blogtext').val();
	$.post('../admin/blogcontroller.php', {blogid: blogid, blogtext:blogtext, blogtitle:blogtitle, func: 'editblog'},
		function(data){
			$('#addblog').fadeOut();
			$('.blogtext').fadeOut(
				function(){
					$('.blogtext').html(data);
					$('.blogtext').fadeIn();
				}
			)
		});
}