var Sound = 0;
var Swf = 0;
var Ra = 0;
var Rm = 0;
var text_enter_url = "请输入连接网址";
var text_enter_txt = "请输入连接说明";
var text_enter_image = "请输入图片网址";
var text_enter_sound = "请输入声音文件网址";
var text_enter_swf = "请输入FLASH动画网址";
var text_enter_ra = "请输入Real音乐网址";
var text_enter_rm = "请输入Real影片网址";
var text_enter_wmv = "请输入Media影片网址";
var text_enter_wma = "请输入Media音乐网址";
var text_enter_mov = "请输入QuickTime音乐网址";
var text_enter_sw = "请输入shockwave音乐网址";
var text_enter_email = "请输入邮件网址";
var text_enter_passwords = "请设置密码";
var text_enter_guang1 = "文字的长度、颜色和边界大小";
var text_enter_guang2 = "要产生效果的文字！";

function DoTitle(addTitle){
var submain=document.newform.submain.value
document.newform.submain.value=addTitle+submain
document.newform.submain.focus();
return (false);
}

function DoEmot(addEmot){
var ly=document.newform.ly.value
document.newform.ly.value=ly+addEmot
document.newform.ly.focus();
return (false);
}

function FontChange(NameValue,FontValue){
	var ly=document.newform.ly.value
	document.newform.ly.value="["+NameValue+"="+FontValue+"]"+ly+"[/"+NameValue+"]"
	document.newform.ly.focus();
	return (false);
}

function FontType(HeadValue,FooterValue){
	var ly=document.newform.ly.value
	document.newform.ly.value=HeadValue+ly+FooterValue
	document.newform.ly.focus();
	return (false);
}

function Validator(theForm)
{
  if (theForm.name.value == "")
  {
    alert("请写上您的姓名!");
    theForm.name.focus();
    return (false);
  }
  if (theForm.submain.value == "")
  {
    alert("请写上留言主题!");
    theForm.submain.focus();
    return (false);
  }      
  if (theForm.ly.value == "")
  {
    alert("请写入您的留言!");
    theForm.ly.focus();
    return (false);
  }
  return (true);
}

function AddText(text) {
	if (document.newform.ly.createTextRange && document.newform.ly.caretPos) {      
		var caretPos = document.newform.ly.caretPos;      
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?
		text + ' ' : text;
	}
	else document.newform.ly.value += text;
	document.newform.ly.focus(caretPos);
}
function inputs(str)
{
AddText(str);
}
function LockPassd() {
var PassdContent = prompt(text_enter_passwords,"");
if (!PassdContent) { 
return;
 }
document.newform.ly.value = "[LOCKED="+PassdContent+"]"+document.newform.ly.value+"[/LOCKED]";
document.newform.ly.focus();
}
function Curl() {
var enterURL   = prompt(text_enter_url, "http://");
if (!enterURL)    {
return;
}
var enterTxT   = prompt(text_enter_txt, enterURL);
if (!enterTxT)    {
return;
}
var ToAdd = "[URL="+enterURL+"]"+enterTxT+"[/URL]";
document.newform.ly.value+=ToAdd;
document.newform.ly.focus();
}
function Cimage() {
var FoundErrors = '';
var enterURL   = prompt(text_enter_image, "http://");
if (!enterURL) {
FoundErrors = "True"
}
if (FoundErrors) {
return;
}
var ToAdd = "[IMG]"+enterURL+"[/IMG]";
document.newform.ly.value+=ToAdd;
document.newform.ly.focus();
}
function Cemail() {
var emailAddress = prompt(text_enter_email,"");
if (!emailAddress) { 
return;
 }
var ToAdd = "[EMAIL]"+emailAddress+"[/EMAIL]";
document.newform.ly.value+=ToAdd;
document.newform.ly.focus();
}
function Csound() {
var FoundErrors = '';
var enterURL   = prompt(text_enter_sound, "http://");
if (!enterURL) {
FoundErrors = "True"
}
if (FoundErrors) {
return;
}
var ToAdd = "[SOUND]"+enterURL+"[/SOUND]";
document.newform.ly.value+=ToAdd;
document.newform.ly.focus();
}

helpstat = false;
stprompt = true;
basic = false;
function thelp(swtch){
	if (swtch == 1){
		basic = false;
		stprompt = false;
		helpstat = true;
	} else if (swtch == 0) {
		helpstat = false;
		stprompt = false;
		basic = true;
	} else if (swtch == 2) {
		helpstat = false;
		basic = false;
		stprompt = true;
	}
}

function Cswf() {
 	if (helpstat){
		alert("Flash\nFlash 动画.\n用法: [flash=宽度, 高度]Flash 文件的地址[/flash]");
	} else if (basic) {
		AddTxt="[flash=500,350][/flash]";
		AddText(AddTxt);
	} else {                  
		txt2=prompt("flash宽度，高度","500,350"); 
		if (txt2!=null) {
                txt=prompt("Flash 文件的地址","http://");
		if (txt!=null) {
                          if (txt2=="") {             
			AddTxt="[flash=500,350]"+txt;
			AddText(AddTxt);
			AddTxt="[/flash]";
			AddText(AddTxt);
               } else {
		        AddTxt="[flash="+txt2+"]"+txt;
			AddText(AddTxt);
			AddTxt="[/flash]";
			AddText(AddTxt);
		 }        
	    }  
       }
    }
}

