﻿//全局变量，用于生成URL最后的time时间戳
var date = new Date();
//分页
function UserPublishDraftMaint230_ButtonSubmit(nextPage, linkURL)
{
	if(nextPage=="")
		return;
	strURI = linkURL+"?UserPublishDraftMaint230_NextPage=" + nextPage;
	self.location = strURI ;
}

//页面跳转
function UserPublishDraftMaint230_buttonGo(frm,linkURL){
	var pattern = /^[\-0-9]*$/;
	var pageNumber=trim(frm.pageText.value);
	if(pageNumber=="")
	{
		alert("请输入页码！");
		frm.pageText.focus();
		return;	
	}
	if(!isNumber(pageNumber)||pageNumber==0){
		alert("请输入大于0的整数页码！");
		frm.pageText.focus();
		return;
	}
	if(compareFloat(pageNumber,frm.pageNumber.value) == -1)
	{
		alert("所输入页码太大！");
		frm.pageText.focus();
		return;	
	}


	UserPublishDraftMaint230_ButtonSubmit(pageNumber,linkURL)
}

//删除
function UserPublishDraftMaint230_Delete(theForm,draftID){
	if(confirm("确认删除此草稿吗？"))
     {
		theForm.UserPublishDraftMaint230_action.value="Delete";
		theForm.UserPublishDraftMaint230_DraftID.value = draftID;
		theForm.submit();
	 }
}

//发表
function UserPublishDraftMaint230_Publish(theForm){
	if(theForm.authorEmail.value==""){
		alert("请填写邮箱地址！");
		theForm.authorEmail.focus();
		return false;
	}
	if(!isEmail(theForm.authorEmail.value)){
		alert("请正确填写邮箱地址！");
		theForm.authorEmail.focus();
		return false;
	}
	if(theForm.draftTitle.value==""){
		alert("请填写信息标题！");
		theForm.draftTitle.focus();
		return false;
	}

	theForm.UserPublishDraftMaint230_DraftContent.value = eWebEditor1.getHTML();
	if(theForm.UserPublishDraftMaint230_DraftContent.value==""){
		alert("请填写信息内容！");
		return false;
	}
		theForm.UserPublishDraftMaint230_AuthorEmail.value = theForm.authorEmail.value;
		theForm.UserPublishDraftMaint230_DraftTitle.value = theForm.draftTitle.value;
		theForm.UserPublishDraftMaint230_CategoryID.value = theForm.categoryList.value;
		theForm.UserPublishDraftMaint230_action.value="Publish";
		theForm.submit();
}

function WriteHtmlEditor()
{	
  document.write ("<INPUT type='hidden' name='content1' value=''>");
  document.write ("<IFRAME ID='eWebEditor1' src='../../../EbizResourceSet/htmleditor/userpublishhtml/ewebeditor.html?id=content1&style=full' frameborder='0' scrolling='no' width='100%' height='200'></IFRAME>");
}

//显示更新
function UserPublishDraftMaint230_showUpdate(theForm,draftID){
	theForm.UserPublishDraftMaint230_action.value="showUpdate";
	theForm.UserPublishDraftMaint230_DraftID.value = draftID;
	theForm.submit();
}

//保存
function UserPublishDraftMaint230_save(theForm){
	if(theForm.authorEmail.value==""){
		alert("请填写邮箱地址！");
		theForm.authorEmail.focus();
		return false;
	}
	if(!isEmail(theForm.authorEmail.value)){
		alert("请正确填写邮箱地址！");
		theForm.authorEmail.focus();
		return false;
	}
	if(theForm.draftTitle.value==""){
		alert("请填写信息标题！");
		theForm.draftTitle.focus();
		return false;
	}

	theForm.UserPublishDraftMaint230_DraftContent.value = eWebEditor1.getHTML();
	if(theForm.UserPublishDraftMaint230_DraftContent.value==""){
		alert("请填写信息内容！");
		return false;
	}else{
		theForm.UserPublishDraftMaint230_AuthorEmail.value = theForm.authorEmail.value;
		theForm.UserPublishDraftMaint230_DraftTitle.value = theForm.draftTitle.value;
		theForm.UserPublishDraftMaint230_CategoryID.value = theForm.categoryList.value;
		theForm.UserPublishDraftMaint230_action.value="Update";
		return true;
	}
}

//重置
function UserPublishDraftMaint230_reset(theForm){
	theForm.reset();
	eWebEditor1.setHTML(theForm.UserPublishDraftMaint230_DraftContent.value);
	theForm.authorEmail.focus();
}

//取消
function UserPublishDraftMaint230_cancle(url){
    self.location = url + "&time=" + date.getTime();
}

function UserPublishDraftMaint230_SetValue(){
	var value = document.UserPublishDraftMaint230_form.UserPublishDraftMaint230_DraftContent.value;
	try{
		if (eWebEditor1.bInitialized){
			eWebEditor1.setHTML(value);
		}else{
			setTimeout("UserPublishDraftMaint230_SetValue();",1000);
		}
	}
	catch(e){
		setTimeout("UserPublishDraftMaint230_SetValue();",1000);
	}

}