(function(a){a(".story-actions-report").live("digg:flag",function(){a(this).die("click").replaceWith("Reported")});a(".sharing-option a").live("click",function(){var e=a(this).attr("data-url");DUI.treq({target:this,url:"/ajax/permalink/track_shares",data:{shared_url:e}})});a(".story-actions-report").live("click",function(e){var h=a(this),i=DUI.parseItemId(h.parents(".story-item").attr("class"));DUI.Auth.requireLogin(function(){DUI.treq({target:e.target,url:"/ajax/flag",data:{item_id:i,referrer:document.referrer,
location_id:DUI.digg_location_id}})},function(){DUI.Tooltip.load(h,"report_item")});e.preventDefault()});a(".assign-topic-toggle").live("click",function(){var e=a(this);DUI.Auth.requireLogin(function(){a(".topic-selection").toggleClass("opened")},function(){DUI.Tooltip.load(e,"assign_topic")});return false});a(".topic-selection-dropdown a").live("click",function(){var e=a(this),h=e.attr("data-digg-topic-slug");e=e.text();DUI.treq({url:"/ajax/permalink/assign_topic",data:{topic:e,topic_slug:h,item_id:a("#item_id").val()},
target:a(".topic-selection-dropdown")});return false});a(".topic-selection-dropdown").live("digg:topic_assigned",function(e,h){a(".topic-nav").find('[data-digg-topic-slug="'+h.topic_slug+'"]').fadeOut();a(".topic-selection-dropdown").fadeOut(function(){a(".topic-selection").html('<a href="/news/'+h.topic_slug+'" class="active-topic">'+h.topic+"</a>").addClass("topic-selected").removeClass("opened")});return false});DUI.permalink_video&&a.isPlainObject(DUI.permalink_video)&&a(function(){if("<iframe"!=
DUI.permalink_video.embed.substr(0,7)&&-1==DUI.permalink_video.embed.indexOf("wmode")){var e=[];if(0<DUI.permalink_video.embed.indexOf("<param")){e=DUI.permalink_video.embed.split(">");e.splice(1,0,'<param name="wmode" value="transparent"></param');DUI.permalink_video.embed=e.join(">");if(0<DUI.permalink_video.embed.indexOf("<embed")){e=DUI.permalink_video.embed.split("<embed");e[1]=' wmode="transparent"'+e[1];DUI.permalink_video.embed=e.join("<embed")}}e=DUI.permalink_video.embed.split(" ");e.splice(1,
0,'wmode="transparent"');DUI.permalink_video.embed=e.join(" ")}e=a(".video-embed");var h=344,i=425,j=a(DUI.permalink_video.embed).hide();e.html(j);if(j.outerWidth()>a(".story-item-details").outerWidth()){i=a(".story-item-details").outerWidth();h=i/1.8}e.css({height:h,width:i});j.attr({height:h,width:i}).show()});a(".modal-close").live("click",function(){a("#modal-wrapper").hide();return false})})($);
(function(a,e){function h(b,c){c=parseInt(b.text())+c;b.text(c+(c==1?" Reply":" Replies"));return c}function i(b){commentCount+=b;s.text(commentCount+(commentCount==1?" Comment":" Comments"))}function j(b,c){var d=b.find("span").remove();b.text(c).prepend(d)}function x(){if(n){a("#comment-list").addClass("expanded");a(".collapsed").removeClass("collapsed")}else a(".expanded").removeClass("expanded")}function y(b){var c=b.offset().top+b.height(),d=a(window),f=d.scrollTop(),g=f+d.height();c=c-g+a("#feedback-bar").height();
c>0&&d.scrollTop(f+c);a("textarea",b).focus()}function t(b,c){var d=a("em.counter em",b);c.append(b);e.Countdown.add(+d.text(),d,e.parseItemId(b.attr("className"),{prefix:"comment-"}))}function o(b){var c=a(".comment-edit-content:first",b);if(c.length){c.remove();a(".comment-body",b).show();a(".comment-reply-options",b).show()}}function z(b){b=a("<div/>").html(b.replace(/\n/g,""));var c=a("br",b);c.length&&c.replaceWith("\n");return b.text()}var n,p=a("#item_id").val(),s=a("#main-column .comment-count, .newsbar-comment-count-wrapper comment-toggle");
commentCount=parseInt(s.text(),10);commentTogglerText=[["Show Hidden Comment","Hide Hidden Comment"],["Show Buried Comment","Hide Buried Comment"]];reportCommentText="Report Comment";commentCount==a(".comment-thread").length&&a("#more-stories").remove();a(".comment-report").live("click",function(){var b=a(this),c,d;d=e.parseItemId(b.closest(".comment-thread").attr("className"),{prefix:"comment-"})||"";c=a("#item_id").val();e.Comments.report({comment_id:d,item_id:c},b);return false}).live("digg:commentreported",
function(){a(this).addClass("comment-reported").find(".action-label").text("Reported");return false});a(".comment-reply-content, .post-comment-form").live("submit",function(){if(a("#submission-endofline").is(":visible"))return false;var b,c,d,f,g;b=a(this);c=a("textarea",b);d=a.trim(c.val());f=d.length;g=a("button[type=submit]",b);if(b.hasClass("disabled")||d==c.attr("placeholder")||f==0||g.hasClass("disabled"))return false;e.Comments.post(b.serializeObject(),b);g.addClass("disabled");b.addClass("disabled");
return false}).live("digg:postedcomment",function(b,c){if(a("#submission-endofline").is(":visible"))return false;var d,f=a(this),g=f.closest(".comment-thread"),l=a("button[type=submit]",f);b=a("input[name=item_id]",f).val();l.removeClass("disabled");f.removeClass("disabled");if(g.length){if(g.closest("#comments-activity").length){d=a("#comment-list .comment-"+e.parseItemId(g.attr("className"),{prefix:"comment-"}).replace(":","_"));e.SysMsg.show("Your reply has been posted!")}(d||g).trigger("digg:commentrepliedto",
c);g.find(".reply-to-thread:first").hide().empty()}else{a("#no-comments-error").remove();c=a(c.html);t(c,a("#comment-list"));c=a(this).find("textarea");c.val("").blur()}i(1);a(".no-comments").is(":visible")&&a(".no-comments p").remove();a("#comment-sorting").not(":visible")&&a("#comment-sorting").fadeIn();_gaq.push(["_trackEvent","Comments","post",b]);return false}).live("digg:error",function(b){var c=a(this);a("button[type=submit]",c).removeClass("disabled");c.removeClass("disabled");b.preventDefault()});
a(".comment-thread").live("digg:commentrepliedto",function(b,c){a(c.html);b=a(this);t(a(c.html),b.find(".thread-replies:first").addClass("expanded"));c=a(".comment:first > .comment-content > ul.comment-reply-options",b);if(c.length){replyCount=c.find(".option-toggle-replies").show();replyCount.length||a('<li class="option-toggle-replies"><a><span class="indicator"></span><span class="reply-count">0</span></a></li>').appendTo(c);h(c.find(".reply-count"),1)}return false}).live("digg:commentdugg digg:commentburied digg:commentneutral",
function(b,c){var d=e.parseItemId(this.className,{prefix:"comment-"});if(b.type=="digg:commentneutral")c.action="un"+(c.action=="digg"?"bury":"digg");a(".comment-"+d.replace(":","_")).trigger("digg:commentduggburied",c);return false}).live("digg:commentduggburied",function(b,c){var d=a(this),f=d.find(".comment-actions"),g=a(".comment-meta:first",d),l=a(".comment-toggle",g),u=c.action,v=c.diggs;c=c.buries;var m=v-c,w=a(".digg-count-net:first",d),k=w.text(),A=parseInt(k),q=d.find(".comment-digg").eq(0),
r=d.find(".comment-bury").eq(0);a(".digg-count-raw:first span",d);var B=a(".digg-count-raw:first",d).find(".count-positive"),C=a(".digg-count-raw:first",d).find(".count-negative");if(u=="bury"){f.addClass("comment-buried").removeClass("comment-dugg");q.removeClass("active");b.type!="digg:neutral"&&r.addClass("active");d.addClass("is-buried buried-state");g.removeClass("buried-state");j(l.toggleClass("bury",m>=0).find("a").removeClass("active"),commentTogglerText[+(m>=0)][0])}else{if(u=="digg"){f.addClass("comment-dugg").removeClass("comment-buried");
r.removeClass("active");b.type!="digg:neutral"&&q.addClass("active")}else{f.removeClass("comment-buried comment-dugg");d.removeClass("is-buried buried-state");q.removeClass("active");r.removeClass("active")}if(m<0){l.removeClass("bury");A>=0&&g.addClass("viewing-buried");j(l.find("a"),commentTogglerText[0][+g.hasClass("viewing-buried")])}else{l.addClass("bury");g.removeClass("viewing-buried");j(l.find("a").removeClass("active"),commentTogglerText[1][0])}}B.text(v);C.text(c);if(m<=0)k=k.replace("+",
"");else if(k.indexOf("+"))k="+"+k;w.text(k.replace(parseInt(k),m));return false}).live("digg:commentdeleted",function(){var b=a(this),c=b.find(".comment-thread").length+1,d=b.parent().closest(".comment-thread");b.remove();i(-c);if(d.length){b=a(".option-toggle-replies:first",d);h(b.find(".reply-count"),-1)||b.hide()}return false});a(".option-toggle-replies a").live("click",function(){var b=a(this).closest(".comment-thread");if(a(".thread-replies",b).eq(0).css("display")!="none")b.addClass("collapsed").removeClass("expanded");
else{b.addClass("expanded").removeClass("collapsed");a(".comment-thread",b).removeClass("collapsed")}return false});a(".comment-toggle a").live("click",function(){var b=a(this).toggleClass("active"),c=b.closest(".comment-thread").toggleClass("buried-state");a(".comment-meta:first",c).toggleClass("viewing-buried");j(b,commentTogglerText[+b.parent().hasClass("bury")][+b.hasClass("active")]);return false});a(".option-reply a").live("click",function(){var b=a(this),c=b.closest(".comment-thread"),d=e.parseItemId(c.attr("className"),
{prefix:"comment-"}),f=c.find(".reply-to-thread:first"),g=a("#reply-prototype").clone().removeAttr("id");e.Auth.requireLogin(function(){c.addClass("expanded");if(f.find(".comment-reply").length)f.show().find(".comment-reply").show();else{g.find("input[name=parent_id]").val(d);g.find("input[name=item_id]").val(p);f.prepend(g.show()).show()}y(f)},function(){e.Tooltip.load(b,"reply")});return false});a(".comment-edit a").live("click",function(){var b,c;b=a(this);var d=a(this).closest(".comment-thread");
c=e.parseItemId(d.attr("className"),{prefix:"comment-"});if(b.hasClass("comment-delete"))e.Comments.deleteComment(c,b);else if(!a(".comment-content:first .comment-edit-content",d).length){c=a(".comment-body:first",d);b=a("#edit-prototype").clone().removeAttr("id");a("textarea",b).val(z(c.html()));a("input[name=item_id]",b).val(p);a("input[name=comment_id]",b).val(e.parseItemId(d.attr("className"),{prefix:"comment-"}));a(".comment-reply-options",d).hide();b.show().insertAfter(c.hide())}return false});
a(".comment-edit-content").live("submit",function(){var b=a(this).serializeObject();e.Comments.edit(b,a(this));return false}).live("digg:editsuccess",function(b,c){b=a(this);var d=b.closest(".comment-thread"),f=a(".comment-body:first",d);c&&c.html?f.replaceWith(a(c.html)):f.text(b.closest("form").find("textarea").val());o(d)});a(".comment-digg, .comment-bury").live("click",function(){var b,c,d,f=a(this);b=f.closest(".comment-thread");c=e.parseItemId(b.attr("className"),{prefix:"comment-"});d=f.hasClass("comment-digg")?
1:-1;b=b.find(d>0?".comment-bury":".comment-digg").eq(0);if(!f.hasClass("active")){if(b.hasClass("active"))d=0;e.Auth.requireLogin(function(){e.Comments.setScore(c,d,f)},function(){e.Tooltip.load(f,"diggbury");return false})}return false});a("em.counter em").live("digg:countdown",function(b,c){a(this).text(c);if(!+c){b=a(this).closest(".comment-thread");b.removeClass("is-editable");a(".comment-edit",b).remove();o(b)}return false}).each(function(){var b=a(this);e.Countdown.add(+b.text(),b,e.parseItemId(b.closest(".comment-thread").attr("className")))});
a("#comment-sorting a").live("click",function(b){a(this).hasClass("ignore")&&b.preventDefault()}).live("mousedown",function(b){if(b.button!==2){var c;b="/ajax/comments/get";c=a(this);if(c.hasClass("sort")&&!c.hasClass("active")){c=c.attr("href").substr(1);if(c=="most-dugg")b="/ajax/comments/getMostDugg";a("#comment-list").append('<span class="loader-large"></span>').find(".comment-thread").hide();e.treq({url:b,target:this,type:"get",data:{item_id:p,sort:c}});a("#comment-sorting .active").removeClass("active").addClass("deactivated");
a(this).addClass("active")}else if(c.hasClass("show-threads")){c.hide();n=c.hasClass("expand-all");a(n?".collapse-all":".expand-all","#comment-sorting").show();x()}}return false}).live("digg:success",function(b,c){if(c&&c.html){e.Countdown.abort();a("#comment-list").html(c.html);a("em.counter em").each(function(){var d=a(this);e.Countdown.add(+d.text(),d,e.parseItemId(d.closest(".comment-thread").attr("className")))});a("#comment-sorting .deactivated").removeClass("deactivated");a("#more-comments").show();
a(".no-comments").hide()}else a(this).trigger("digg:error",{message:"Internal error - comments could not be loaded. Please <a href=http://about.new.digg.com/contact/bugreport/ target=_blank>report this bug</a>."});return false}).live("digg:error",function(){a(".loader-large").hide();a("#comment-list .comment-thread").show();a(this).removeClass("active");a("#comment-sorting .deactivated").removeClass("deactivated").addClass("active");return false});a(".comment-reply-content .cancel-reply").live("click",
function(){a(this).closest(".comment-thread").find(".reply-to-thread:first").hide();return false});a(".comment-edit-content .cancel-reply").live("click",function(){o(a(this).closest(".comment-thread"));return false});a(".buried-read-more-trigger").live("click",function(){var b=a(this),c=b.parents(".comment").first().find(".buried-truncated"),d;realHeight=c.find("span").innerHeight();d=b.attr("data-digg-origheight")||"32px";if(b.hasClass("on")){c.animate({height:d},100);b.text("Comment is buried, click here to see the rest.")}else{b.attr("data-digg-origheight",
c.innerHeight());c.animate({height:realHeight},100);b.text("Hide this comment.")}b.toggleClass("on");return false})})($,DUI);(function(){if(window.location.hash!=""){var a,e,h;try{a=window.location.hash.replace(":","\\:");h=(e=$(a+".comment-thread").length)&&$(a+":visible").length;e&&!h&&$(a).effect("highlight",{},5E3).parents(".comment-thread").removeClass("collapsed").addClass("expanded")}catch(i){}}})();
