﻿function Login(UserName, Password) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: "WebService_Web.asmx/Login",
        data: "{UserName:'" + UserName + "',Password:'" + Password + "'}",
        dataType: 'json',
        success: function (result) {

            if (result.d == true) {
                //alert(result.d);
                $("#LOGINPANEL0").html("当前用户： " + UserName + " <a  style=\"cursor:pointer; color:#a4a4a4;\" onclick=\"LogOut()\">[退出]</a></div>");
                $("#LOGINPANEL1").html("");
                $("#LOGINPANEL2").html("");
                $("#LOGINPANEL3").html("");
            }
            else {
                alert("登录失败，请检查您的用户名和密码输入是否正确");
            }
        }
    });
}

function LogOut() {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: "WebService_Web.asmx/LogOut",
        data: "{}",
        dataType: 'json',
        success: function (result) {
                $("#LOGINPANEL0").html("用户名：<input name=\"\" id=\"username\" type=\"text\" class=\"inputlogin\" />&nbsp;&nbsp;密码：<input name=\"\" id=\"password\" type=\"password\" class=\"inputlogin\" />");
                $("#LOGINPANEL1").html("<img src=\"images/login_btn.gif\" style=\"cursor:pointer\"  onclick=\"Login($('#username').val(),$('#password').val())\" />");
                $("#LOGINPANEL2").html("<a href=\"reg.aspx\"><img src=\"images/reg_btn.gif\" /></a><a href=\"forgetpwd.aspx\"><img src=\"images/forget_btn.gif\" /></a>");
                $("#LOGINPANEL3").html("您也可以用合作账号登录&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"weiboreg.aspx\" class=\"a-aaa\">新浪微博</a>");

        }
    });

    }


    function InsertComment(NewsId, CommentContent) {
        if (CommentContent != "") {
            if ($("#cb_noname").attr("checked") == false) {
                $.ajax({
                    type: "POST",
                    contentType: "application/json",
                    url: "WebService_Web.asmx/InsertComment",
                    data: "{NewsId:'" + NewsId + "',CommentContent:'" + CommentContent + "'}",
                    dataType: 'json',
                    success: function (result) {
                        if (result.d == true) {
                            alert("提交成功,正在审核中...");
                        }
                        else {
                            alert("提交失败");
                        }
                    }
                });
            }
            else {
                $("#user").focus();

            }


        }
        else { 
        alert("请填写评论内容")
        
        }
        
        
    
    }
