//write by  xdju 2002-2-19   13:35 
//javascript的代码包
function KillSpace(x)
{
	while((x.length>0) && (x.charAt(0)==' '))
		x = x.substring(1,x.length)
	while((x.length>0) && (x.charAt(x.length-1)==' '))
		x = x.substring(0,x.length-1)
	return x
}
//论坛与斑竹设置的检查，检察日期的相对应的框架是否为可以写
function CheckAllDate(value)
{
	if(value==0)
	{
		document.addcolumn.fdValue.disabled=true;
		document.addcolumn.fdFromDate.disabled=true;
		document.addcolumn.fdToDate.disabled=true;
		document.addcolumn.fdFromTime.disabled=true;
		document.addcolumn.fdToTime.disabled=true;
	}
	if(value==1) 
	{
		document.addcolumn.fdValue.disabled=true;
		document.addcolumn.fdFromDate.disabled=true;
		document.addcolumn.fdToDate.disabled=true;
		document.addcolumn.fdFromTime.disabled=false;
		document.addcolumn.fdToTime.disabled=false;
	}
	if(value==2) 
	{
		document.addcolumn.fdValue.disabled=false;
		document.addcolumn.fdFromDate.disabled=true;
		document.addcolumn.fdToDate.disabled=true;
		document.addcolumn.fdFromTime.disabled=false;
		document.addcolumn.fdToTime.disabled=false;
	}
	if(value==3) 
	{
		document.addcolumn.fdValue.disabled=true;
		document.addcolumn.fdFromDate.disabled=false;
		document.addcolumn.fdToDate.disabled=false;
		document.addcolumn.fdFromTime.disabled=false;
		document.addcolumn.fdToTime.disabled=false;
	}
}
//
function CheckAllDate1(value)
{
	if(value==0)
	{
		document.updatoption1.fdValue.disabled=true;
		document.updatoption1.fdFromDate.disabled=true;
		document.updatoption1.fdToDate.disabled=true;
		document.updatoption1.fdFromTime.disabled=true;
		document.updatoption1.fdToTime.disabled=true;
	}
	if(value==1) 
	{
		document.updatoption1.fdValue.disabled=true;
		document.updatoption1.fdFromDate.disabled=true;
		document.updatoption1.fdToDate.disabled=true;
		document.updatoption1.fdFromTime.disabled=false;
		document.updatoption1.fdToTime.disabled=false;
	}
	if(value==2) 
	{
		document.updatoption1.fdValue.disabled=false;
		document.updatoption1.fdFromDate.disabled=true;
		document.updatoption1.fdToDate.disabled=true;
		document.updatoption1.fdFromTime.disabled=false;
		document.updatoption1.fdToTime.disabled=false;
	}
	if(value==3) 
	{
		document.updatoption1.fdValue.disabled=true;
		document.updatoption1.fdFromDate.disabled=false;
		document.updatoption1.fdToDate.disabled=false;
		document.updatoption1.fdFromTime.disabled=false;
		document.updatoption1.fdToTime.disabled=false;
	}
}
//论坛与斑竹设置的检查，输入必添项
function checkform()
{
	
	if(document.addcolumn.fdName.value=='')
	{
		 alert("请输入专栏名称");
		 return false;
	}/*
	var fdTableColor=document.addcolumn.fdTableColor.value.length;
	var fdMenuColor=document.addcolumn.fdMenuColor.value.length;
	var fdActiveColor=document.addcolumn.fdActiveColor.value.length;
	var fdHoverColor=document.addcolumn.fdHoverColor.value.length;
	var fdLinkColor=document.addcolumn.fdLinkColor.value.length;
	var fdVlinkColor=document.addcolumn.fdVlinkColor.value.length;
	var fdBgColor=document.addcolumn.fdBgColor.value.length;
	if((fdTableColor!=6)&&(fdMenuColor!=6)&&(fdActiveColor!=6)&&(fdHoverColor!=6)&&(fdLinkColor!=6)&&(fdVlinkColor!=6)&&(fdBgColor!=6))
	{
		alert("你输入的颜色不正确");
		return false;
	}*/
	/*if(document.addcolumn.fdStyle[0].checked)
	{
		 alert("你确认取消，设置为全开放吗？");
		 return true;
	}*/
	//每日
	if(document.addcolumn.fdStyle[1].checked)
	{
		 if(document.addcolumn.fdFromTime.value == document.addcolumn.fdToTime.value)
			{	alert("你输入的时间不正确");	return false; }
		}
	//每周
	if(document.addcolumn.fdStyle[2].checked)
	{
		if(document.addcolumn.fdFromDate.date=document.addcolumn.fdToDate.value)
		{
			 if(document.addcolumn.fdFromTime.value>=document.addcolumn.fdToTime.value)
			 {	alert("你输入的时间不正确");	return false; }
		 }
	}
	//时间段
	if(document.addcolumn.fdStyle[3].checked)
	{
		if(document.addcolumn.fdFromDate.date>document.addcolumn.fdToDate.value)
		{
			 alert("你输入的日期不正确");
			 return false; 
		}
		else if(document.addcolumn.fdFromDate.date=document.addcolumn.fdToDate.value)
		{
			 if(document.addcolumn.fdFromTime.value>=document.addcolumn.fdToTime.value)
			{	alert("你输入的时间不正确");	return false; }
		 }
	}
	
}
//论坛与斑竹设置的颜色拾取
function selectcolor(str)
{
  var arr = showModalDialog("selcolor.htm", "", "dialogWidth:18.5em; dialogHeight:17.5em; status:0");
  if (arr != null){
		if (str=='1')
		document.addcolumn.fdTableColor.value=arr;
		else if (str=='2')
		document.addcolumn.fdMenuColor.value=arr;
		else if (str=='3')
		document.addcolumn.fdActiveColor.value=arr;
		else if (str=='4')
		document.addcolumn.fdHoverColor.value=arr;
		else if (str=='5')
		document.addcolumn.fdLinkColor.value=arr;
		else if (str=='6')
		document.addcolumn.fdVlinkColor.value=arr;
		else if (str=='7')
		document.addcolumn.fdBgColor.value=arr;
		 else Composition.focus();
	}
}
//文章的全选
function selectAll()
{
	if(document.titleFrm)
	{
		if(document.titleFrm.selectall.checked==true)
		{
			var total = document.titleFrm.count.value*1;
			for(var i = 0; i < total; i++)
			{
				var thisCtrl = eval("document.titleFrm.checkname" + i);
				thisCtrl.checked=true;
			}
		}
		else
		{
			var total = document.titleFrm.count.value*1;
			for(var i =0; i < total; i++)
			{
				var thisCtrl = eval("document.titleFrm.checkname" + i);
				thisCtrl.checked=false;
			}
		}
	}
}
//判断注册表单
function checkregform() {
	document.registerform.fdLogin.value = KillSpace(document.registerform.fdLogin.value);
	document.registerform.fdPassword.value = KillSpace(document.registerform.fdPassword.value);
	document.registerform.fdName.value = KillSpace(document.registerform.fdName.value);
	document.registerform.fdEmail.value = KillSpace(document.registerform.fdEmail.value);

	if (document.registerform.fdLogin.value.length<2) {
		alert("用户名长度必须在2个字符以上");
		return false;
	}
	else if (document.registerform.fdPassword.value.length<6) {
		alert("密码长度必须在6个字符以上");
		return false;
	}
	else if (document.registerform.fdPassword.value!=document.registerform.fdPassword2.value) {
		alert("密码和确认密码不一致");
		return false;
	}
	else if (document.registerform.fdName.value.length<2) {
		alert("姓名长度必须在2个字符以上");
		return false;
	}
	else if (document.registerform.fdEmail.value.indexOf('@',0)==-1) {
		alert("请认真填写EMAIL，因为您必须通过该EMAIL激活您的帐号。");
		return false;
	}
	else
	{
		return true;
	}
}
//弹出日历的框架
function fPopUpCalendarDlg(ctrlobj) {
	showx = event.screenX - event.offsetX - 4 - 210 ; // + deltaX;
	showy = event.screenY - event.offsetY + 18; // + deltaY;
	newWINwidth = 210 + 4 + 18;

	retval = window.showModalDialog("calendardlg.htm", "", "dialogWidth:197px; dialogHeight:210px; dialogLeft:"+showx+"px; dialogTop:"+showy+"px; status:no; directories:yes;scrollbars:no;Resizable=no; "  );
	if( retval != null ) {
		ctrlobj.value = retval;
	}
}

