﻿// ---------------------------------------------------------------------------------------------------
// Control部分（控制部分 按钮事件等）
// ---------------------------------------------------------------------------------------------------
function fastReply()
{
    window.scrollTo(0, document.body.clientHeight);
    __setEditorFocus();
}

function fastQuote(id, topicId, nickname, createTime)
{
    var source = document.getElementById(id);
    document.getElementById("quoteContent").innerHTML = source.innerHTML;
    document.getElementById("quoteInfo").innerText = nickname + " 发表于 " + createTime;
    document.getElementById("quoteDisplayDiv").style.display = "";
    document.getElementById("quotedId").setAttribute("value", topicId);
    
    window.scrollTo(0, document.body.clientHeight);
    __setEditorFocus();
}
function fastDeleteReply(id, conId, toolsId)
{
    if(confirm("是否确定要删除此回复？"))
    {
    var con = document.getElementById(conId);
    var tools = document.getElementById(toolsId);
    
    xmlAjax.load("/API/Forum.aspx?fid=deletequote&rid=" + id);
    ajaxDeleteReply(conId, toolsId);   
    } 
}

function cancelQuote()
{
    document.getElementById("quoteContent").innerHTML = "";
    document.getElementById("quoteInfo").innerText = "";
    document.getElementById("quoteDisplayDiv").style.display = "none";
    document.getElementById("quotedId").setAttribute("value", "0");
}



// Ajax Delete Reply
var timerDeleteReply;
function ajaxDeleteReply(conId, toolsId)
{ 
    window.clearTimeout(timerDeleteReply);
    if(xmlAjax.readyState == "4")
    {
        window.status = "删除回复中，请稍候...";

        var result = xmlAjax.documentElement.childNodes.item(0).text;
        if(result == "done")
        {
            window.status = "回复删除完毕！";
            var con = document.getElementById(conId);
            con.innerHTML = "<div class=\"deleted\">回复已删除！</div>";
            document.getElementById(toolsId).style.display = "none";
            return false;
        }
        else
        {
            alert("发生意外，请与管理员联系！");
            window.clearTimeout(timerDeleteReply);
            return true;
        }
    }
    else
    {
        window.status = "删除回复中，请稍候...";
        timerDeleteReply = window.setTimeout("ajaxDeleteReply('" + conId + "', '" + toolsId + "')", 250);
    }
}

























// ---------------------------------------------------------------------------------------------------
// 页面功能函数（控制部分 按钮事件等）
// ---------------------------------------------------------------------------------------------------
function validateAddReply(id)
{
    var qid = document.getElementById("quotedId").getAttribute("value");
    document.getElementById(id).setAttribute("value", qid); 
                
    if(__getEditorValue() == "")
    {
        alert("请填写回复内容！");
        __setEditorFocus();
        return false;
    }
    else
    {
        var replyWords = __getEditorValue().replace(/&nbsp;/g,"");
        if(replyWords.length < 5)
        {
            alert("请填写回复内容必须超过5个字！");
            __setEditorFocus();
            return false;
        }
    }
    
    copyEditorValue();

    return true;
}

function validateModifyReply(id)
{
    if(__getEditorValue() == "")
    {
        alert("请填写回复内容！");
        __setEditorFocus();
        return false;
    }
    else
    {
        var replyWords = __getEditorValue();
        if(replyWords.length < 10)
        {
            alert("请填写回复内容必须超过10个字！");
            __setEditorFocus();
            return false;
        }
    }

    copyEditorValue();

    return true;
}




function copyEditorValue()
{
    window.clipboardData.setData('text', __getEditorValue());
}


function getBackEditorValue()
{
    __setEditorValue(window.clipboardData.getData("text"));
}























//----
function thumbImg(obj)
{}