function Crm() {
	if (helpstat) {
               alert("realplay\n播放realplay文件.\n用法: [rm=宽度, 高度]文件地址[/rm]");
	} else if (basic) {
		AddTxt="[rm=500,350][/rm]";
		AddText(AddTxt);
	} else { 
		txt2=prompt("视频的宽度，高度","500,350"); 
		if (txt2!=null) {
			txt=prompt("视频文件的地址","请输入");
			if (txt!=null) {
				if (txt2=="") {
					AddTxt="[rm=500,350]"+txt;
					AddText(AddTxt);
					AddTxt="[/rm]";
					AddText(AddTxt);
				} else {
					AddTxt="[rm="+txt2+"]"+txt;
					AddText(AddTxt);
					AddTxt="[/rm]";
					AddText(AddTxt);
				}         
			} 
		}
	}
}

function Cwmv() {
	if (helpstat) {
               alert("Media Player\n播放Media Player文件.\n用法: [mp=宽度, 高度]文件地址[/mp]");
	} else if (basic) {
		AddTxt="[mp=500,350][/mp]";
		AddText(AddTxt);
	} else { 
		txt2=prompt("视频的宽度，高度","500,350"); 
		if (txt2!=null) {
			txt=prompt("视频文件的地址","请输入");
			if (txt!=null) {
				if (txt2=="") {
					AddTxt="[mp=500,350]"+txt;
					AddText(AddTxt);
					AddTxt="[/mp]";
					AddText(AddTxt);
				} else {
					AddTxt="[mp="+txt2+"]"+txt;
					AddText(AddTxt);
					AddTxt="[/mp]";
					AddText(AddTxt);
				}         
			} 
		}
	}
}

function Cmov() {
	if (helpstat) {
               alert("QuickTime\n播放QuickTime文件.\n用法: [qt=宽度, 高度]文件地址[/qt]");
	} else if (basic) {
		AddTxt="[qt=500,350][/qt]";
		AddText(AddTxt);
	} else { 
		txt2=prompt("视频的宽度，高度","500,350"); 
		if (txt2!=null) {
			txt=prompt("视频文件的地址","请输入");
			if (txt!=null) {
				if (txt2=="") {
					AddTxt="[qt=500,350]"+txt;
					AddText(AddTxt);
					AddTxt="[/qt]";
					AddText(AddTxt);
				} else {
					AddTxt="[qt="+txt2+"]"+txt;
					AddText(AddTxt);
					AddTxt="[/qt]";
					AddText(AddTxt);
				}         
			} 
		}
	}
}

function Cdir() {
	if (helpstat) {
               alert("Shockwave\n插入Shockwave文件.\n用法: [dir=宽度, 高度]文件地址[/dir]");
	} else if (basic) {
		AddTxt="[dir=500,350][/dir]";
		AddText(AddTxt);
	} else { 
		txt2=prompt("Shockwave文件的宽度，高度","500,350"); 
		if (txt2!=null) {
			txt=prompt("Shockwave文件的地址","请输入地址");
			if (txt!=null) {
				if (txt2=="") {
					AddTxt="[dir=500,350]"+txt;
					AddText(AddTxt);
					AddTxt="[/dir]";
					AddText(AddTxt);
				} else {
					AddTxt="[dir="+txt2+"]"+txt;
					AddText(AddTxt);
					AddTxt="[/dir]";
					AddText(AddTxt);
				}         
			} 
		}
	}
}



function Cra() {
var FoundErrors = '';
var enterURL   = prompt(text_enter_ra, "http://");
if (!enterURL) {
FoundErrors = "True"
}
if (FoundErrors) {
return;
}
var ToAdd = "[RA]"+enterURL+"[/RA]";
document.newform.ly.value+=ToAdd;
document.newform.ly.focus();
}

function Cwma() {
var FoundErrors = '';
var enterURL   = prompt(text_enter_wma, "http://");
if (!enterURL) {
FoundErrors = "True"
}
if (FoundErrors) {
return;
}
var ToAdd = "[wma]"+enterURL+"[/wma]";
document.newform.ly.value+=ToAdd;
document.newform.ly.focus();
}
function Cguang() {
var FoundErrors = '';
var enterSET   = prompt(text_enter_guang1, "255,red,2");
var enterTxT   = prompt(text_enter_guang2, "文字");
if (!enterSET)    {
FoundErrors = "True"
}
if (!enterTxT)    {
FoundErrors = "True"
}
if (FoundErrors)  {
return;
}
var ToAdd = "[glow="+enterSET+"]"+enterTxT+"[/glow]";
document.newform.ly.value+=ToAdd;
document.newform.ly.focus();
}

function Cying() {
var FoundErrors = '';
var enterSET   = prompt(text_enter_guang1, "255,blue,1");
var enterTxT   = prompt(text_enter_guang2, "文字");
if (!enterSET)    {
FoundErrors = "True"
}
if (!enterTxT)    {
FoundErrors = "True"
}
if (FoundErrors)  {
return;
}
var ToAdd = "[SHADOW="+enterSET+"]"+enterTxT+"[/SHADOW]";
document.newform.ly.value+=ToAdd;
document.newform.ly.focus();
}

ie = (document.all)? true:false
if (ie){
function ctlent(eventobject){if(event.ctrlKey && window.event.keyCode==13){this.document.newform.submit();}}
}