function fPopface(ctrlobj,ctrlobj2) {
	newWINwidth = 210 + 4 + 18;
	retval = window.showModalDialog("selectpic.php", "", "dialogWidth:400px; dialogHeight:430px; dialogLeft:100px; dialogTop:0px; status:no; directories:yes;scrollbars:no;Resizable=no; "  );
	if( retval != null ) {
		ctrlobj.src = retval;
		ctrlobj2.value = retval;
	}
}

//检测用户发布公告是否正确
function checkbulltin()
{
	fdTitile=KillSpace(document.checkaddbulltin.fdTitile.value);
	fdEndDate=KillSpace(document.checkaddbulltin.fdEndDate.value);
	fdContent=KillSpace(document.checkaddbulltin.fdContent.value);
	fdSendDate=KillSpace(document.checkaddbulltin.fdSendDate.value);
	if((fdTitile=='')||(fdEndDate=='')||(fdContent==''))
	{
		alert("公告标题、公告内容、公告的结束日期必须填写"); return false;
	}
	else if(fdEndDate<=fdSendDate)
	{	
		alert("公告日期必须在发布日期之后"); return false;	
	}
  else return true;
}
//弹出新的窗口
function MM_openBrWindow(theURL,winName,features) 
{ 
	window.open(theURL,winName,features);
}
//对屏蔽设置 进行效验--添加
function checkshield()
{
	fdMarkName=KillSpace(document.checkname.fdMarkName.value);
	fdMarkReplace=KillSpace(document.checkname.fdMarkReplace.value);
	if((fdMarkName=='')||(fdMarkReplace==''))
	{
		alert("词语,替代词 必须填写"); return false;	
	}
	else return true;
}
function checkshield2()
{
	fdMarkName=KillSpace(document.checkname.fdMarkName.value);
	if(fdMarkName=='')
	{
		alert("禁止词语必须填写"); return false;	
	}
	else return true;
}
//对头衔管理的效验
function checktitle()
{
	var fdName=KillSpace(document.pmlistform.fdName.value);
	var fdScore=KillSpace(document.pmlistform.fdScore.value);
	var fdMessageNum = KillSpace(document.pmlistform.fdMessageNum.value);

	if((fdName)&&(fdScore)&&(fdMessageNum))
	{
		return true;
	} else {
		alert("请您认真填写头衔名称、最底分数、悄悄话数！"); 
		return false;	
	}
}
//判断是否为整数
function isInt(y)
{
	var error=1;
	for(i=0;i<y.length;i++)
	{
	  f=y.substring(i,i+1);
	  f=f*1;
	  if((f<0)||(f>9)) error=0; 
	}
	return error;
}

