function SubmitTemplate()
{
if (form.TemplateName.value=="") { //名字为空就返回了 
alert("模版名称不能为空") 
form.TemplateName.focus(); //焦点放到输入名字的地方 
return false; } 
if (form.Content.value=="") { //名字为空就返回了 
alert("模版内容不能为空") 
form.Content.focus(); //焦点放到输入名字的地方 
return false; }
document.forms.form.submit()
}

function SubmitLabeling()
{
if (form.LabName.value=="") { //名字为空就返回了 
alert("自由标签名称不能为空") 
form.LabName.focus(); //焦点放到输入名字的地方 
return false; } 
if (form.Content.value=="") { //名字为空就返回了 
alert("自由标签内容不能为空") 
form.Content.focus(); //焦点放到输入名字的地方 
return false; }
document.forms.form.submit()
}

var buttonArrays=[];
var buttonArraysCount=0;
function writeIconStandard(id,command,img,title)
	{
	w=25;
	h=24;
	imgPath=img;
	sHTML=""+
		"<td unselectable='on' style='padding-right:1px;VERTICAL-ALIGN: top;margin-left:0;margin-right:1px;margin-bottom:1px;width:"+w+"px;height:"+h+"px;'>"+
		"<span unselectable='on' style='position:absolute;clip: rect(0 "+w+"px "+h+"px 0)'>"+
		"<img name=\""+id+"\" id=\""+id+"\" btnIndex=\""+buttonArraysCount+"\" unselectable='on' src='"+imgPath+"' style='position:absolute;top:-0;width:"+w+"px'"+
		"onmouseover='doOver(this)' "+
		"onmouseout='doOut(this)' "+
		"onmousedown='doDown(this)' "+
		"onmouseup=\"if(doUp(this)){"+command+"}\" alt=\""+title+"\">"+
		"</span></td>";
	sHTML="<table align=left cellpadding=0 cellspacing=0 style='table-layout:fixed;'><tr>"+sHTML+"</tr></table>";
	buttonArrays.push(["inactive"]);
	buttonArraysCount++;
	return sHTML;
	}
	
function doOver(btn)
	{
	btnArr=buttonArrays[btn.btnIndex];
	if(btnArr[0]=="inactive")btn.style.top=-24;//no.2
	}
function doDown(btn)
	{
	btnArr=buttonArrays[btn.btnIndex];
	if(btnArr[0]!="disabled")btn.style.top=-48;//no.3
	}
var bCancel=false;
function doOut(btn)
	{
	if(btn.style.top=="-48px")
		{//lagi pushed tapi mouseout (cancel)
		bCancel=true;
		}
	btnArr=buttonArrays[btn.btnIndex];
	if(btnArr[0]=="active")btn.style.top=-72;//no.4 (remain active/pushed)
	if(btnArr[0]=="inactive")btn.style.top=0;//no.1 (remain inactive)
	}
function doUpToggle(btn)
	{
	if(bCancel)
		{//lagi pushed tapi mouseout (cancel)
		bCancel=false;btn.style.top=0;
		return false;
		}
	btnArr = buttonArrays[btn.btnIndex];
	if(btnArr[0]=="inactive")
		{
		btn.style.top=-72;//no.4
		btnArr[0]="active";
		return true;
		}
	if(btnArr[0]=="active")
		{
		btn.style.top=-24;//no.2
		btnArr[0]="inactive";
		return true;
		}
	}
function doUp(btn)//return true/false
	{
	if(bCancel)
		{//lagi pushed tapi mouseout (cancel)
		bCancel=false;btn.style.top=0;
		return false;
		}
	btnArr=buttonArrays[btn.btnIndex];
	if(btnArr[0]=="disabled") return false;
	btn.style.top=-24;//no.2
	return true;
	}

function modelessDialogShow(url,width,height,obj)
	{
	var obj=window.OpenWindowAndSetValue("Labeling/txt_convert.htm?"+url,width,height,'window',obj)
	if (obj==undefined)return false;
  	if (obj!='')insert(obj);
	}
	
function OpenWindowAndSetValue(Url,Width,Height,WindowObj,SetObj)
{
	var ReturnStr=showModalDialog(Url,WindowObj,"dialogWidth:"+Width+"px;dialogHeight:"+Height+"px;edge:Raised;center:1;help:0;resizable:1;");
	if (ReturnStr!='') SetObj.value=ReturnStr;
	return ReturnStr;
}

