function getIdObj(id) {
	return document.getElementById(id);
}

function ctrlEnterSubmit(event){

	if((event.ctrlKey && event.keyCode == 13)) {
		getIdObj('button3').click();
	}
}

function enterSubmit(event){
	
	var evt = event || window.event; 
	
	if((evt.keyCode == 13)) {
		getIdObj('formSubmit').click();
	}
}

var updateVerifyCode =function (id) {

	if ($('#'+id).css('display') == 'none') {
		changeVerifyCode(id);
	}
}

var changeVerifyCode =function (id) {
	var s=$('#'+id);
	if(s){
		s.css('display','none');
		s.attr('src','/js/verifyCode.php?rand='+Math.random());
		s.css('display','');
	}
}

function uploadImgContent(text)
{	
	getIdObj('conArea').value+='[img='+text+'][/img]';
}


//回复引用

function html_trans(str) {
	var str;
	str = str.replace(/<\/embed>/ig,"");
    str = str.replace(/[\r\n]/g,"");
	str = str.replace(/<b>(.*?)<\/b>/ig,"[b]$1[/b]");
	str = str.replace(/<i>(.*?)<\/i>/ig,"[i]$1[/i]");
	str = str.replace(/<u>(.*?)<\/u>/ig,"[u]$1[/u]");
	str = str.replace(/<p>(.*?)<\/p>/ig,"[p]$1[/p]");
	str = str.replace(/<font[^>]+color="([^">]+)"[^>]*>(.*?)<\/font>/ig,"[color=$1]$2[/color]");
	str = str.replace(/<font[^>]+color=([^ >]+)[^>]*>(.*?)<\/font>/ig,"[color=$1]$2[/color]");
	str = str.replace(/<embed[^>]+src=([^ ]+)[^>]*>/ig,"[swf=$1][/swf]");
	str = str.replace(/<embed[^>]+src="([^"]+)"[^>]*>/ig,"[swf=$1][/swf]");
	str = str.replace(/<a[^>]+href="(http|https|mms|rstp|ed2k|ftp|news|thunder|tencent|gopher|telnet)([^"]+)"[^>]*><img[^>]+src="([^"]+)"[^>]*><\/a>/ig,"[img=$3][/img]");
	str = str.replace(/<a[^>]+href="(http|https|mms|rstp|ed2k|ftp|news|thunder|tencent|gopher|telnet)([^"]+)"[^>]*>(.*?)<\/a>/ig,"[url=$1$2]$3[/url]");
	str = str.replace(/<blockquote>/ig,"[quote]");
	str = str.replace(/<\/blockquote>/ig,"[/quote]");
	str = str.replace(/<br>/ig,"[br]");
	str = str.replace(/&nbsp;/g," ");
	str = str.replace(/&amp;/g,"&");
	str = str.replace(/&quot;/g,"\"");
	str = str.replace(/&lt;/g,"<");
	str = str.replace(/&gt;/g,">");
	str = str.replace(/\[br\]问答积分(.*)/g,"");
	str = str.replace(/\[br\]\[color=red\]最佳答案\[\/color\](.*)/g,"");
    return str;
}

function quoteMsg(msgId){

	var quoteHTML=html_trans($('#__Message_' + msgId).html());

    var quoteMessage = "[quote]" + quoteHTML + "[/quote]";

	$('#comment').find("#conArea").focus();

	$('#comment').find("#conArea").val(quoteMessage);

}