//对网站的option的颜色进行效验
function selectcolor1(str)
{
  var arr = showModalDialog("selcolor.htm", "", "dialogWidth:18.5em; dialogHeight:17.5em; status:0");
  if (arr != null){
		if (str=='1')
		document.updatoption1.fdTableColor.value=arr;
		else if (str=='2')
		document.updatoption1.fdMenuColor.value=arr;
		else if (str=='3')
		document.updatoption1.fdActiveColor.value=arr;
		else if (str=='4')
		document.updatoption1.fdHoverColor.value=arr;
		else if (str=='5')
		document.updatoption1.fdLinkColor.value=arr;
		else if (str=='6')
		document.updatoption1.fdVlinkColor.value=arr;
		else if (str=='7')
		document.updatoption1.fdBgColor.value=arr;
		 else Composition.focus();
	}
}
//对网站的option的进行效验
function updatoption()
{
	var fdSetTime=document.updatoption1.fdSetTime.value;
	if((fdSetTime==''))
	{			
		alert("灌水检查选项填写不正确"); return false;
	}
	var fdSetCookieTime=document.updatoption1.fdSetCookieTime.value;
	if((fdSetCookieTime==''))
	{			
		alert("cookie记录时间填写不正确"); return false;
	}
	var fdImageSize=document.updatoption1.fdImageSize.value;
	if((fdImageSize==''))
	{			
		alert("文章帖图图片大小填写不正确"); return false;
	}
	var fdImageX=document.updatoption1.fdImageX.value;
	if((fdImageX==''))
	{			
		alert("文章帖图图片尺寸最大长度输入不正确"); return false;
	}
	var fdImageY=document.updatoption1.fdImageY.value;
	if((fdImageY==''))
	{			
		alert("文章帖图图片尺寸最大宽度输入不正确"); return false;
	}
	var fdUserImageSize=document.updatoption1.fdUserImageSize.value;
	if((fdUserImageSize==''))
	{			
		alert("人头像图片大小填写不正确"); return false;
	}
	var fdUserImageX=document.updatoption1.fdUserImageX.value;
	if((fdUserImageX==''))
	{			
		alert("人头像图片尺寸最大长度输入不正确"); return false;
	}
	var fdUserImageY=document.updatoption1.fdUserImageY.value;
	if((fdUserImageY==''))
	{			
		alert("人头像图片尺寸最大宽度输入不正确"); return false;
	}
	var fdTitleSize=document.updatoption1.fdTitleSize.value;
	if((fdTitleSize==''))
	{			
		alert("文章标题的最大字符数输入不正确"); return false;
	}
	var fdContentSize=document.updatoption1.fdContentSize.value;
	if((fdContentSize==''))
	{			
		alert("文章内容的最大字符数输入不正确"); return false;
	}
	var fdStarSize=document.updatoption1.fdStarSize.value;
	if((fdStarSize==''))
	{			
		alert("星星照片的大小输入不正确"); return false;
	}
	var fdDispTitleNum=document.updatoption1.fdDispTitleNum.value;
	if((fdDispTitleNum==''))
	{			
		alert("显示文章条数输入不正确"); return false;
	}
	var fdDispReplyNum=document.updatoption1.fdDispReplyNum.value;
	if((fdDispReplyNum==''))
	{			
		alert("显示回帖条数输入不正确"); return false;
	}
	/*var fdTableColor=document.updatoption1.fdTableColor.value.length;
	var fdMenuColor=document.updatoption1.fdMenuColor.value.length;
	var fdActiveColor=document.updatoption1.fdActiveColor.value.length;
	var fdHoverColor=document.updatoption1.fdHoverColor.value.length;
	var fdLinkColor=document.updatoption1.fdLinkColor.value.length;
	var fdVlinkColor=document.updatoption1.fdVlinkColor.value.length;
	var fdBgColor=document.updatoption1.fdBgColor.value.length;
	if((fdTableColor!=6)||(fdMenuColor!=6)||(fdActiveColor!=6)||(fdHoverColor!=6)||(fdLinkColor!=6)||(fdVlinkColor!=6)||(fdBgColor!=6))
	{
		alert("你输入的颜色不正确");
		return false;
	}*/
}

