function del(b,a){b=getSelectorId(b);$(b).fadeTo(500,0.4,function(){if(confirm("Are you sure you want to delete this entry?")){$.ajax({type:"DELETE",data:"",url:a,complete:function(c){if(c.status==200){$(b).fadeOut(function(){$(this).remove()})}else{alert("Failed to delete entry: "+c.responseText);$(b).fadeTo(1000,1)}}})}else{$(b).fadeTo(500,1)}})}function approve(d,b,a){d=getSelectorId(d);var c=$(a).text().toUpperCase()=="APPROVE";$(d).fadeTo(800,0.3,function(){$.ajax({type:"POST",data:"approved="+c,url:b,complete:function(e){if(e.status==200){if(!c){$(d).removeClass("commentApprove").addClass("commentNotApproved");$(a).text("Approve")}else{$(d).removeClass("commentNotApproved").addClass("commentApprove");$(a).text("Unapprove")}$(d).find("em.warning").remove()}else{alert("Failed to set approval: "+e.responseText)}$(d).fadeTo(2000,1)}})})}function approveAll(c,b,a){$.ajax({type:"POST",data:"",url:b,complete:function(d){if(d.status==200){alert("Approved: "+d.responseText);$(a).remove();$("#comments div.commentNotApproved").fadeTo(800,0.3,function(){$('#comments button:contains("Approve")').remove();$("#comments em.warning").remove();$("#comments div.commentNotApproved").toggleClass("commentNotApproved").addClass("commentApprove").fadeTo(2000,1)})}else{alert("Failed to approve: "+d.responseText)}}})}function getSelectorId(a){return"#"+a.toString().replace(/:/g,"\\:").replace(/\./g,"\\.").replace(/,/g,"\\,")}$(function(){$("#addcommentform").submit(function(){$(".error").hide();var a="<entry xmlns='http://www.w3.org/2005/Atom'><title>Comment</title>";if($("#authenticated").length==0){a+="<author>";if($.trim($("#txtName").val()).length==0){$("#nameError").fadeIn("slow");return false}else{a+="<name>"+parse($("#txtName").val())+"</name>"}if($.trim($("#txtEmail").val()).length==0||$("#txtEmail").val().search(emailRegxp)==-1){$("#emailError").fadeIn("slow");return false}else{a+="<email>"+encodeURI($("#txtEmail").val())+"</email>"}if($.trim($("#txtWebsite").val())!="http://"&&$.trim($("#txtWebsite").val()).length>0){if($("#txtWebsite").val().search(urlRegxp)==-1){$("#websiteError").fadeIn("slow");return false}else{a+="<uri>"+encodeURI($("#txtWebsite").val())+"</uri>"}}a+="</author>"}if($.trim($("#txtComment").val()).length==0){$("#commentError").fadeIn("slow");return false}else{a+="<content type='html'>"+parse($("#txtComment").val())+"</content></entry>"}$.ajax({type:"POST",url:$("#addcommentform").attr("action"),data:a,contentType:"application/atom+xml;type=entry",dataType:"xml",complete:function(c){if(c.status==200){reset();var b=$(c.responseText);b.addClass("commentSelf").fadeTo(0,0,function(){b.appendTo("#comments").fadeTo(1000,1);$("abbr[class*=timeago]").timeago();$("#commentsEmpty").remove()})}else{alert("Failed to post comment: "+c.statusText+"\n"+c.responseText)}}});return false})});function parse(a){if(a){return a.replace(/\n/,"<br />").replace(/&/g,"&amp;").replace(/\"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}return""}function reset(){$(".commentError").hide();$("#txtComment")[0].value=""}var emailRegxp=/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i;var urlRegxp=/^(?:https?|s?ftp|telnet|ssh|scp):\/\/(?:(?:[\w]+:)?\w+@)?(?:(?:(?:[\w-]+\.)*\w[\w-]{0,66}\.(?:[a-z]{2,6})(?:\.[a-z]{2})?)|(?:(?:25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.)(?:(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})))(?:\:\d{1,5})?(?:\/(~[\w-_.])?)?(?:(?:\/[\w-_.]*)*)?\??(?:(?:[\w-_.]+\=[\w-_.]+&?)*)?$/i;$.fn.watermark=function(c){var a={color:"#999"};var b=$.extend({},a,c);return this.each(function(){var d=$(this);d.attr("baseColor",d.css("color"));if(!d.attr("title")){d.attr("title",d.val())}if(d.val()==d.attr("title")){d.attr("isWatermark",1);d.css("color",b.color)}d.bind("focus",function(){var e=$(this);if(e.val()!=e.attr("title")&&e.val()!=""){e.attr("isWatermark",0)}if(e.attr("isWatermark")==1){e.val("");e.attr("isWatermark",0);e.css("color",e.attr("baseColor"))}}).bind("blur",function(){var e=$(this);if(e.val()!=e.attr("title")&&e.val()!=""){e.attr("isWatermark",1)}if(e.attr("isWatermark")==0){e.css("color",b.color);if(e.val()==""){e.attr("isWatermark",1);e.val(e.attr("title"))}}})})};$.fn.rater=function(b){var a=$.extend({},$.fn.rater.defaults,b);return this.each(function(){var e=$(this);var d=e.find(".ui-rater-starsOn");var c=e.find(".ui-rater-starsOff");if(a.size==undefined){a.size=c.height()}if(a.rating==undefined){a.rating=d.width()/a.size}if(a.id==undefined){a.id=e.attr("id")}c.mousemove(function(i){var h=i.clientX-c.offset().left;var g=c.width()-(c.width()-h);g=Math.min(Math.ceil(g/(a.size/a.step))*a.size/a.step,a.size*a.ratings.length);d.width(g);var f=Math.round(d.width()/c.width()*(a.ratings.length*a.step))/a.step;e.attr("title",a.ratings[f-1]==undefined?f:a.ratings[f-1])}).hover(function(f){d.addClass("ui-rater-starsHover")},function(f){d.removeClass("ui-rater-starsHover");d.width(a.rating*a.size)}).click(function(g){var f=Math.round(d.width()/c.width()*(a.ratings.length*a.step))/a.step;$.fn.rater.rate(e,a,f)}).css("cursor","pointer");d.css("cursor","pointer")})};$.fn.rater.defaults={postHref:location.href,ratings:["Bad","Boring","Average","Good","Great"],step:1};$.fn.rater.rate=function(e,a,b){var d=e.find(".ui-rater-starsOn");var c=e.find(".ui-rater-starsOff");c.fadeTo(600,0.4,function(){$.ajax({url:a.postHref,type:"POST",data:"id="+a.id+"&rating="+b,complete:function(f){if(f.status==200){a.rating=parseFloat(f.responseText);c.unbind("click").unbind("mousemove").unbind("mouseenter").unbind("mouseleave");c.css("cursor","default");d.css("cursor","default");c.fadeTo(600,0.1,function(){d.removeClass("ui-rater-starsHover").width(a.rating*a.size);var g=e.find(".ui-rater-rateCount");if(g){g.text(parseInt(g.text())+1);e.find(".ui-rater-rating").text(a.rating.toFixed(1))}c.fadeTo(500,1);e.attr("title","Your rating: "+b.toFixed(1))})}else{alert(f.responseText);c.fadeTo(2200,1)}}})})};