﻿
var layer=document.getElementById("repalylayer");
$("div.Win_overlay").css("height",document.documentElement.offsetHeight+"px");
var ft=parseInt(document.documentElement.scrollTop+(document.documentElement.clientHeight-layer.offsetHeight)/2);
layer.style.top=ft+"px";
var flag=0; 
var speed=10;
var acc=2;

function move(){
var t=layer.style.top;
var top=parseInt(t.substring(0,t.length-2));
var myhigh=parseInt(document.documentElement.scrollTop+(document.documentElement.clientHeight-layer.offsetHeight)/2);
if(top<myhigh-speed){layer.style.top=top+speed+"px";}
else if(top>myhigh+speed){layer.style.top=top-speed+"px";}
setTimeout("move()",2);
} 

function scall(){if(flag==0){move();flag=1;}}



function closerepaly(){
    $(layer).hide();
    $("div.Win_overlay").hide();
    
}

function Add(){
    var ArticleID=$("#ArticleID").val();
    if($("#Content").val()==""||$("#Content").val()=="在此发表评论！"){
        alert("请输入评论内容");
        $("#Content").focus();
        return;
    }
    if($("#Content").val().length>5000){
        alert("评论内容过长");
        $("#Content").focus();
        return;      
    }
    var Info={};
    Info.Content=$("#Content").val();
    Info.ArticleID=ArticleID; 
    $.post("/ArticleComment.Add.data",Info,function(data){
        if(data=="ok"){
            alert("发表成功");
            location.reload();
        }else{
            alert(data);
        }
    })
}

function Support(ID){
    var ArticleID=$("#ArticleID").val();
    $.post("/ArticleComment.Support.data",{ID:ID,ArticleID:ArticleID},function(data){
        self.location.reload();
    })
}

function Del(ID){
    var ArticleID=$("#ArticleID").val();
    $.post("/ArticleComment.Del.data",{ID:ID,ArticleID:ArticleID},function(data){
     if(data=="ok"){
            alert("删除成功");
            self.location.reload();
        }else{
            alert(data);
        }        
    })
}

function Against(ID){
    var ArticleID=$("#ArticleID").val();
    $.post("/ArticleComment.Against.data",{ID:ID,ArticleID:ArticleID},function(data){
        self.location.reload();
    })
}

function Repaly(){
    var ArticleID=$("#ArticleID").val();
    if($("#repalycontent").val()==""||$("#repalycontent").val()=="在此发表评论！"){
        alert("请输入评论内容");
        $("#repalycontent").focus();
        return;
    }
    var Info={};
    Info.Content=$("#repalycontent").val();
    //Info.hidename=$("#repalyhidename")[0].checked;
    Info.ArticleID=ArticleID;
    Info.ParentID=repalyid
    $.post("/ArticleComment.Add.data",Info,function(data){
        if(data=="ok"){
            alert("发表成功");
            location.reload();
        }else{
            alert(data);
        }
    })
}

function PreRepaly(id){
    repalyid=id;
    $(layer).show();
    $("#repalycontent").focus();
    $("div.Win_overlay").show();
}

window.onscroll=scall;