function insert(returnValue_lable)
{
	obj=document.getElementById("Content");
	obj.focus();
	if(document.selection==null)
	{
		var iStart = obj.selectionStart
		var iEnd = obj.selectionEnd;
		obj.value = obj.value.substring(0, iEnd) +returnValue_lable+ obj.value.substring(iEnd, obj.value.length);
	}else
	{
		var range = document.selection.createRange();
		range.text=returnValue_lable;
	}
}
	
	arrCustomButtons = [["btntype","modelessDialogShow('TypeLeb.asp',650,600,'obj')","栏目标签","../Editor/icons/type.gif"],
								["btnclass","modelessDialogShow('ClassLeb.asp',600,470,'obj')","列表标签","../Editor/icons/class.gif"],
								["btnwithleb","modelessDialogShow('Withleb.asp',600,390,'obj')","更新/排行标签","../Editor/icons/Withleb.gif"],
								["btnmovie","modelessDialogShow('Movieleb.asp',650,570,'obj')","内容标签","../Editor/icons/movie.gif"],
								["btnsearch","modelessDialogShow('SearchLeb.asp',650,470,'obj')","搜索标签","../Editor/icons/search.gif"],
								["btnAllLeb","modelessDialogShow('AllLeb.asp',650,290,'obj')","全部影片标签","../Editor/icons/AllLeb.gif"],
								["btnNavLeb","modelessDialogShow('NavLeb.asp',650,330,'obj')","导航标签","../Editor/icons/NavLeb.gif"],
								["btnNavigation","modelessDialogShow('LocationLeb.asp',350,155,'obj')","位置导航标签","../Editor/icons/Navigation.gif"],								
								["btnFeature","modelessDialogShow('Feature.asp',650,410,'obj')","专题导航标签","../Editor/icons/Feature.gif"],
								["btnFlashSlide","modelessDialogShow('FlashSlide.asp',650,420,'obj')","FLASH幻灯标签","../Editor/icons/FlashSlide.gif"],
								["btnNotice","modelessDialogShow('NoticeLeb.asp',650,320,'obj')","公告标签","../Editor/icons/Notice.gif"],
								["btnlogin","modelessDialogShow('UsersLogin.asp',680,350,'obj')","登陆标签","../Editor/icons/login.gif"],
								["btnsearchLeb","modelessDialogShow('SearchInputLeb.asp',680,330,'obj')","搜索框标签","../Editor/icons/searchLeb.gif"],
								["btnLabeling","modelessDialogShow('ZyLeb.asp',650,330,'obj')","自由标签","../Editor/icons/Labeling.gif"],
								["btnvote","modelessDialogShow('VoteLeb.asp',400,330,'obj')","投票标签","../Editor/icons/vote.gif"],
								["btnad","modelessDialogShow('AdLeb.asp',400,330,'obj')","广告标签","../Editor/icons/Ad.gif"],
								["btnlinkLeb","modelessDialogShow('LinkLeb.asp',650,225,'obj')","友情连接标签","../Editor/icons/linkLeb.gif"],
								["btnTvLeb","modelessDialogShow('TvLeb.asp',500,190,'obj')","直播导航标签","../Editor/icons/TvLeb.gif"],
								["btnhelp","modelessDialogShow('HelpLeb.asp',650,320,'obj')","帮助标签","../Editor/icons/help.gif"],
								["btnhome","insert('{$SetHome}')","设为首页标签","../Editor/icons/home.gif"],
								["btnCollection","insert('{$SetCollection}')","加入收藏夹标签","../Editor/icons/Collection.gif"],
								["btnLogoLeb","modelessDialogShow('LogoLeb.asp',500,190,'obj')","网站Logo标签","../Editor/icons/LogoLeb.gif"],
								["btnsetupdir","insert('{$SetupDir}')","网站安装路径标签","../Editor/icons/setupdir.gif"],
								["btnWebUrl","insert('{$WebUrlW}')","网站URL标签","../Editor/icons/WebUrl.gif"],
								["btnindex","insert('{$WebNameW}')","网站名称标签","../Editor/icons/index.gif"]]
var sHTMLIcons="";
for(j=0;j<arrCustomButtons.length;j++)
{
	sCbName=arrCustomButtons[j][0];
	sCbCommand=arrCustomButtons[j][1];
	sCbCaption=arrCustomButtons[j][2];
	sCbImage=arrCustomButtons[j][3];
	sHTMLIcons+=writeIconStandard(sCbName,sCbCommand,sCbImage,sCbCaption);
}