//送出修改內容
function mod_content_form(){
	answer = confirm("你確定要修改嗎?");
	if(answer){
		document.modForm.content.value = $("#output").html();
		document.modForm.submit();
	}
}

//儲存內容
function saveContent(mode){
	if(mode == "ok"){
		$("#title").html(document.getElementById('input').value);
		var tmpHtml = document.getElementById("iframe").contentWindow.document.body.innerHTML;
		tmpHtml = tmpHtml.replace("<P>",""); // 去開頭P
		tmpHtml = tmpHtml.replace("</P>",""); // 去結尾P
		$("#content").html(tmpHtml);
	}
	$("#input").hide();
	$("#output").show();
	$("#modButton").show();
	document.getElementById("iframe").contentWindow.document.designMode='off'; //iframe設定成不可編輯
	$("#edit").hide();
}


//修改內容
function modContent(){
	$("#output").hide();
	$("#modButton").hide();
	$("#input").show();
	document.getElementById("input").value = $("#title").html();
    $("#edit").show();
    document.getElementById("iframe").contentWindow.document.designMode='on'; //iframe設定成可編輯
    setTimeout("document.getElementById('iframe').contentWindow.document.body.innerHTML = document.getElementById('content').innerText",200); //停200豪秒再把html丟入
	setTimeout("document.getElementById('iframe').contentWindow.document.body.style.backgroundColor='#373428'",200);
	setTimeout("document.getElementById('iframe').contentWindow.document.body.style.color='#FFF'",200);
	setTimeout("document.getElementById('iframe').contentWindow.document.body.style.fontSize='10pt'",200);
	setTimeout("document.getElementById('iframe').contentWindow.document.onkeypress = cancelEnter;",200);
}

//把Enter鍵鎖住避免出現不必要的Tag
function cancelEnter(){
	if(document.getElementById('iframe').contentWindow.event.keyCode==13){
		return false; 
		//setTimeout("changeContent();",200);
	}
}
/*
function changeContent(){
	text = document.getElementById('iframe').contentWindow.document.body.innerHTML;
		alert(text);
		text = text.replace('<P>&nbsp;</P>','');
		text = text.replace('<P>','');
		text = text.replace('</P>','<BR>');
		document.getElementById('iframe').contentWindow.document.body.innerHTML = text;
		alert(text);
}
*/