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,a,b){d=getSelectorId(d);var c=$(b).text().toUpperCase()=="APPROVE";$(d).fadeTo(800,0.3,function(){$.ajax({type:"POST",data:"approved="+c,url:a,complete:function(e){if(e.status==200){if(!c){$(d).removeClass("commentApprove").addClass("commentNotApproved");$(b).text("Approve")}else{$(d).removeClass("commentNotApproved").addClass("commentApprove");$(b).text("Unapprove")}$(d).find("em.warning").remove()}else{alert("Failed to set approval: "+e.responseText)}$(d).fadeTo(2000,1)}})})}function approveAll(c,a,b){$.ajax({type:"POST",data:"",url:a,complete:function(d){if(d.status==200){alert("Approved: "+d.responseText);$(b).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(b){var c={color:"#999"};var a=$.extend({},c,b);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",a.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",a.color);if(e.val()==""){e.attr("isWatermark",1);e.val(e.attr("title"))}}})})};$.fn.openid=function(){var k=$(this);var d=k.find("input[name=openid_username]");var b=k.find("input[name=openid_identifier]");var a=k.find("div:has(input[name=openid_username])>span:eq(0)");var j=k.find("div:has(input[name=openid_username])>span:eq(1)");var f=k.find("fieldset:has(input[name=openid_username])");var i=k.find("fieldset:has(input[name=openid_identifier])");var l=function(){if(d.val().length<1){d.focus();return false}b.val(a.text()+d.val()+j.text());return true};var c=function(){if(b.val().length<1){b.focus();return false}return true};var g=function(){var m=$(this);m.parent().find("li").removeClass("highlight");m.addClass("highlight");f.fadeOut();i.fadeOut();k.unbind("submit").submit(function(){b.val(k.find("li.highlight span").text())});k.submit();return false};var e=function(){var m=$(this);m.parent().find("li").removeClass("highlight");m.addClass("highlight");f.hide();i.show();b.focus();k.unbind("submit").submit(c);return false};var h=function(){var m=$(this);m.parent().find("li").removeClass("highlight");m.addClass("highlight");i.hide();f.show();k.find("label[for=openid_username] span").text(m.attr("title"));a.text(m.find("span").text().split("username")[0]);j.text("").text(m.find("span").text().split("username")[1]);b.focus();k.unbind("submit").submit(l);return false};k.find("li.direct").click(g);k.find("li.openid").click(e);k.find("li.username").click(h);b.keypress(function(m){if((m.which&&m.which==13)||(m.keyCode&&m.keyCode==13)){return c()}});d.keypress(function(m){if((m.which&&m.which==13)||(m.keyCode&&m.keyCode==13)){return l()}});k.find("li span").hide();k.find("li").css("line-height",0).css("cursor","pointer");k.find("li:eq(0)").click();return this};$.fn.rater=function(b){var a=$.extend({},$.fn.rater.defaults,b);return this.each(function(){var d=$(this);var c=d.find(".ui-rater-starsOn");var e=d.find(".ui-rater-starsOff");if(a.size==undefined){a.size=e.height()}if(a.rating==undefined){a.rating=c.width()/a.size}if(a.id==undefined){a.id=d.attr("id")}e.mousemove(function(g){var h=g.clientX-e.offset().left;var i=e.width()-(e.width()-h);i=Math.min(Math.ceil(i/(a.size/a.step))*a.size/a.step,a.size*a.ratings.length);c.width(i);var f=Math.round(c.width()/e.width()*(a.ratings.length*a.step))/a.step;d.attr("title",a.ratings[f-1]==undefined?f:a.ratings[f-1])}).hover(function(f){c.addClass("ui-rater-starsHover")},function(f){c.removeClass("ui-rater-starsHover");c.width(a.rating*a.size)}).click(function(g){var f=Math.round(c.width()/e.width()*(a.ratings.length*a.step))/a.step;$.fn.rater.rate(d,a,f)}).css("cursor","pointer");c.css("cursor","pointer")})};$.fn.rater.defaults={postHref:location.href,ratings:["Bad","Boring","Average","Good","Great"],step:1};$.fn.rater.rate=function(c,b,d){var a=c.find(".ui-rater-starsOn");var e=c.find(".ui-rater-starsOff");e.fadeTo(600,0.4,function(){$.ajax({url:b.postHref,type:"POST",data:"id="+b.id+"&rating="+d,complete:function(f){if(f.status==200){b.rating=parseFloat(f.responseText);e.unbind("click").unbind("mousemove").unbind("mouseenter").unbind("mouseleave");e.css("cursor","default");a.css("cursor","default");e.fadeTo(600,0.1,function(){a.removeClass("ui-rater-starsHover").width(b.rating*b.size);var g=c.find(".ui-rater-rateCount");if(g){g.text(parseInt(g.text())+1);c.find(".ui-rater-rating").text(b.rating.toFixed(1))}e.fadeTo(500,1);c.attr("title","Your rating: "+d.toFixed(1))})}else{alert(f.responseText);e.fadeTo(2200,1)}}})})};