function Preview(n,action,field)
{
	openWindow("Admin_CatchPreview.Aspx?Action=" + action + "&" + field + "=" + n,640,480);
}

function Upload()
{
	window.open("Admin_UpLoad.Aspx?","XfokUpload","left=0,top=0,width=470,height=374,status=1");
}

function InsertToPreviewImg(str)
{
	document.XfokForm.PreviewImg.value = str;
}

function Catch_Flash()
{
	var obj = document.XfokForm.IsFlashCatch;
	if (obj.checked == true)
	{
		document.XfokForm.CatchBodyStart.value = "[FLASH]";
		document.XfokForm.CatchBodyEnd.value = "[/FLASH]";
	}
	else
	{
		document.XfokForm.CatchBodyStart.value = "";
		document.XfokForm.CatchBodyEnd.value = "";
	}
}

function checkListType(InputName)
{
	var obj = document.XfokForm;
	if (obj.ListType[0].checked)
		obj[InputName].value = "template/{TemplateDirectory}/list_text.ascx";
	else if (obj.ListType[1].checked)
		obj[InputName].value = "template/{TemplateDirectory}/list_image.ascx";
}

function checkisSystem(obj)
{
	if (obj.ChannelUrl.value.length > 0)
		obj.isSystem.selectedIndex = 1;
	else
		obj.isSystem.selectedIndex = 0;
}

function AppendSiteKey(str){
	var RevisedKey = "";
	var CurrentKey = document.XfokForm.LikeKey.value;	//当前已输入的关键字
	if(CurrentKey == "")
	{
		RevisedKey = str;
	}
	else
	{ 
		var arr = CurrentKey.split("|");
		for (var i = 0; i < arr.length; i++)
		{
			if(str.indexOf(arr[i]) >=0 && arr[i].length==str.length)
				return;
		}
		if (str != "")
		{
			str = "|" + str;
		}
		RevisedKey = CurrentKey + str;
	}
	document.XfokForm.LikeKey.value = RevisedKey;
	document.XfokForm.LikeKey.focus();
	return;
} 

function hideLayer()
{
   if (document.getElementById) // IE5+, NN6+
      oElement = document.getElementById("ie");
   else if (document.all)  // IE4
      oElement = document.all("ie");
   else if (document.layers)  // NN4
      oElement = document.layers["ns"];
   
   if (oElement != null && document.layers)
      oElement.visibility = "hidden";
   else if (oElement != null)
      oElement.style.visibility = "hidden";
}

function checkContentForm(theform)
{
	SaveContent();
}

function SaveContent()
{
	Status.innerHTML = '<layer id="ns"><div id="ie">内容保存中，请稍候 ...<IMG alt="内容保存中，请稍候 ..." src="images/loading.gif" border="0"></div></layer>';
}


//设置分类下拉菜单颜色
function setOptionColor(DropName)
{
	try
	{
		if (DropName == null)
		{
			DropName = "ClassID";
		}
		var obj = document.all[DropName];
		for (var i=0;i<obj.options.length;i++)
		{
			if (obj.options[i].value=="0")
			{
				obj.options[i].style.color="gray";
			}
			else
			{
				obj.options[i].style.color="black";
			}
		}
	}
	catch(e)
	{
	}
}

//************编辑器相关函数***************

// 修改编辑栏高度
function XfokEditor_Size(num)
{
	var obj=getByID("Editor");
	if (parseInt(obj.offsetHeight)+num>=200)
		obj.height = (parseInt(obj.offsetHeight) + num);
	if (num>0)
		obj.width="100%";
}
