﻿function isEmail(mail){
	return(new RegExp(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/).test(mail)); 
} 
function chkForm_AddReco(obj)
{
    if(obj.content.value == "")
    {
        obj.content.focus();
        alert("请输入[内容]");
        return false;
    }
    if(obj.username.value == "")
    {
        obj.username.focus();
        alert("请输入[用户名]");
        return false;
    }
    if(obj.email.value != "" && !isEmail(obj.email.value))
    {
        obj.email.focus();
        alert("请输入[正确的Email]");
        return false;
    }
    return true;
}
function grin(tag) {
        var myField;
        if (document.getElementById('content') && document.getElementById('content').type == 'textarea') {
                myField = document.getElementById('content');
        }
        else {
                return false;
        }
        if (document.selection) {
                myField.focus();
                sel = document.selection.createRange();
                sel.text = tag;
                myField.focus();
        }
        else if (myField.selectionStart || myField.selectionStart == '0') {
                var startPos = myField.selectionStart;
                var endPos = myField.selectionEnd;
                var cursorPos = endPos;
                myField.value = myField.value.substring(0, startPos)
                                          + tag
                                          + myField.value.substring(endPos, myField.value.length);
                cursorPos += tag.length;
                myField.focus();
                myField.selectionStart = cursorPos;
                myField.selectionEnd = cursorPos;
        }
        else {
                myField.value += tag;
                myField.focus();
        }
}
function replyComment_close()
{
	document.getElementById("reply_html").style.display="none";
	document.if2f_comment.reply.value="";
}
function replyComment(str)
{
	newHTML=document.getElementById("content_"+str).innerHTML;
	document.getElementById("reply_html").style.display="";
	document.getElementById("reply_html").innerHTML="<b style='color:#000000'>您所要回应的评论为：</b>(<a onclick='replyComment_close()' style='padding-left:50%;cursor:pointer'><b style='color:#61A2CD'><u>取消回应该评论</u></b></a>)<br/><br/>"+newHTML+"<br/>";
	document.if2f_comment.reply.value=str;
	document.getElementById("content").focus();
}