//判断vB代码输入表单
function checkvbbform() {
	if ((!document.vbcodeform.fdLabel.value)||(!document.vbcodeform.fdReplace.value)||(!document.vbcodeform.fdExample.value)||(!document.vbcodeform.fdDescribe.value))
	{
		alert("必须填写每一项"); return false;
	} else {
		return true;
	}
}

//判断悄悄话表单
function checkpmform() {
	if ((!document.pmform.fdToLogin.value)||(!document.pmform.fdContent.value))
	{
		alert("留言对象、内容不为空"); return false;
	} else {
		return true;
	}
}

//全部选定/取消
function CheckAll() {
	for (var i=0;i<document.pmlistform.elements.length;i++) {
		var e = document.pmlistform.elements[i];
		if ((e.name != 'checkall') && (e.type=='checkbox')) {
			e.checked = document.pmlistform.checkall.checked;
		}
	}
}

//分页程序检查
function check_page(){
    if(((document.change_page.intGotoPage.value*1)>(document.change_page.intMaxPage.value*1))||((document.change_page.intGotoPage.value*1)<1)){
          alert("该页不存在");
          return false;
    } else {
          return true;
    }
}
//弹出对话框函数
function fPopUpWin(filename,prop_w,prop_h,prop_l,prop_t) 
{
	
	var features =
		'dialogWidth:'  + prop_w + 'px;' +
		'dialogHeight:' + prop_h + 'px;' +
		'dialogLeft:'   + prop_l + 'px;' +
		'dialogTop:'    + prop_t + 'px;'+
		'directories:yes; localtion:yes; menubar:no; status=no; toolbar=no;scrollbars:no;Resizeable=no';

    
    window.showModalDialog(filename,"NewWindow",features);
}
//备份数据表判断
function checkbackup()
{
	var flag=0;
	for (var i=0;i<document.pmlistform.elements.length-4;i++) 
	{
		if(document.pmlistform.elements[i].checked)	
			flag=1
	}
	//alert(flag)
	if(flag)	return true;
	else 
	{
		alert("请选择表名");
		return false;
	}
}
//社区星星判断
function checkstar()
{
	fdImage1=document.pmform.fdImage1.value;
	fdImage2=document.pmform.fdImage2.value;
	fdHeight=document.pmform.fdHeight.value;
	fdWeight=document.pmform.fdWeight.value;
	fdMarry=document.pmform.fdMarry.value;
	fdSchool=document.pmform.fdSchool.value;
	fdIdeal=document.pmform.fdIdeal.value;
	fdTalk=document.pmform.fdTalk.value;
	fdHobbit=document.pmform.fdHobbit.value;
	fdLoveBook=document.pmform.fdLoveBook.value;
	fdLovemusic=document.pmform.fdLovemusic.value;
	fdLoveFriend=document.pmform.fdLoveFriend.value;
	fdLovePlace=document.pmform.fdLovePlace.value;
	fdLovePeople=document.pmform.fdLovePeople.value;
	fdLoveMan=document.pmform.fdLoveMan.value;
	fdLoveSports=document.pmform.fdLoveSports.value;
	fdOICQ=document.pmform.fdOICQ.value;
	fdDetail=document.pmform.fdDetail.value;
	if((fdImage1=='')||(fdHeight=='')||(fdWeight=='')||(fdMarry=='')||(fdSchool=='')||(fdIdeal=='')||(fdTalk=='')||(fdHobbit=='')||(fdLoveBook=='')||(fdLovemusic=='')||(fdLoveFriend=='')||(fdLovePlace=='')||(fdLovePeople=='')||(fdLoveMan=='')||(fdLoveSports=='')||(fdOICQ=='')||(fdDetail==''))
	{
		alert("以上带*号必须填写");
		return false;
	}
	else
	return true;
}
function checkadvertise()
{
	fdImage=KillSpace(document.checkadvertisement.fdImage.value);
	if(fdImage=='')
	{
		alert("你必须选择图片");
		return false;
	}
	return true;
}
//判断vB代码输入表单
function checkvbbform() {
	if ((!document.vbcodeform.fdLabel.value)||(!document.vbcodeform.fdReplace.value)||(!document.vbcodeform.fdExample.value)||(!document.vbcodeform.fdDescribe.value))
	{
		alert("必须填写每一项"); return false;
	} else {
		return true;
	}
}

