function postsumit_one(form)
{
	var cid = form.cid.options;
	if (cid[cid.selectedIndex].value == '')
	{
		alert('請選擇合適的分類');
		return false;
	}
}
function insertatt(content){
	switch (editormod)
	{
		case '0':
		case '1':
			var txtarea = document.getElementById('posteditor_textarea');
			if (txtarea.createTextRange && txtarea.caretPos) {
				var caretPos = txtarea.caretPos;
				caretPos.text = content;
				txtarea.focus();
			} else {
				txtarea.value  += content;
				txtarea.focus();
			}
			break;
		case '2':
			var oEditor = FCKeditorAPI.GetInstance('content');
			if ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG ) {
				oEditor.InsertHtml(content) ;
			} else {
				alert('請先轉換到所見即所得模式') ;
			}
			break;
		default:
			alert('編輯器模式錯誤');
	}
}
function delatt(id) {
	$.ajax({
		type: 'GET',
		url: pb_url+'include/upload.inc.php',
		dataType: 'json',
		data: 'action=del&id=' + id + '&fsid=' + fsid + '&random=' + Math.random(),
		error: function(var1,var2,var3)
		{
			alert('附件刪除錯誤，請檢查網絡連接。') ;
		},
		success: function(data)
		{
			document.getElementById('uploaded').removeChild(document.getElementById('attachment_'+data));
		}
	});
}
function supdelatt(id) {
	$.ajax({
		type: 'GET',
		url: pb_url+'manage.php',
		dataType: 'html',
		data: 'action=del&type=attachment&aid=' + id + '&random=' + Math.random(),
		error: function(var1,var2,var3)
		{
			alert('附件刪除錯誤，請檢查網絡連接。') ;
		},
		success: function(data)
		{
			if (data)
			{
				document.getElementById('uploaded').removeChild(document.getElementById('e_attachment_'+id));
			}
			else
			{
				alert('附件刪除錯誤，可能您無刪除權限。') ;
			}
		}
	});
}
var oldtopicimg = '';
function changetopicimg(type)
{
	var topicimg = $('#topicimg');
	if (type == 'edit')
	{
		oldtopicimg = topicimg.html();
		topicimg.empty().html('<input type="file" id="topicimg" name="topicimg" />[<span onclick="changetopicimg(\'cancel\')">'+topicimg_cancel+'</span>]')
	}
	else if (type == 'cancel')
	{
		topicimg.empty().html(oldtopicimg);
	}
	return;
}
function storeCaret(textEl) {
	if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}
