$(document).ready(function () {
var baseURL = "http://pay.wanlou.com/"
$("#wl_divMessage").html("<ul class='wl-comment'></ul> <div class='wl-form-comment'> <form id='form_message' name='form_message' method='post' action='" + baseURL + "LeaveWord.aspx'> <div class='wl-field'> <label class='label'>真实姓名：</label><div class='inputbox'> <input class='text address' type='text' name='txtMsgName' id='txtMsgName' maxlength='100' /></div> </div>  <div class='wl-field'> <label class='label'>手机号码：</label><div class='inputbox'> <input class='text address' type='text' name='txtMsgMobile' id='txtMsgMobile' maxlength='20' />&nbsp;&nbsp;您的个人联系信息不会被公开</div> </div> <div class='wl-field'> <label class='label'>电子邮件：</label><div class='inputbox'> <input class='text address' type='text' name='txtMsgEmail' id='txtMsgEmail' maxlength='100' /></div> </div> <div class='wl-field'> <label class='label'>留言内容：</label><div class='inputbox'> <textarea class='messagebox' name='txtMsgContent' id='txtMsgContent'></textarea></div> </div> <div class='wl-field'> <div class='inputbox'> <input type='hidden' name='hdPid' id='hdPid' value='' /><input class='wl-btn-order' type='submit' value='提交' /></div> </div> </form><a name='messages'></a> </div>");
    //加载留言列表
    $.getScript(baseURL + "ajax/MessageFormHandler.ashx?callback=wl_message_form&pid=" + form_message_param.pid + "&ps=" + form_message_param.ps + "&ts=" + Math.random(6));
    //留言翻页
    $("#wl_divMessage .wl-pagebottom a").live("click", function () {
        var pageIndex = $(this).attr("rel");
        $.getScript(baseURL + "ajax/MessageFormHandler.ashx?callback=wl_message_form&pid=" + form_message_param.pid + "&ps=" + form_message_param.ps + "&pi=" + pageIndex + "&ts=" + Math.random(6));
    });

    $("#hdPid").val(form_message_param.pid);

    $.validator.addMethod(
         "verifymobile",
        function (value, element) {
            var reg = /^(\+86)?(1[0-9]{10})$/;
            return reg.test(value);
        },
        '手机号码格式不正确，请重新输入'
     );

    //表单验证
    $("#form_message").validate({
        rules: {
            txtMsgName: {
                required: true
            },
            txtMsgMobile: {
                required: true,
                verifymobile: true
            },
            txtMsgEmail: {
                required: true,
                email: true
            },
            txtMsgContent: {
                required: true
            }
        },
        messages: {
            txtMsgName: {
                required: "请输入你的姓名！"
            },
            txtMsgMobile: {
                required: "请输入你的手机号码！"
            },
            txtMsgEmail: {
                required: "请输入你的邮箱！",
                email: "邮箱格式不正确，请重新输入！"
            },
            txtMsgContent: {
                required: "请输入你的留言内容！"
            }
        },
        errorElement: "em",
        success: function (label) {
            label.text("OK！").addClass("success");
        }
    });

});
document.writeln("<script type=\"text\/javascript\">");
document.writeln("var _bdhmProtocol = ((\"https:\" == document.location.protocol) ? \" https:\/\/\" : \" http:\/\/\");");
document.writeln("document.write(unescape(\"%3Cscript src=\'\" + _bdhmProtocol + \"hm.baidu.com\/h.js%3F9aeaf39acc5bf6b77bea8dbae8e23dd3\' type=\'text\/javascript\'%3E%3C\/script%3E\"));");
document.writeln("<\/script>");
document.writeln("<script type=\"text/javascript\" src=\"http://pay.wanlou.com/js/show.js\"></script>");