var $imt = jQuery.noConflict(); //jquery 有冲突，我重新定义了一下

$imt(document).ready(function() {   
if ($imt('#commentform').length) {
    $imt('#commentform').submit(function(){    //ID为 commentform 的表单提交时发生的函数，也就是整个留言输入框 form 的ID。
        jQuery.ajax({
            url:  'http://blog.xiao3.info/wordpress/wp-content/themes/xiaosan/templates/comments-ajax.php',    //刚刚创建的 comments-ajax.php 文件的位置的绝对路径。
            data: $imt('#commentform').serialize(),   
            type: 'POST',
            beforeSend: function() {   //post数据以前执行的动作
   $imt('#reply .imt-request').remove(); //移除 '#reply .imt-request'这个节点
   $imt('#commentform').block({ //使用blockUI插件写出提示
                message: '<img src="http://www.xiao3.info/image/loading.gif" />正在提交评论请稍候～',
    fadeIn: 1000,
    fadeOut: 1000,
                css: {width: '350px', top: '10px',left: '', right: '10px', border: 'none',  padding: '5px',  backgroundColor: '#000000', '-webkit-border-radius': '10px', '-moz-border-radius': '10px', opacity: .6, color: '#fff',cursor:'wait' } 
            });
            },
            error: function(request) {    //数据返回发生错误时，也就是非200状态，一般是500
                $imt('#commentform').block({ //使用blockUI插件重新写出提示
     message: '<img src="http://www.xiao3.info/image/loading.gif" />'+request.responseText,
     fadeIn: 1000, fadeOut: 1000, timeout: 5000,
     showOverlay: false, centerY: false,
     css: {width: '350px', top: '10px',left: '', right: '10px', border: 'none',  padding: '5px',  backgroundColor: '#000000', '-webkit-border-radius': '10px', '-moz-border-radius': '10px', opacity: .6, color: '#fff',cursor:'wait' }
    });
    //因为blockUI插件写出的提示是转瞬即逝的，所以又加入了这样的一个东西
    var imterror='<span style="color: rgb(255, 0, 0); font-size: 0.9em; font-weight: bold;">[提交失败]<span style="color: rgb(0, 0, 0); font-weight: normal; font-size: 12px;">'+request.responseText+'</span></span>';
    $imt('#reply').append(imterror); //这里是要插入的位置，我插入在#reply'里面的
    var imt_error=$imt('#reply .imt-request').hide();//把插入的内容隐藏起来
    imt_error.fadeIn(1000); //再用一个比较好看的方式显示出插入的内容
            },
            success: function(data) { //数据返回正确，也就是200状态
                $imt('textarea').each(function(){ //清空评论内容
                    this.value='';
                });
    $imt('#reply').append('<span style="color: rgb(0, 58, 33); font-size: 0.9em; font-weight: bold;">[提交成功]</span>');
    var imt_error=$imt('#reply .imt-request').hide();
    imt_error.fadeIn(1000);
                if (!$imt('#thecomments').length) { //检查是否是第一条评论
     $imt('#respond').before('<ol id="thecomments"></ol>');//构建正确的 DIV结构
    }
                $imt('#thecomments').append(data);    //向ID为 comments 的元素添加返回的数据，也就是整个 ol
    var new_comment = $imt('#thecomments li:last').hide();    //让最新添加的数据隐藏
    new_comment.slideDown(1000);    //再显示，这里是为了实现滑出的效果，不想要也可以直接显示
                $imt('#commentform:input').attr('disabled', true);
                $imt('#commentform').block({
     message: '<img src="http://www.xiao3.info/image/loading.gif" />提交成功！感谢您参与这篇日志的讨论',
     fadeIn: 1500,  fadeOut: 1500, imeout: 4000,
     showOverlay: false,  centerY: false,
     css: {width: '350px', top: '10px',left: '', right: '10px', border: 'none',  padding: '5px',  backgroundColor: '#000000', '-webkit-border-radius': '10px', '-moz-border-radius': '10px', opacity: .6, color: '#fff',cursor:'wait' }
    });
    setTimeout(function() {
                $imt('#commentform:input').removeAttr('disabled');
                }, 15000);        //这里是设置15秒之后才可以再次留言，自行设置，单位毫秒。
            }
        });
       return false;