?/*********************************************************
// 目的?   输出UBB
// 输入?   ?
// 返回?   ?
//*********************************************************
function ExportUbbFrame() {

	objActive="content";	

	document.write("<p>")

	document.write("<a alt=\"\" onmousedown=\"InsertText(objActive,ReplaceText(objActive,'[url]http://','[/url]'),true);\" style=\"padding:2px;cursor:pointer;\">[链接]</a>")

	document.write("<a alt=\"\" onmousedown=\"InsertText(objActive,ReplaceText(objActive,'[url=http://]','[/url]'),true);\" style=\"padding:2px;cursor:pointer;\">[链接2]</a>")

	document.write("<a alt=\"\" onmousedown=\"InsertText(objActive,ReplaceText(objActive,'[email]','[/email]'),true);\" style=\"padding:2px;cursor:pointer;\">[邮件]</a>")

	document.write("<a alt=\"\" onmousedown=\"InsertText(objActive,ReplaceText(objActive,'[img]','[/img]'),true);\" style=\"padding:2px;cursor:pointer;\">[图像]</a>")

	document.write("<a alt=\"\" onmousedown=\"InsertText(objActive,ReplaceText(objActive,'[b]','[/b]'),true);\" style=\"padding:2px;cursor:pointer;\">[粗体]</a>")
	document.write("<a alt=\"\" onmousedown=\"InsertText(objActive,ReplaceText(objActive,'[i]','[/i]'),true);\" style=\"padding:2px;cursor:pointer;\">[斜体]</a>")
	document.write("<a alt=\"\" onmousedown=\"InsertText(objActive,ReplaceText(objActive,'[u]','[/u]'),true);\" style=\"padding:2px;cursor:pointer;\">[下划]</a>")

	document.write("<a alt=\"\" onmousedown=\"InsertText(objActive,ReplaceText(objActive,'[color=red]','[/color]'),true);\" style=\"padding:2px;cursor:pointer;\">[加红]</a>")
	document.write("<a alt=\"\" onmousedown=\"InsertText(objActive,ReplaceText(objActive,'[color=blue]','[/color]'),true);\" style=\"padding:2px;cursor:pointer;\">[加蓝]</a>")

//暂时取消视频类UBB代码
//	document.write("<a alt=\"\" onmousedown=\"InsertText(objActive,ReplaceText(objActive,'[mp]','[/mp]'),true);\" style=\"padding:2px;cursor:pointer;\">[MP]</a> ")
//	document.write("<a alt=\"\" onmousedown=\"InsertText(objActive,ReplaceText(objActive,'[rm]','[/rm]'),true);\" style=\"padding:2px;cursor:pointer;\">[RM]</a> ")
//	document.write("<a alt=\"\" onmousedown=\"InsertText(objActive,ReplaceText(objActive,'[swf]','[/swf]'),true);\" style=\"padding:2px;cursor:pointer;\">[FLASH]</a> ")

	document.write("</p>")
}
//*********************************************************




//*********************************************************
// 目的?   自动插入并替?
// 输入?   ?
// 返回?   ?
//*********************************************************
var objActive;
function GetActiveText(objHTML) {
	objActive=objHTML;
	if(document.selection){
		var obj=document.getElementById(objHTML);
		obj.currPos = document.selection.createRange().duplicate()
	}
}

function InsertText(objHTML,strText,bolReplace) {
	if(strText==""){return("")}
	var obj=document.getElementById(objHTML);
	if(document.selection){
		if (obj.currPos){
			if(bolReplace && (obj.value=="")){
				obj.currPos.text=strText
			}
			else{
				obj.currPos.text+=strText
			}
		}
		else{
			obj.value+=strText
		}
	}
	else{
		if(bolReplace){
			obj.value=obj.value.slice(0,obj.selectionStart) + strText + obj.value.slice(obj.selectionEnd,obj.value.length)
		}
		else{
			obj.value=obj.value.slice(0,obj.selectionStart) + strText + obj.value.slice(obj.selectionStart,obj.value.length)
		}
	}
	//obj.focus();
}

function ReplaceText(objHTML,strPrevious,strNext) {
	var obj=document.getElementById(objHTML);
	var strText;
	if(document.selection && document.selection.type == "Text"){
		if (obj.currPos){
			var range = document.selection.createRange();
			range.text = strPrevious + range.text + strNext;
			return("");
		}
		else{
			strText=strPrevious + strNext;
			return(strText);
		}
	}
	else{
		if(obj.selectionStart || obj.selectionEnd){
			strText=strPrevious + obj.value.slice(obj.selectionStart,obj.selectionEnd) + strNext;
			return(strText);
		}
		else{
			strText=strPrevious + strNext;
			return(strText);
		}
	}
}
//*********************************************************
