
function showFace(rid,commentdiv)
{
	var strTarget = rid ;
	
	if(commentdiv=="commentcontentreply") strTarget+= "reply";
	var img_Path = $("css_path").value ;
	var strHtml = '<span style="position:absolute;width:250px;" >';
	var des_Path = img_Path + "images/face/";
		strHtml += '<img class="imgbd0" src="'+des_Path+'face.gif" title="插入表情" onclick="setContent(\''+commentdiv+'\',\''+rid+'\',\''+strTarget+'\');" id="faceImg'+strTarget+'">';
		strHtml += '<div id="faceDiv'+strTarget+'" style="left:0px; top:15px !important; top:19px; position:absolute; z-index:999; display:none;border:1px solid #E6E6E6;background-color:#FFFFFF;">';
		strHtml += '</div></span>';
		return strHtml ;
}

function setContent(commentdiv,rid,strTarget){
	var obj = $("faceDiv"+strTarget);
	if(obj.innerHTML==""){
		var img_Path = $("css_path").value ;
		var des_Path = img_Path + "images/face/";
		var aFace = new Array("微笑", "乖", "偷笑", "眨眼", "吐舌头", "喜欢", "哭", "咬牙", "气愤", "冒火", "委屈", "生气", "痛苦", "冤枉", "吐", "酷", "惊讶", "脸红", "小声", "不", "想", "晕", "怪", "睡觉", "困", 
		"闭嘴", "牛", "不好", "生病", "示爱", "感冒", "好吃", "叹", "小心", "钱", "可爱", "疑问", "帅", "邮件", "亲","妩媚女孩","握手","烧香","地雷","敲头","阴险","流泪","心碎","可怜","哼哼","下雨","鼓掌","OK","作揖","胜利","狂吐","折磨","鄙视","拜拜","猪头","便便","菜刀","音乐","饭","礼物");
		var strHtml="";
		strHtml += '<table>';
		for(var i=1 ; i<=65;i++){
			if(i%13==1) strHtml += '<tr>';
			strHtml += '<td align=center><img src="'+des_Path+i+'.gif" onclick=onImage(\"'+i+'.gif\",\"'+commentdiv+rid+'\",\"faceDiv'+strTarget+'\");   title=\"'+ aFace[i-1]+'\" height=19px width=19px onmouseout="this.style.background=\'\';this.style.cursor=\'pointer\'; " onmouseover="this.style.background=\'#99CCFF\';this.style.cursor=\'pointer\';"></td>';
			if(i%13==0) strHtml += '</tr>';
		}
		strHtml += '</table>';
		obj.innerHTML=strHtml ;	
	}
	obj.style.display==''?obj.style.display='none':obj.style.display='' ;
}

function onImage(strUrl,textarea,divName) 
 {
    obj = $(textarea);
    txt = "[FACE]" + strUrl + "[/FACE]";
    selection = document.selection;
    obj.focus();
    if (typeof obj.selectionStart != "undefined") {
        var s = obj.selectionStart;
        obj.value = obj.value.substr(0, obj.selectionStart) + txt + obj.value.substr(obj.selectionEnd);
        obj.selectionEnd = s + txt.length;
    } else if (selection && selection.createRange) {
        var sel = selection.createRange();
        sel.text = txt;
    } else {
        obj.value += txt;
    }
    $(divName).style.display = 'none';
}

function unBar_rsm(str)
{/*先替换表情图片再替换其他图片*/
	var re1 = /\<img [^>]* src=\"(?:[^(\<)]+)\/skin\/images\/face\/(.+?)\">/gi;
	var re2 =/\n\n/g;
	var re3 =/\<[^>].+?>/ig;
	var str = str.replace(re1, "[FACE]$1[/FACE]");
		str = str.replace(re2, "\n");
		str=str.replace(re3,'');

	return (str);
}
function saveCall(strHtml)
{
	var re1 = /\[FACE\](.*?)\[\/FACE\]/g;
	var re2 = /\</g;
	var re3 = /\>/g;
	var path = $("css_path").value ;
		path+="images/face/";
		strHtml = strHtml.replace(re2, "&lt;");
		strHtml = strHtml.replace(re3, "&gt;");
		strHtml = strHtml.replace(re1, "<img class='imgbd0' style='height:19px;width:19px;' src=\"" + path + "$1\" >");
	return strHtml;
}

