/* 设置BaseAjax请求路径 */
function setAjaxBaseUrl(url){
    ajaxbaseurl = url;
}

/*去左右空格*/
function trim(str){
	str = str.replace(/\s*$/, "");
	str = str.replace(/^\s*/, "");
	return str;
}

/*插入表情*/
function insertEM(tag, textarea){
	var themess = document.getElementById(textarea);//编辑对象
	themess.focus();
	if (document.selection) {
		var theSelection = document.selection.createRange().text;//获取选区文字
		if(theSelection){
			document.selection.createRange().text = theSelection = tag + theSelection;//替换
		}else{
			document.selection.createRange().text = tag;
		}
		theSelection='';
	}else{
		var scrollPos = themess.scrollTop;
		var selLength = themess.textLength;
		var selStart = themess.selectionStart;//选区起始点索引，未选择为0
		var selEnd = themess.selectionEnd;//选区终点点索引
		if (selEnd <= 2){
			selEnd = selLength;
		}
		var s1 = (themess.value).substring(0,selStart);//截取起始点前部分字符
		var s2 = (themess.value).substring(selStart, selEnd)//截取选择部分字符
		var s3 = (themess.value).substring(selEnd, selLength);//截取终点后部分字符
		themess.value = s1 + tag + s2 + s3;//替换
		themess.focus();
		themess.selectionStart = newStart;
		themess.selectionEnd = newStart;
		themess.scrollTop = scrollPos;
		return;
	}
}