//判断悄悄话表单
function checkpmform() {
	if ((!document.pmform.fdToLogin.value)||(!document.pmform.fdContent.value))
	{
		alert("留言对象、内容不为空"); return false;
	} else {
		return true;
	}
}

//全部选定/取消
function CheckAll() {
	for (var i=0;i<document.pmlistform.elements.length;i++) {
		var e = document.pmlistform.elements[i];
		if ((e.name != 'checkall') && (e.type=='checkbox')) {
			e.checked = document.pmlistform.checkall.checked;
		}
	}
}

//分页程序检查
function check_page(){
    if(((document.change_page.intGotoPage.value*1)>(document.change_page.intMaxPage.value*1))||((document.change_page.intGotoPage.value*1)<1)){
          alert("该页不存在");
          return false;
    } else {
          return true;
    }
}
//弹出对话框函数
function fPopUpWin(filename,prop_w,prop_h,prop_l,prop_t) 
{
	
	var features =
		'dialogWidth:'  + prop_w + 'px;' +
		'dialogHeight:' + prop_h + 'px;' +
		'dialogLeft:'   + prop_l + 'px;' +
		'dialogTop:'    + prop_t + 'px;'+
		'directories:yes; localtion:yes; menubar:no; status=no; toolbar=no;scrollbars:no;Resizeable=no';

    
    window.showModalDialog(filename,"NewWindow",features);
}
//备份数据表判断
function checkbackup()
{
	var flag=0;
	for (var i=0;i<document.pmlistform.elements.length-4;i++) 
	{
		if(document.pmlistform.elements[i].checked)	
			flag=1
	}
	//alert(flag)
	if(flag)	return true;
	else 
	{
		alert("请选择表名");
		return false;
	}
}
//社区星星判断
function checkstar()
{
	fdImage1=document.pmform.fdImage1.value;
	fdImage2=document.pmform.fdImage2.value;
	fdHeight=document.pmform.fdHeight.value;
	fdWeight=document.pmform.fdWeight.value;
	fdMarry=document.pmform.fdMarry.value;
	fdSchool=document.pmform.fdSchool.value;
	fdIdeal=document.pmform.fdIdeal.value;
	fdTalk=document.pmform.fdTalk.value;
	fdHobbit=document.pmform.fdHobbit.value;
	fdLoveBook=document.pmform.fdLoveBook.value;
	fdLovemusic=document.pmform.fdLovemusic.value;
	fdLoveFriend=document.pmform.fdLoveFriend.value;
	fdLovePlace=document.pmform.fdLovePlace.value;
	fdLovePeople=document.pmform.fdLovePeople.value;
	fdLoveMan=document.pmform.fdLoveMan.value;
	fdLoveSports=document.pmform.fdLoveSports.value;
	fdOICQ=document.pmform.fdOICQ.value;
	fdDetail=document.pmform.fdDetail.value;
	if((fdImage1=='')||(fdHeight=='')||(fdWeight=='')||(fdMarry=='')||(fdSchool=='')||(fdIdeal=='')||(fdTalk=='')||(fdHobbit=='')||(fdLoveBook=='')||(fdLovemusic=='')||(fdLoveFriend=='')||(fdLovePlace=='')||(fdLovePeople=='')||(fdLoveMan=='')||(fdLoveSports=='')||(fdOICQ=='')||(fdDetail==''))
	{
		alert("以上带*号必须填写");
		return false;
	}
	else
	return true;
}
//广告维护表单检验
function checkadvertise()
{
	fdImage=KillSpace(document.checkadvertisement.fdImage.value);
	if(fdImage=='')
	{
		alert("必须选择广告图片");
		return false;
	}
	return true;
}
//决定备份文件名
function setfilename() {
	var today = new Date();
	var year = today.getYear();
	var month = today.getMonth()+1;
	var date = today.getDate();
	var hour = today.getHours();
	var minute = today.getMinutes();
	var second = today.getSeconds();
	var thistime = year+"-"+month+"-"+date+"_"+hour+"-"+minute+"-"+second+".sql";
	if(document.pmlistform.way[0].checked)
	{ 
		document.pmlistform.filename.value = "all_"+thistime;
	}
	if(document.pmlistform.way[1].checked)
	{ 
		document.pmlistform.filename.value = "part_"+thistime;
	}
	if(document.pmlistform.way[2].checked)
	{ 
		document.pmlistform.filename.value = "stru_"+thistime;
	}
		document.pmlistform.nowtime.value = year+"-"+month+"-"+date+" "+hour+":"+minute+":"+second;
}
//备份表单检验
function checkbackupform() {
	var ok1 = 0;
	var ok2 = 0;
	for (var i=1;i<document.pmlistform.elements.length;i++) {
		var e = document.pmlistform.elements[i];
		if ((e.type=='checkbox') && (e.checked==true)) {
			ok1 = 1;
		}
		if ((e.type=='radio') && (e.checked==true)) {
			ok2 = 1;
		}
	}
	if ((ok1==1) && (ok2==1))
	{
		 return true;
	} else if (ok1==1) {
		alert("请选择备份方式");
		return false;
	} else if (ok2==1) {
		alert("请选择数据表");
		return false;
	} else {
		alert("请选择数据表和备份方式");
		return false;
	}
}
//vb选项
// *******************************************************

