function showFace(){
	var face_1=$("face1").options[$("face1").selectedIndex].value;
	var face_2=$("face2").options[$("face2").selectedIndex].value;
	var face_3=$("face3").options[$("face3").selectedIndex].value;
	var currentFace=face_1 + face_2 + face_3
	if(currentFace=="000"){
	    $("spanFace").innerHTML=" "
	}else $("spanFace").innerHTML="<img src='"+path+"/comm/images/icon/"+ currentFace +".gif'>"
}
function showFaceSim(){
	var face_1=$("face1Sim").options[$("face1Sim").selectedIndex].value;
	var face_2=$("face2Sim").options[$("face2Sim").selectedIndex].value;
	var face_3=$("face3Sim").options[$("face3Sim").selectedIndex].value;
	var currentFace=face_1 + face_2 + face_3
	if(currentFace=="000"){
	    $("spanFaceSim").innerHTML=" "
	}else $("spanFaceSim").innerHTML="<img src='"+path+"/comm/images/icon/"+ currentFace +".gif'>"
}
function PreFace(){
	var face_1=parseInt($("face1").selectedIndex);
	var face_2=parseInt($("face2").selectedIndex);
	var face_3=parseInt($("face3").selectedIndex);
	if(face_3 > 0){
		$("face3").selectedIndex=face_3 -1
		showFace();
	}else{
		if(face_2 >0){
			$("face2").selectedIndex=face_2 -1
			$("face3").selectedIndex=9
			showFace();
		}else{
			if(face_1 >0){
				$("face1").selectedIndex=face_1 -1
				$("face2").selectedIndex=9
				$("face3").selectedIndex=9
				showFace();
			}
		}
	}
}
function PreFaceSim(){
	var face_1=parseInt($("face1Sim").selectedIndex);
	var face_2=parseInt($("face2Sim").selectedIndex);
	var face_3=parseInt($("face3Sim").selectedIndex);
	if(face_3 > 0){
		$("face3Sim").selectedIndex=face_3 -1
		showFaceSim();
	}else{
		if(face_2 >0){
			$("face2Sim").selectedIndex=face_2 -1
			$("face3Sim").selectedIndex=9
			showFaceSim();
		}else{
			if(face_1 >0){
				$("face1Sim").selectedIndex=face_1 -1
				$("face2Sim").selectedIndex=9
				$("face3Sim").selectedIndex=9
				showFaceSim();
			}
		}
	}
}
function NextFace(){
	var face_1=parseInt($("face1").selectedIndex,10);
	var face_2=parseInt($("face2").selectedIndex,10);
	var face_3=parseInt($("face3").selectedIndex,10);
	if(face_3 < 9){
		$("face3").selectedIndex=face_3 + 1
		showFace();
	}else{
		if(face_2 < 9){
			$("face2").selectedIndex=face_2 + 1
			$("face3").selectedIndex=0
			showFace();
		}else{
			if(face_1 < 4){
				$("face1").selectedIndex=face_1 +1
				$("face2").selectedIndex=0
				$("face3").selectedIndex=0
				showFace();
			}
		}
	}
}
function NextFaceSim(){
	var face_1=parseInt($("face1Sim").selectedIndex,10);
	var face_2=parseInt($("face2Sim").selectedIndex,10);
	var face_3=parseInt($("face3Sim").selectedIndex,10);
	if(face_3 < 9){
		$("face3Sim").selectedIndex=face_3 + 1
		showFaceSim();
	}else{
		if(face_2 < 9){
			$("face2Sim").selectedIndex=face_2 + 1
			$("face3Sim").selectedIndex=0
			showFaceSim();
		}else{
			if(face_1 < 4){
				$("face1Sim").selectedIndex=face_1 +1
				$("face2Sim").selectedIndex=0
				$("face3Sim").selectedIndex=0
				showFaceSim();
			}
		}
	}
}
function preView(){
	var s=$("txtContent").value;
	s=s.replace(/&/ig,"&amp;") 
	s=s.replace(/>/ig,"&gt;") //>
	s=s.replace(/</ig,"&lt;") //<
	s=s.replace(/\t/ig,"&nbsp;&nbsp;&nbsp;") //Tab
	s=s.replace(/"/ig,"&quot;") //"
	s=s.replace(/'/ig,"&#39;") //'
	s=s.replace(/\r/ig,"") //回车是一个13+10
	s=s.replace(/\n\n/ig,"<P>") // 
	s=s.replace(/\n/ig,"<BR>") //换行
	s=s.replace(/\x20/ig,"&nbsp;") //空格 
	s=s.replace("\n","<br>");

	var re=/\[url=([^\/].*?)\]\[img\]([^\/].*?)\[\/img\]\[\/url\]/gi;
	s=s.replace(re,"<div><a href='$1' target=_blank><img src='$2' vspace=10 border=0></a></div>")

	re=/\[img\](.+?)\[\/img\]/gi;
	s=s.replace(re,"<div><img src='$1' vspace=10 border=0></div>");

	re=/\[b\](.*?)\[\/b\]/gi;
	s=s.replace(re,"<b>$1</b>");
	re=/\[color=([^\/].*?)\]([^\/].*?)\[\/color\]/gi;
	s=s.replace(re,"<font color=$1>$2</font>");
/*
	re=/\[QT=*([0-9]*),*([0-9]*)\](.*?)\[\/QT]/ig;
	s=s.replace(re,"<embed src=$3 width=$1 height=$2 autoplay=true loop=false controller=true playeveryframe=false cache=false scale=TOFIT bgcolor=#000000 kioskmode=false targetcache=false pluginspage=http://www.apple.com/quicktime/>")
	re=/\[MP=*([0-9]*),*([0-9]*)\](.*?)\[\/MP]/ig;
	s=s.replace(re,"<object align=middle classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 class=OBJECT id=MediaPlayer width=$1 height=$2 ><PARAM NAME=AUTOSTART VALUE=0><param name=ShowStatusBar value=-1><param name=Filename value=$3><embed type=application/x-oleobject codebase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701 flename=mp src=$3  width=$1 height=$2></embed></object>")
	re=/\[RM=*([0-9]*),*([0-9]*)\](.*?)\[\/RM]/ig;
	s=s.replace(re,"<OBJECT classid=clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA class=OBJECT id=RAOCX width=$1 height=$2><PARAM NAME=SRC VALUE=$3><PARAM NAME=CONSOLE VALUE=Clip1><PARAM NAME=CONTROLS VALUE=imagewindow><PARAM NAME=AUTOSTART VALUE=0></OBJECT><br><OBJECT classid=CLSID:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA height=32 id=video2 width=$1><PARAM NAME=SRC VALUE=$3><PARAM NAME=AUTOSTART VALUE=0><PARAM NAME=CONTROLS VALUE=controlpanel><PARAM NAME=CONSOLE VALUE=Clip1></OBJECT>")
*/
	$("showContent").innerHTML=s
}
var txt="";
function getActiveText(selectedtext) {
	var ie=/msie/ig.test(navigator.userAgent);
	if(ie) {
		txt=document.selection.createRange().text;
	} else {
		txt=document.getSelection();
	}
	if(selectedtext.createTextRange) {
		selectedtext.caretPos=document.selection.createRange().duplicate();
	}
	return true;
}

function addText(txt) {
	if ($("txtContent").createTextRange && $("txtContent").caretPos) {
		var caretPos=$("txtContent").caretPos;
		caretPos.text=caretPos.text.charAt(caretPos.text.length - 1)==' ' ? txt + ' ' : txt;
	} else {
		$("txtContent").value+=txt;
	}
	preView();
	setfocus();
}
function setfocus(){
	$("txtContent").focus();
}
function bold(){
	if(txt=="" || txt==null){
		txt="文字";
		txt=prompt("文字将被变粗.",txt);
	}
	if(txt!=null){
		txt="[b]"+txt;
		addText(txt);
		txt="[/b]";
		addText(txt);
	}
}
function showcolor(color) {
	if(txt==null) txt="";
	AddTxt="[color="+color+"] "+txt+" [/color]";
	addText(AddTxt);
	$("color").value="";
}

function setCtrl(ctrl) {
		switch (ctrl)
		{	
			case 'SWF':
				urlname="/images/swf.htm";
				var thisvalue=window.showModalDialog(""+urlname,"","dialogWidth:28;dialogHeight:11;dialogTop:100;dialogLeft:200;help:off;status:no;scroll:off;");
				if (thisvalue!=null) 
				{
					a=thisvalue.toString().split('@@@');
					//if (a.length==3) {
					//	AddTxt="\n\r[FLASH="+a[1]+","+a[2]+"]"+a[0]+"[/FLASH]\n\r";	
					    AddTxt="\n\r[FLASH]"+a+"[/FLASH]\n\r";
						addText(AddTxt);	
					//}
				}
				break;
			case 'SHOCKWAVE':
				urlname="/images/swav.htm";
				var thisvalue=window.showModalDialog(""+urlname,"","dialogWidth:28;dialogHeight:11;dialogTop:100;dialogLeft:200;help:off;status:no;scroll:off;");
				if (thisvalue!=null) 
				{
					a=thisvalue.toString().split('@@@');
					if (a.length==3) {
						AddTxt="\n\r[DIR="+a[1]+","+a[2]+"]"+a[0]+"[/DIR]\n\r";	
						addText(AddTxt);	
					}
				}
				break;
			case 'QUICKTIME':
				urlname="/images/quicktime.htm";
				var thisvalue=window.showModalDialog(""+urlname,"","dialogWidth:28;dialogHeight:11;dialogTop:100;dialogLeft:200;help:off;status:no;scroll:off;");
				if (thisvalue!=null) 
				{
					a=thisvalue.toString().split('@@@');
					if (a.length==3) {
						AddTxt="\n\r[QT="+a[1]+","+a[2]+"]"+a[0]+"[/QT]\n\r";	
						addText(AddTxt);	
					}
				}
				break;
			case 'RM':
				urlname="/images/rm.htm";
				var thisvalue=window.showModalDialog(""+urlname,"","dialogWidth:28;dialogHeight:11;dialogTop:100;dialogLeft:200;help:off;status:no;scroll:off;");
				if (thisvalue!=null) 
				{
					a=thisvalue.toString()//.split('@@@');
					//if (a.length==3) {
					//	AddTxt="\n\r[RM="+a[1]+","+a[2]+"]"+a[0]+"[/RM]\n\r";
					    AddTxt="\n\r[RM]"+a+"[/RM]\n\r";
						addText(AddTxt);
					//}
				}
				break;
			case 'MEDIA':	
				urlname="/images/media.htm";
				var thisvalue=window.showModalDialog(""+urlname,"","dialogWidth:28;dialogHeight:11;dialogTop:100;dialogLeft:200;help:off;status:no;scroll:off;");
				if (thisvalue!=null) 
				{
					a=thisvalue.toString()//.split('@@@');
					//if (a.length==3){
						//AddTxt="\n\r[MP="+a[1]+","+a[2]+"]"+a[0]+"[/MP]\n\r";
						AddTxt="\n\r[MP]"+a+"[/MP]\n\r";
						addText(AddTxt);
					//}
				}
				break;
		}
}

function isIE() {
	if(document.all) return true;
	return false;
} 
function ctlent(eventobject){
    if(isIE()){
        if(event.ctrlKey && window.event.keyCode==13){
	        $("form1").btnSubmit.click();
        }
    }
    else{
        if(eventobject.ctrlKey && window.eventobject.keyCode==13){
	        $("form1").btnSubmit.click();
        }
    }
	
}

/*
2006 - 06 - 21加入上传附件功能
*/
var form_count=0,real_count=0;
function add(){
	if(real_count>9){
		alert("你已经超过了10个附件,不能再添加附件!");
		return;
	}
	var new_attachment=document.createElement('<input name=attachment_' + form_count+'>');
	new_attachment.setAttribute('id', 'attachment_' + form_count);
	new_attachment.setAttribute('type', 'file');
	new_attachment.setAttribute('size', '44');
	$("divAttach").appendChild(new_attachment);
	//var  bt = $('attachment_' + form_count);
	//bt.click();
	//if(bt.value.length>0){
	    form_count++;
	    real_count++;
	//}else{
	//	$("divAttach").removeChild($('attachment_' + form_count));
	//}
}