VoteBar=function(f){var d=this,e=jQuery,c;var a=function(h,g,i){if(g===0){}else{var j=PHP.get("you_voted_text").replace("%s",h.vote);c.down("h3").addClass("voted").html(j);if(typeof h.rendered_text!==undefined){e("#aftervote").down().html(h.rendered_text)}e("#aftervote").appear()}};var b=function(h,g,i){e("#votebar").enable()};this.vote=function(i){var h=e(i.target);if(h.is("LABEL")){if(!PHP.get("user_logged_in",false)){PassportHandler.open().reposition(e(document).scrollTop());return false}e("#"+i.target.htmlFor).attr("checked",true);c=h.up("form");var j=c.serializeArray(),g=c.attr("action");c.disable();e.ajax.startWaiting(c,e.ajax({type:"post",url:g,data:j,success:a,error:b}))}h=null};this.init=function(){e("#votebar ul").click(this.vote);e("#votebar").enable()};this.lock=function(){e("#votebar").disable()}};PortalReviewSubmit=function(){var d=jQuery,c=d("#review_form"),b={require:[["review_stars","Choose a star rating for this submission."],["review_body","You must write a review!"]]};c.off();if(c.find("#review_agreed").length){b.require.push(["review_agreed","You must agree to the terms and conditions"])}var a=new NgFormValidator(c,b);this.init=function(){d("#review_form_show").off();d("#review_form_show").click(function(g){var f=d(this);if(f.text()=="Cancel Review"){f.text("Write a Review")}else{f.text("Cancel Review")}c.toggle();return false});var e=function(){c.enableSubmit()};c.submit(function(f){if(a.validate()){c.ajaxSubmit(function(g){d("#portal_reviews_container").replaceWith(d("#portal_reviews_container",g));c.toggle();d("#review_form_show").hide()});return false}else{alert(a.getErrorMessages().join("\n"))}f.preventDefault()})}};PortalReview=(function(c){var a,b;var d=function(){var j=false,i=function(o){var m=c(o.target);if(m.is("label")){var l=c("#"+o.target.htmlFor),k={y:"yes",n:"no",x:"x"},n=m.up("form");if(!l.attr("disabled")){l.attr("checked",true);n.ajaxSubmit(function(p){n.disable().down("span").html(p.message)});return false}}},f=function(){var k=c(this);c(this.href.substr(this.href.indexOf("#"))).toggle();if(-1===k.html().indexOf("Cancel")){k.data("original text",k.html());k.html("Cancel")}else{k.html(k.data("original text"))}return false},h=function(l){var k=c(this);k.ajaxSubmit(function(p){var q=c(p),o=q.find("div.authresponse"),m=q.find("div.modlinks");k.enable().hide();var n=k.prev("div");n.down("div.authresponse").remove();n.down("div.modlinks").before(o).replaceWith(m)},{dataType:"html"});return false},g=function(){if(this.href){c.get(this.href,null,function(k){c("#portal_reviews").replaceWith(k);c("#portal_reviews").scrollTo()});return false}},e=function(){b.off();b.delegate("form.helpful","click",i).delegate("a.respond_to_review","click",f).delegate("div.pagenav a","click",g).delegate('form[id^="review-response"]',"submit",h)};this.init=function(){if(!j){e();j=true}}};return{_:function(f,e){a=new d();b=f||c("#portal_reviews");return a}}})(jQuery);var NgFavorites=(function(){var g=jQuery,b=false,f=null;var c=function(){b=false;f=null};var d=function(i){if(i){if(g.isString(i)){f.replaceWith(g(i))}else{if(i.url){if(i.success){alert(i.success)}window.location.href=i.url}}}};var h=function(i){if(null!==f){form_id=f.attr("id");d(i);e(form_id)}c()};var e=function(j){var i=g("#count_"+j);if(i.exists()){if(i.children().size()){i=i.children(i.children().size()-1)}i.html(FormatNumber(parseInt(i.html().replace(/[^0-9]+/g,""),10)+1)+" Fans")}};var a=function(i){i.stopImmediatePropagation();if(b){alert("Sorry, another form is currently being saved.");return false}f=g(i.target);b=true;f.ajaxSubmit(h,{error:c});return false};return{addListener:function(i){var j;if(g.isString(i)){if(i.indexOf("#")!==0){i="#"+i}j=g(i)}else{if(i.is("form")){j=i}else{throw"Don't know how to add this."}}j.bind("submit",a)}}})();