tags = new Array();

// *******************************************************
// replacements for unsupported array functions (because arrayname.push(var)
// and arrayname.pop() are not implemented in IE until version 5.5)

function getarraysize(thearray) {
// replacement for arrayname.length property
	for (i = 0; i < thearray.length; i++) {
		if ((thearray[i] == "undefined") || (thearray[i] == "") || (thearray[i] == null))
			return i;
		}
	return thearray.length;
}

function arraypush(thearray,value) {
// replacement for arrayname.push(value)
	thearraysize = getarraysize(thearray);
	thearray[thearraysize] = value;
}

function arraypop(thearray) {
// replacement for arrayname.pop()
	thearraysize = getarraysize(thearray);
	retval = thearray[thearraysize - 1];
	delete thearray[thearraysize - 1];
	return retval;
}

// *******************************************************

function setmode(modevalue) {
// sets cookie for normal (0) and enhanced (1) modes
	document.cookie = "vbcodemode="+modevalue+"; path=/; expires=Wed, 1 Jan 2020 00:00:00 GMT;";
}

function normalmode(pmform) {
// checks value of mode radio buttons. returns true if normal mode
	if (pmform.mode[0].checked) return true;
	else return false;
}

function stat(thevalue) {
// places mini-help text into help/error textbox
// strings are stored in vbcode_language.js
	document.pmform.status.value = eval(thevalue+"_text");
}

