function getEditor()
{
	var name = 'Viết bình luận';
	tinyMCE.init({
		mode : "exact",
		elements : "txt_write_comment",
		theme : "advanced",
		entities : "",
		plugins : "inlinepopups,emotions,eBizImage,eBizIcon",
		theme_advanced_buttons1 : "mybutton,bold,italic,underline,justifyleft,justifycenter,justifyright,justifyfull,forecolor,emotions,eBizIcon,fontselect,fontsizeselect",
		theme_advanced_buttons2 : "",
		theme_advanced_buttons3 : "",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "none",
		theme_advanced_resizing : false,
		setup: function(ed) {
			ed.addButton('mybutton', {
				label : name,
				onclick : function() {
				}
			});
		}
	});
}
function delBlog(bid, title, picture)
{
	if( confirm('Bạn đồng ý xóa bài viết này không?') )
	{
		ajax_delBlog(bid, title, picture, 0);
	}
}
function saveComment()
{
	var content = tinyMCE.get('txt_write_comment').getContent();
	if( content != '' )
	{		
		document.frmpostcomment.content.value = content;
		document.frmpostcomment.submit();
	}
	else
	{
		alert('Bạn chưa nhập lời bình luận!');
	}
}
function delComment(bid, cid)
{
	if( confirm('Bạn đồng ý xóa bình luận này không?') )
	{
		ajax_delComment(bid, cid);
	}
}
function incNumComment()
{
	var num = parseInt(document.getElementById('spanNumComment').innerHTML) + 1;
	document.getElementById('spanNumComment').innerHTML = num;
	document.getElementById('numcomment').innerHTML = num;
}
function decNumComment()
{
	var num = parseInt(document.getElementById('spanNumComment').innerHTML) - 1;
	document.getElementById('spanNumComment').innerHTML = (num >= 0 ? num : 0);
	document.getElementById('numcomment').innerHTML = (num >= 0 ? num : 0);
}
function insIcon(key)
{
	if( document.frmpostcomment.comment_content.value == 'Hãy cho mọi người biết ý kiến của bạn đi nào!' ) document.frmpostcomment.comment_content.value = '';
	insertAtCursor(document.frmpostcomment.comment_content, key);
}
$(document).ready(function() {
	cafe_setCookie('page', '1--'+window.location.href);
	showComment(0);
	if( document.getElementById('id1').value == 1 )	$.scrollTo('#ym_vid_binhluan', 700);
});
function showComment(step)
{
	var num = parseInt(document.getElementById('spanNumComment').innerHTML);
	if( num > 0 )
	{
		var bid = document.getElementById('bid').value;
		$.getJSON
		(
			BLOG_HOST + 'ajax/mypage_showcomment/' + username + '/' + bid + '/' + step + '/?jsoncallback=?',
			function(data)
			{
				var result = data.html;
				if( result )				
					$("#list_bluan").html(result);				
				else
					$("#list_bluan").html('');
				
			}
		);
	}
	else
	{
		$("#list_bluan").html('');
	}
}
function showBlogSameSubjectId()
{
	if( document.getElementById('ym_blogsamesubject').innerHTML == '' )
	{
		ajax_showBlogSameSubjectId(document.getElementById('sid').value, document.getElementById('bid').value);
	}
}
function showBlogOther()
{
	if( document.getElementById('ym_blogother').innerHTML == '' )
	{
		ajax_showBlogOther(document.getElementById('bid').value);
	}
}