function CommentSubmit(art_id)
{
    var username = '';//document.getElementById("username").value;
    var email = '';//document.getElementById("email").value;
    var content = document.getElementById("editor_textarea").value;
    if(!document.login_status)
    {
        var username = document.getElementById("username").value;
        var    email = document.getElementById("email").value;
        if(username.length < 1 || username.length > 50)
        {   
            alert("请正确填写昵称");
            return;
        }   
        if(email.length < 1 || email.length > 100)
        {   
            alert("请正确填写Email");
            return;
        }
    }
    if(content.length < 1) 
    {   
        alert("请正确填写评论");
        return;
    } 
    $.post('http://'+document.domain+'/include/deal_data.php',{'username':username,'email':email,'content': content,'art_id' :art_id,'yzm':$('#yzm').val() ,'type' : 'com_sub'}, function(data) {
            if(data > 0)
            {
            alert("回复成功！");
            window.location.reload();
            }
            else if(data == '0')alert("内容不能为空！");
            else if(data == '-1')alert('验证码不正确！');
            else if(data == '-2')alert("回复未成功！");
            else if(data == '-3')
            {
                alert('您可能在别的地方已登陆,请重新登陆！');
                document.location='http://passport.metroer.com/logout.php?forward='+transform(document.location.href);
            }
            else alert(data);
    }); 
}
function FormSub()
{
    var username = document.getElementById("username").value;
    var email = document.getElementById("email").value;
    var content = document.getElementById("content").value;
    if(username.length < 1 || username.length > 50) 
    {   
        alert("请正确填写昵称");
        return false;
    }   
    if(email.length < 1 || email.length > 100)
    {   
        alert("请正确填写Email");
        return false;
    }   
    if(content.length < 1)  
    {   
        alert("请正确填写评论");
        return false;
    }
    var form1 = document.getElementById("form1");
    form1.submit()

}
function Comsubmit(formid)
{
    var username = '';//$("#username").val();
    var email = '';//$("#email").val();
    var content = document.getElementById("editor_textarea").value;
    if(!document.login_status)
    {
        username = $("#username").val();
        email = $("#email").val();
        if(username.length < 1 || username.length > 50)
        {   
            alert("请正确填写昵称");
            return;
        }   
        if(email.length < 1 || email.length > 100)
        {   
            alert("请正确填写Email");
            return;
        }
    }
    if(content.length < 1) 
    {   
        alert("请正确填写评论");
        return;
    } 
    $.post('http://'+document.domain+'/include/deal_data.php',{'username':username,'email':email,'content': content,'art_id' :$('#art_id').val(),'yzm':$('#yzm').val(),'type' : 'concom_add'}, function(data) {
            if(data == 1)
            { 
                alert("回复成功！");window.location=window.location;
            }
            else if(data == '0')  alert('该文章可能已删除！');
            else if(data == '-1') alert('验证码不正确！');
            else if(data == '-2') alert("回复未成功！");
            else if(data == '-3') 
            {
                alert('您可能在别的地方已登陆,请重新登陆！');
                document.location='http://passport.metroer.com/logout.php?forward='+transform(document.location.href);
            }
            //else  alert("请求错误！");
            else alert(data);
    }); 
}
function AddLinkByKey(keys,containerId)
{
    var containerId = containerId?containerId:'contentContainer';
    var container = document.getElementById(containerId);
    
    if(!container || keys.length==0)return;
    replaceNodeValue(container,keys);
}
function replaceNodeValue(obj,keys)
{
    chg_flag = false;
    if(obj.childNodes.length>0)
    {
        for(var i=0;i<obj.childNodes.length;i++)
        {
            node = obj.childNodes[i];
            if(node.nodeType ==3 && !chg_flag)
             {
                var text =node.nodeValue;
                for(var j=0;j<keys.length;j++)
                {
                    text = text.replace(keys[j].tag_name,"<a style=\"color:#ED5E7C\" href=\""+keys[j].link+"\">"+keys[j].tag_name+"</a>");
                }
                if(text !=node.nodeValue)
                {
                    $(node).replaceWith(text); 
                    chg_flag = true;
                }
             }
            else if(obj.childNodes[i].nodeType ==1 && !chg_flag )replaceNodeValue(obj.childNodes[i],keys);
        }
    }   
}
function StarCommentSubmit()
{   
    var login_ticket    = GetCookie('login_ticket');
    var login_username  = decodeURI(EncodeUtf8(GetCookie('login_username')));
    var login_uid       = GetCookie('login_uid');
    var login_status    = document.getElementById('login_status');
    document.login_uid = login_uid;
    document.login_username = login_username;
    document.login_ticket   = login_ticket;
    document.login_status   = true;

    var username = '';
    var email = '';
    var content = document.getElementById("editor_textarea").value;
    if(!document.login_status)
    {
        var username = document.getElementById("username").value;
        var    email = document.getElementById("email").value;
        if(username.length < 1 || username.length > 50)
        {   
            alert("请正确填写昵称");
            return;
        }   
        if(email.length < 1 || email.length > 100)
        {   
            alert("请正确填写Email");
            return;
        }
    }
    if(content.length < 1) 
    {   
        alert("请正确填写评论");
        return;
    }
    $.post('http://'+document.domain+'/include/deal_data.php',{'username':username,'email':email,'content': content,'star_id' :$('#star_id').val(),'yzm':$('#yzm').val() ,'type' : 'star_comment'}, function(data) {
            if(data > 0)
            {
                alert("回复成功！");
                window.location.reload();

            }
            else if(data == '0')alert("内容不能为空！");
            else if(data == '-1')alert('验证码不正确！');
            else if(data == '-2')alert("回复未成功！");
            else if(data == '-3')
            {
                alert('您可能在别的地方已登陆,请重新登陆！');
                document.location='http://passport.metroer.com/logout.php?forward='+transform(document.location.href);
            }
            else alert(data);
    }); 
}