// *******************************************************

function closetag(pmform) {
// closes last opened tag
	if (normalmode(pmform))
		stat('enhanced_only');
	else
		if (tags[0]) {
			pmform.fdContent.value += "[/"+ arraypop(tags) +"]";
			}
		else {
			stat('no_tags');
			}
	//pmform.closecurrent.checked=false;
	pmform.fdContent.focus();
}

function closeall(pmform) {
// closes all open tags
	if (normalmode(pmform))
		stat('enhanced_only');
	else {
		if (tags[0]) {
			while (tags[0]) {
				pmform.fdContent.value += "[/"+ arraypop(tags) +"]";
				}
			pmform.fdContent.value += " ";
			}
		else {
			stat('no_tags');
			}
		}
	//pmform.closealltags.checked=false;
	pmform.fdContent.focus();
}

// *******************************************************

function vbcode(pmform,vbcode,prompttext) {
// insert [x]yyy[/x] style markup
	if ((normalmode(pmform)) || (vbcode=="IMG")) {
		inserttext = prompt(tag_prompt+"\n["+vbcode+"]xxx[/"+vbcode+"]",prompttext);
		if ((inserttext != null) && (inserttext != ""))
			pmform.fdContent.value += "["+vbcode+"]"+inserttext+"[/"+vbcode+"] ";
		}
	else {
		donotinsert = false;
		for (i = 0; i < tags.length; i++) {
			if (tags[i] == vbcode)
				donotinsert = true;
			}
		if (donotinsert)
			stat("already_open");
		else {
			pmform.fdContent.value += "["+vbcode+"]";
			arraypush(tags,vbcode);
			}
		}
	pmform.fdContent.focus();
}

// *******************************************************

function fontformat(pmform,thevalue,thetype) {
// insert two-parameter markup - [x=y]zzz[/x]
	if (normalmode(pmform)) {
		if (thevalue != 0) {
			inserttext = prompt(font_formatter_prompt+" "+thetype,"");
			if ((inserttext != null) && (inserttext != ""))
				pmform.fdContent.value += "["+thetype+"="+thevalue+"]"+inserttext+"[/"+thetype+"] ";
			}
		}
	else {
		pmform.fdContent.value += "["+thetype+"="+thevalue+"]";
		arraypush(tags,thetype);
		}
	pmform.sizeselect.selectedIndex = 0;
	pmform.fontselect.selectedIndex = 0;
	pmform.colorselect.selectedIndex = 0;
	pmform.fdContent.focus();
}

// *******************************************************

function namedlink(pmform,thetype) {
// inserts named url or email link - [url=mylink]text[/url]
	linktext = prompt(link_text_prompt,"");
		var prompttext;
		if (thetype == "URL") {
			prompt_text = link_url_prompt;
			prompt_contents = "http://";
			}
		else {
			prompt_text = link_email_prompt;
			prompt_contents = "";
			}
	linkurl = prompt(prompt_text,prompt_contents);
	if ((linkurl != null) && (linkurl != "")) {
		if ((linktext != null) && (linktext != ""))
			pmform.fdContent.value += "["+thetype+"="+linkurl+"]"+linktext+"[/"+thetype+"] ";
		else
			pmform.fdContent.value += "["+thetype+"]"+linkurl+"[/"+thetype+"] ";
		}
	pmform.fdContent.focus();
}

