﻿    var pagecount=0;
    function doMessage()
    {
        var susername=$("#username").val();
        var semail   =$("#email").val();
        var sphone   =$("#phone").val();
        var saddress =$("#address").val();
        var scontent =$("#content").val();
        $("#loading").html("<img src='/Script/loading.gif' />");
        if($("#yzm2").html()!=$("#yzm").val())
        {
            alert("请输入正确的验证码.");
            $("#yzm").focus();
            $("#loading").html("");
             return false;
        }
        if(susername=="")
        {
             alert("您尚未输入姓名！");
             $("#username").focus();
              $("#loading").html("");
             return false;
        }
        if(scontent=="")
        {
             alert("请输出内容！");
             $("#content").focus();
              $("#loading").html("");
             return false;
        }
       
        $("#do").click(function() 
        {
		    $("#form1")[0].reset();
	    });
//alert(documentid);
//return false;
        $.get("AddComments.axd",
        {username:susername,email:semail,phone:sphone,address:saddress,content:scontent,did:documentid},
        function(data)
        {
            alert(data);
            $("#loading").html("");
            GetAllMsg(documentid,1);
        }
        
        );
    }
    function GetAllMsg(documentid,page)
    {
        $("#commentsList").html("<span style=\"color:green;font-weight:bold;\">正在载入留言列表....</span>");
        $.ajax({
            type:"POST",
            url:"GetAllMsg.axd?did=" + documentid + "&page="+page+"&"+parseInt(Math.random() * 1000),
            dataType:"html",
            data:"",
            success:function(result)
            {
                $("#commentsList").html(result);
            }
        });
    }
   $(document).ready(function() {
   $("#yzm2").html(parseInt(Math.random() * (9999-1000)+1000));
	GetAllMsg(documentid,1);
    });



/*-----------------------------------------------------------*/
document.writeln("    <form id=\"form1\">");
document.writeln("    <div>");
document.writeln("    <div id=\"commentsList\"><\/div>");
document.writeln("    <div id=\"loading\"><\/div>");
document.writeln("    <fieldset>");
document.writeln("    <legend>*****请您留言*****<\/legend>");
document.writeln("    <table width=\"100%\" cellpadding=\"2\" cellspacing=\"2\">");
document.writeln("    <tr><td class='c1'>名称:<\/td><td><input type=\"text\" id=\"username\" \/><font color=red>*<\/font><\/td><\/tr>");
document.writeln("    <tr><td class='c1'>邮件:<\/td><td><input type=\"text\" id=\"email\" \/><\/td><\/tr>");
document.writeln("    <tr><td class='c1'>电话:<\/td><td><input type=\"text\" id=\"phone\" \/><\/td><\/tr>");
document.writeln("    <tr><td class='c1'>地址:<\/td><td><input type=\"text\" id=\"address\" \/><\/td><\/tr>");
document.writeln("    <tr><td class='c1'>内容:<\/td><td><textarea id=\"content\" cols=\"40\" rows=\"5\"><\/textarea><font color=red>*<\/font><\/td><\/tr>");
document.writeln("    <tr><td class='c1'>验证码:<\/td><td><input type=\"text\" id=\"yzm\" \/><font color=red>*<\/font><span id=\"yzm2\"><\/span> <\/td><\/tr>");
document.writeln("    <tr><td><\/td><td><input id=\"do\" type=\"button\" value=\"提交\" onclick=\"doMessage()\"\/><\/td><\/tr>");
document.writeln("    <\/table>");
document.writeln("    <\/fieldset>");
document.writeln("    <\/div>");
document.writeln("    <\/form>");
