function init(){
	var editor = FCKeditorAPI.GetInstance('content'); 
	document.getElementById('count').value=editor.GetHTML().length;
}
function new_post(){
	window.open('post.php','new_post','width=650,height=500,scrollbars=no');
}
function reply(msg){
	window.open('post.php?post='+msg,'reply','width=650,height=500,scrollbars=no');
}
function smiley(smiley)
{
	var oEditor = FCKeditorAPI.GetInstance('content');
		
	if ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG )
	{
		oEditor.InsertHtml("<img src=http://italy.paoyuan.org/guestbook/images/"+ smiley +" alt= />") ;
	}
	else
		alert( 'You must be on WYSIWYG mode!' ) ;
}
function check(){ 
	var editor = FCKeditorAPI.GetInstance('content');		
	if (document.getElementById('author').value.length==0){
		alert("Please enter your nickname!!");
		document.getElementById('author').focus();
		return false;
	} else if (document.getElementById('code').value.length==0){
		alert("Please enter the authorization code!!");
		document.getElementById('code').focus();
		return false;
	} else if (editor.GetHTML().length==0){
		alert("Please enter the message!!");
		editor.Focus();
		return false;
	} else {
		return true;
	}
 }
 
function rand(min,max){
	return (min + Math.floor( Math.random() * (max - min + 1) ));
}

function auth_code(){
	document.getElementById('auth_code').src='';
	document.getElementById('auth_code').src='auth_img.php?'+rand(1,9999);
}