// *******************************************************

function dolist(pmform) {
// inserts list with option to have numbered or alphabetical type
	listtype = prompt(list_type_prompt, "");
	if ((listtype == "a") || (listtype == "1")) {
		thelist = "[list="+listtype+"]\n";
		listend = "[/list="+listtype+"] ";
		}
	else {
		thelist = "[list]\n";
		listend = "[/list] ";
		}
	listentry = "initial";
	while ((listentry != "") && (listentry != null)) {
		listentry = prompt(list_item_prompt, "");
		if ((listentry != "") && (listentry != null))
			thelist = thelist+"[*]"+listentry+"\n";
		}
	pmform.fdContent.value += thelist+listend;
	pmform.fdContent.focus();
}

function js_callpage(htmlurl) {
  var newwin=window.open(htmlurl,"useronline","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=400,height=430");
  newwin.focus();
  return false;
}
// *******************************************************

function smilie(thesmilie) {
// inserts smilie text
	document.pmform.fdContent.value += thesmilie+" ";
	document.pmform.fdContent.focus();
}

function opensmiliewindow(x,y,sessionhash) {
// um... opens smilie overflow window.
		window.open("misc.php?action=getsmilies&s"+sessionhash, "smilies", "toolbar=no,scrollbars=yes,resizable=yes,width="+x+",height="+y);
}
// the following are the text prompts for buttons etc.
// DO NOT ADD LINE-BREAKS BETWEEN THE "...." QUOTES!

// MINI-HELP fdContentS

b_text = "文本加粗";  // "Insert BOLD text"
i_text = "文本变斜体";  // "Insert ITALIC text"
u_text = "文本加入下画线";  // "Insert UNDERLINED text"

size_text = "改变文本的大小"; // "Alter the SIZE of your text"
font_text = "改变文本的字体"; // "Alter the FONT of your text"
color_text = "改变文本的颜色"; // "Alter the COLOR of your text"

url_text = "在内容中插入超级链接"; // "Insert a hyperlink into your fdContent"
email_text = "在内容中插入email地址"; // "Insert an email-link into your fdContent"
img_text = "在内容中插入图象"; // "Insert an image into your fdContent"

code_text = "在内容中插入代码"; // "Insert monospace text into your fdContent"
php_text = "在内容中插入PHP代码"; // "Insert text with PHP syntax highlighting"
list_text = "在内容中插入顺序列表"; // "Insert an ordered list into your fdContent"
quote_text = "在内容中插入引用"; // "Insert a quote into your fdContent"

norm_text = "普通代码模式"; // "Switch to normal code-editing mode"
enha_text = "高级代码模式"; // "Enhanced mode: allows complex nesting of tags"

closecurrent_text = "关闭当前标签"; // "Close the current vBcode tag"
closeall_text = "关闭所有标签"; // "Close all open vBcode tags"

// ERROR fdContentS

enhanced_only_text = "<< 只能在高级代码模式中起作用 >>"; // "<< This is only available in Enhanced Mode >>"
no_tags_text = "没有发现打开的VB代码标签"; // "<< No open vBcode tags detected. >>"
already_open_text = "您已经打开了该类型的一个标签"; // "<< You already have an open tag of this type >>"

// TEXT FOR POP-UP PROMPTS

tag_prompt = "请输入内容进行格式定义:"; // "Enter the text to be formatted:"

font_formatter_prompt = "请输入内容进行格式定义"; // "Enter the text to be formatted with the specified"

link_text_prompt = "请输入需要链接的内容"; // "Enter the text to be displayed for the link (optional)"
link_url_prompt = "请输入完成路径"; // "Enter the full URL for the link"
link_email_prompt = "请输入EMAIL地址链接"; // "Enter the email address for the link"

list_type_prompt = "您需要什么类型的列表？ 输入1按数字列表，输入a按字母列表，不输入表示按照默认状态"; // "What type of list do you want? Enter '1' for a numbered list, enter 'a' for an alphabetical list, or leave blank for a list with bullet points.";
list_item_prompt = "请输入列表项，按'Cancel'结束"; // "Enter a list item.\nLeave the box empty or press 'Cancel' to complete the list.";
