/** WordPress jQuery-Ajax-Comments v1.3 by Willin Kan **/
var i=0,got=-1,len=document.getElementsByTagName("script").length;while(i<=len&&got==-1){var js_url=document.getElementsByTagName("script")[i].src,got=js_url.indexOf("comments-ajax.js");i++}var ajax_php_url=js_url.replace("-ajax.js","-ajax.php"),oktxt='<img src="'+js_url.substring(0,js_url.indexOf("wp-content"))+'wp-admin/images/yes.png" style="vertical-align:middle" alt=""/> 提交成功',num=1,wait=15;jQuery(document).ready(function($){$comments=$("#comments-title span");$cancel=$("#cancel-comment-reply-link");$submit=$("#commentform #submit");$submit.attr("disabled",false);var submit_val=$submit.val();$("#commentform").submit(function(){$submit.val("正在提交").attr("disabled",true).fadeTo("slow",0.5);$.ajax({url:ajax_php_url,data:$(this).serialize(),type:$(this).attr("method"),error:function(request){alert(request.responseText);setTimeout(function(){$submit.attr("disabled",false).fadeTo("slow",1).val(submit_val)},3000)},success:function(data){$("#comment").val("");var t=addComment,cancel=t.I("cancel-comment-reply-link"),temp=t.I("wp-temp-form-div"),respond=t.I(t.respondId),parent=t.I("comment_parent").value;if($comments.length){n=parseInt($comments.text().match(/\d+/));$comments.text($comments.text().replace(n,n+1))};new_htm='" id="new_comm_'+num+'"></';if(parent=="0"){$(".commentlist:last").after('\n<ol class="commentlist clear'+new_htm+'ol>')}else{$("#respond").before('\n<ul class="children'+new_htm+'ol>')};$("#new_comm_"+num).hide().append(data);$("#new_comm_"+num+" .comment-body").append("<p id='successTip'>"+oktxt+"</p>");$("#new_comm_"+num).fadeIn("slow");setTimeout(function(){$("#successTip").slideUp("slow",function(){$(this).remove()})},3000);$("html,body").animate({scrollTop:$("#new_comm_"+num).offset().top-200},900);countdown();num++;cancel.style.display="none";cancel.onclick=null;t.I("comment_parent").value="0";if(temp&&respond){temp.parentNode.insertBefore(respond,temp);temp.parentNode.removeChild(temp)}}});return false});function countdown(){if(wait>0){$submit.val(wait);wait--;setTimeout(countdown,1000)}else{$submit.val(submit_val).attr("disabled",false).fadeTo("slow",1);wait=15}}});
/** comment-reply.js */
addComment={moveForm:function(d,f,i,c){var m=this,a,h=m.I(d),b=m.I(i),l=m.I("cancel-comment-reply-link"),j=m.I("comment_parent"),k=m.I("comment_post_ID");if(!h||!b||!l||!j){return}m.respondId=i;c=c||false;if(!m.I("wp-temp-form-div")){a=document.createElement("div");a.id="wp-temp-form-div";a.style.display="none";b.parentNode.insertBefore(a,b)}h.parentNode.insertBefore(b,h.nextSibling);if(k&&c){k.value=c}j.value=f;l.style.display="";l.onclick=function(){var n=addComment,e=n.I("wp-temp-form-div"),o=n.I(n.respondId);if(!e||!o){return}n.I("comment_parent").value="0";e.parentNode.insertBefore(o,e);e.parentNode.removeChild(e);this.style.display="none";this.onclick=null;return false};try{m.I("comment").focus()}catch(g){}return false},I:function(a){return document.getElementById(a)}};
