(function(f){f.fn.extend({elastic:function(){var d=['paddingTop','paddingRight','paddingBottom','paddingLeft','fontSize','lineHeight','fontFamily','width','fontWeight'];return this.each(function(){if(this.type!='textarea'){return false}var $textarea=f(this),$twin=f('<div />').css({'position':'absolute','display':'none'}),lineHeight=parseInt($textarea.css('line-height'),10)||parseInt($textarea.css('font-size'),'10'),minheight=parseInt($textarea.css('height'),10)||lineHeight*3,maxheight=parseInt($textarea.css('max-height'),10)||Number.MAX_VALUE,goalheight=0,i=0;$twin.appendTo($textarea.parent());var i=d.length;while(i--){$twin.css(d[i].toString(),$textarea.css(d[i].toString()))}function setHeightAndOverflow(a,b){curratedHeight=Math.floor(parseInt(a,10));if($textarea.height()!=curratedHeight){$textarea.css({'height':curratedHeight+'px','overflow':b})}}function update(){var a=$textarea.val().replace(/<|>/g,' ').replace(/\n/g,'<br />').replace(/&/g,"&amp;");var b=$twin.html();if(a+'&nbsp;'!=b){$twin.html(a+'&nbsp;');if(Math.abs($twin.height()+lineHeight-$textarea.height())>3){var c=$twin.height()+lineHeight;if(c>=maxheight){setHeightAndOverflow(maxheight,'auto')}else if(c<=minheight){setHeightAndOverflow(minheight,'hidden')}else{setHeightAndOverflow(c,'hidden')}}}}$textarea.css({'overflow':'hidden'});$textarea.keyup(function(){update()});$textarea.live('input paste',function(e){setTimeout(update,250)});update()})}})})(jQuery);(function($){$.fn.changeFontSize=function(options){var options=$.extend({numberOfSizes:3,maxSize:18,minSize:12},options);var el=$(this);var arr=new Array();var maxSize=options.maxSize;var minSize=options.minSize;var numSizes=options.numberOfSizes;var sizeSpan=maxSize-minSize;var increment=sizeSpan/numSizes;Array.max=function(array){return Math.max.apply(Math,array);};$.each($(el),function(){number=$(this).text().length;arr.push(number);});var max=arr.max();if(max<=4){$(el).css('font-size',maxSize);}else if(max<=6){$(el).css('font-size','14px');}else{$(el).css('font-size','12px');}};})(jQuery);;(function($){var $scrollTo=$.scrollTo=function(target,duration,settings){$(window).scrollTo(target,duration,settings);};$scrollTo.defaults={axis:'xy',duration:parseFloat($.fn.jquery)>=1.3?0:1};$scrollTo.window=function(scope){return $(window)._scrollable();};$.fn._scrollable=function(){return this.map(function(){var elem=this,isWin=!elem.nodeName||$.inArray(elem.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!isWin)
return elem;var doc=(elem.contentWindow||elem).document||elem.ownerDocument||elem;return $.browser.safari||doc.compatMode=='BackCompat'?doc.body:doc.documentElement;});};$.fn.scrollTo=function(target,duration,settings){if(typeof duration=='object'){settings=duration;duration=0;}
if(typeof settings=='function')
settings={onAfter:settings};if(target=='max')
target=9e9;settings=$.extend({},$scrollTo.defaults,settings);duration=duration||settings.speed||settings.duration;settings.queue=settings.queue&&settings.axis.length>1;if(settings.queue)
duration/=2;settings.offset=both(settings.offset);settings.over=both(settings.over);return this._scrollable().each(function(){var elem=this,$elem=$(elem),targ=target,toff,attr={},win=$elem.is('html,body');switch(typeof targ){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(targ)){targ=both(targ);break;}
targ=$(targ,this);case'object':if(targ.is||targ.style)
toff=(targ=$(targ)).offset();}
$.each(settings.axis.split(''),function(i,axis){var Pos=axis=='x'?'Left':'Top',pos=Pos.toLowerCase(),key='scroll'+Pos,old=elem[key],max=$scrollTo.max(elem,axis);if(toff){attr[key]=toff[pos]+(win?0:old-$elem.offset()[pos]);if(settings.margin){attr[key]-=parseInt(targ.css('margin'+Pos))||0;attr[key]-=parseInt(targ.css('border'+Pos+'Width'))||0;}
attr[key]+=settings.offset[pos]||0;if(settings.over[pos])
attr[key]+=targ[axis=='x'?'width':'height']()*settings.over[pos];}else{var val=targ[pos];attr[key]=val.slice&&val.slice(-1)=='%'?parseFloat(val)/100*max:val;}
if(/^\d+$/.test(attr[key]))
attr[key]=attr[key]<=0?0:Math.min(attr[key],max);if(!i&&settings.queue){if(old!=attr[key])
animate(settings.onAfterFirst);delete attr[key];}});animate(settings.onAfter);function animate(callback){$elem.animate(attr,duration,settings.easing,callback&&function(){callback.call(this,target,settings);});};}).end();};$scrollTo.max=function(elem,axis){var Dim=axis=='x'?'Width':'Height',scroll='scroll'+Dim;if(!$(elem).is('html,body'))
return elem[scroll]-$(elem)[Dim.toLowerCase()]();var size='client'+Dim,html=elem.ownerDocument.documentElement,body=elem.ownerDocument.body;return Math.max(html[scroll],body[scroll])
-Math.min(html[size],body[size]);};function both(val){return typeof val=='object'?val:{top:val,left:val};};})(jQuery);BR.AdReloader=Class.create({initialize:function(opts){this.adSpaces=$$('.fod_ad');this.refreshRate=opts.refreshRate?opts.refreshRate:180;this.countAsPageview=(opts.countAsPageview==undefined||opts.countAsPageview)?true:false;this.page_type=opts.page_type?opts.page_type:"";},reload:function(page_type_addition){var rnd=Math.round(Math.random()*100000000);this.adSpaces.each(function(elmnt){elmnt.src=elmnt.src.replace(/aac_random=\d+\//,'acc_random='+rnd+'/');});if(this.countAsPageview){this.registerPageview(page_type_addition);this.reloadQuantCast();this.reloadComscore();}},start:function(){this.pe=new PeriodicalExecuter(this.reload.bind(this),this.refreshRate);},stop:function(){this.pe.stop();},registerPageview:function(page_type_addition){var page_type=this.page_type;if(page_type_addition){page_type=page_type+"-"+page_type_addition;}
try
{pageTracker._trackPageview(location.pathname+'?type='+page_type);}
catch(exception)
{}
try
{teamTracker._trackPageview(BR.teamTrackerPath);}
catch(exception)
{}
try
{analyticsTracker._trackPageview(BR.teamTrackerPath);}
catch(exception)
{}},reloadQuantCast:function(){try
{_qoptions={qacct:"p-3a-0o8sJKz6Ek",media:"webpage",event:"refresh"};quantserve();}
catch(exception)
{}},reloadComscore:function(){try
{if(COMSCORE)
{COMSCORE.beacon({c1:2,c2:6246855,c3:'',c4:document.location.host+'/'+document.location.pathname,c5:'',c6:'',c15:''});}}
catch(exception)
{}}});BR.imageGallery=Class.create({initialize:function(on_results,on_select){this.openSearches=0;this.page=1;this.per_page=130;this.attributes={};this.attributes.page=this.page;this.attributes.per_page=this.per_page;this.onResults=on_results;this.onSelection=on_select;if($('close-gallery')){Event.observe('close-gallery','click',function(){$('article-photo_gallery').hide();});}},search:function(query){this.openSearches++;$('article-photo_gallery').style.display="block";$('empty-results').hide();$('error-results').hide();$('gallery-results').hide();$('getty_searching').show();$('gallery-pager-query').update(query);var url="/ajax_image_gallery";this.attributes.query=query;var that=this;new Ajax.Request(url,{method:'get',parameters:this.attributes,onSuccess:function(res){that.results(res);},onFailure:function(){alert('oops there was an issue with your search request!');},onComplete:function(){$('getty_searching').hide();}});},results:function(response){this.openSearches--;this.response=eval("("+response.responseText+")");this.errorHappened=(this.response[5]=='error');this.searchResults=this.response[0];this.currentPage=false;this.totalResults=this.response[1];this.createPager();this.loadResults(1);},createPager:function(){$('gallery-pager-query').innerHTML=this.attributes.query;$('gallery-pager').innerHTML="";this.pages=Math.ceil(this.totalResults/10);var that=this;for(var i=0;i<this.pages;i++){var id="pager-"+(i+1).toString();var li=new Element('li');var s=new Element('span',{"id":id});s.innerHTML=(i+1);li.insert(s);Event.observe(li,"click",function(event){that.loadResultsFromClick(event);});$('gallery-pager').insert(li);}
$('gallery-pager').insert('<li><span id="pager-next" class="next">Next Page &raquo;</span></li>');Event.observe($('pager-next'),'click',function(){that.nextPage();});},nextPage:function(){if(this.currentPage&&(this.currentPage<=this.pages)){if(this.currentPage==this.pages){this.loadResults(1);}else{this.loadResults(this.currentPage+1);}}},loadResults:function(page){this.onResults();if(this.currentPage){$("pager-"+this.currentPage).className="";}
this.currentPage=parseInt(page,10);$('gallery-results').update('');if($("pager-"+page)){$("pager-"+page).className="current";}
var start=(page-1)*9;var end=(page)*9;var that=this;this.searchResults.slice(start,end).each(function(result){if(result.url_thumb&&result.id){var li=new Element('li');var a=new Element('a');var s=new Element('p',{'class':'gallery-photo'});var img=new Image();img.src=result.url_thumb;img.id="image-id-"+result.id;s.insert(img,{position:"bottom"});li.insert(s,{position:"bottom"});li.insert("<p class='date'>"+result.date+"</p>"+"<p class='title'>"+result.title+"</p>"+"<p class='people'>"+result.people+"</p>",{position:"bottom"});Event.observe(li,"click",function(event){$('article-photo_gallery').toggle();that.onSelection(result.url_thumb,result.url_comp,result.id);});$('gallery-results').insert(li,{position:"bottom"});}}.bind(this));if(this.errorHappened)
$('error-results').show();else if(this.searchResults.size()>0)
$('gallery-results').show();else
$('empty-results').show();},loadResultsFromClick:function(event){e=Event.element(event);var page=e.innerHTML;this.loadResults(page);}});BR.imageCropper=Class.create({initialize:function(options,on_load,on_submit,on_results,on_cancel){console.log("%%%% BR.imageCropper initialize 1");this.options=options;this.url=options.url;this.title=options.title;this.caption=options.caption;this.credit=options.credit;this.onLoad=on_load;this.onSubmit=on_submit;this.onResults=on_results;this.onCancel=on_cancel;that=this;if($('uncropped_image')){$('uncropped_image').remove();}
var img=new Image();img.id="uncropped_image";img.onload=function(){this.onLoad();$('crop_canvas').insert(img);setup_image_cropper(6);}.bindAsEventListener(this);img.src=this.url;Event.stopObserving($('cropper-go-back'),"click",this.cancelEvent);Event.stopObserving($('btn_choose-a-different-photo'),"click",this.cancelEvent);Event.stopObserving($('btn_crop-photo-and-continue'),"click",this.submitEvent);Event.stopObserving($('cropper-move-left'),"click",this.moveLeftEvent);Event.stopObserving($('cropper-move-right'),"click",this.moveRightEvent);Event.stopObserving($('cropper-move-up'),"click",this.moveUpEvent);Event.stopObserving($('cropper-move-down'),"click",this.moveDownEvent);this.cancelEvent=this.cancel.bindAsEventListener(this);this.submitEvent=this.submit.bindAsEventListener(this);Event.observe($('cropper-go-back'),"click",this.cancelEvent);Event.observe($('btn_choose-a-different-photo'),"click",this.cancelEvent);Event.observe($('btn_crop-photo-and-continue'),"click",this.submitEvent);this.moveLeftEvent=function(){this.move(-10,0);}.bindAsEventListener(this);this.moveRightEvent=function(){this.move(10,0);}.bindAsEventListener(this);this.moveUpEvent=function(){this.move(0,10);}.bindAsEventListener(this);this.moveDownEvent=function(){this.move(0,-10);}.bindAsEventListener(this);Event.observe($('cropper-move-left'),"click",this.moveLeftEvent);Event.observe($('cropper-move-right'),"click",this.moveRightEvent);Event.observe($('cropper-move-up'),"click",this.moveUpEvent);Event.observe($('cropper-move-down'),"click",this.moveDownEvent);console.log("%%%% BR.imageCropper initialize END");},submit:function(){this.onSubmit();var attributes=new Object();attributes.crop_left=$("crop_left").value;attributes.crop_top=$("crop_top").value;attributes.crop_width=$("crop_width").value;attributes.crop_height=$("crop_height").value;attributes.stencil_width=$("stencil_width").value;attributes.stencil_height=$("stencil_height").value;attributes.resize_to_stencil=$("resize_to_stencil").value;attributes.crop_cancel=$("crop_cancel").value;attributes.image_id=$("image_id").value;attributes.url=this.url;attributes.title=this.title;attributes.caption=this.caption;attributes.credit=this.credit;var that=this;var url="/uploads/crop";new Ajax.Request(url,{method:'post',parameters:attributes,onSuccess:function(transport){that.results(transport);},onFailure:function(){alert('oops something went wrong');},onLoading:function(){}});},results:function(transport){var response=eval("("+transport.responseText+")");if(response!=false){$('article_primary_image_id').value=response.id;if($('cropped-image-preview')){$('cropped-image-preview').remove();}
var img=new Image();img.src=response.url;img.id="cropped-image-preview";img.onload=function(){this.onResults(img);}.bindAsEventListener(this);}},cancel:function(){Event.stopObserving($('cropper-go-back'),"click",this.cancelEvent);Event.stopObserving($('btn_choose-a-different-photo'),"click",this.cancelEvent);Event.stopObserving($('btn_crop-photo-and-continue'),"click",this.submitEvent);Event.stopObserving($('cropper-move-left'),"click",this.moveLeftEvent);Event.stopObserving($('cropper-move-right'),"click",this.moveRightEvent);Event.stopObserving($('cropper-move-up'),"click",this.moveUpEvent);Event.stopObserving($('cropper-move-down'),"click",this.moveDownEvent);$('article_primary_image_id').value="";this.onCancel();},move:function(x,y){img.display.l+=x;img.display.t+=y;img=ensure_stencil_is_inside_image(img,cropstencil);set_dom_obj_dimensions(uncropped_image_obj,img.display);set_crop_form_params(form_params,img,cropstencil);}});BR.autoTagger=Class.create({initialize:function(title,body,chooser){this.title=title;this.body=body;this.chooser=chooser;this.attributes=new Object();this.attributes.title=this.title;this.attributes.body=this.body;},search:function(){var url="/tagger/new_article_tags";var that=this;new Ajax.Request(url,{method:'post',parameters:this.attributes,onSuccess:function(transport){$('tag-search').hide();that.results(transport.responseJSON);},onFailure:function(){$('tag-search').hide();alert('Unable to tag article');}});},results:function(tags){tags.each(function(tag){tagger.insertTag(tag);}.bind(this));}});BR.tinyMCE=Class.create({initialize:function(on_load){this.onLoad=on_load;this.frameId="article_body_ifr";that=this;this.instance=tinyMCE.init({oninit:that.onLoad,mode:"exact",elements:"article_body",theme:"advanced",convert_urls:false,plugins:"emotions,preview,spellchecker,pagebreak,br_stripalltags",pagebreak_separator:"<!-- my page break -->",stripalltags_except:["p","div","br"],theme_advanced_buttons1:"bold,italic,underline,separator,indent,outdent,separator,bullist,numlist,link,separator,undo,redo,separator,code,separator,pagebreak,br_stripalltags",theme_advanced_buttons2:"",theme_advanced_buttons3:"",theme_advanced_toolbar_location:"top",theme_advanced_toolbar_align:"left",extended_valid_elements:"a[name|href|target|title|onclick],img[class|src|article_page_src|br_image_id|"+"border=0|alt|title|hspace|vspace|width|height|align|name|style],"+"hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]"});Event.observe($('btn_resize'),"mousedown",function(event){this.resize(event);}.bindAsEventListener(this));},resize:function(event){this.frameElem=$(this.frameId);this.frameDoc=this.frameElem.contentDocument;if(this.frameDoc==undefined){this.frameDoc=this.frameElem.contentWindow.document;}
this.mousePos=Event.pointerY(event);this.height=$(this.frameId).getHeight();this.dragging=true;this.eventEnd=function(event){this.end(event);}.bindAsEventListener(this);this.eventMove=function(event){this.move(event,0);}.bindAsEventListener(this);Event.observe($('btn_resize'),"mouseup",this.eventEnd);Event.observe(document,"mouseup",this.eventEnd);Event.observe(this.frameDoc,"mouseup",this.eventEnd);Event.observe(document,"mousemove",this.eventMove);var offset;if(BrowserDetect.browser=="Explorer"){offset=0;}
else{offset=$(this.frameId).cumulativeOffset()[1];}
this.eventMoveOffset=function(event){this.move(event,offset);}.bindAsEventListener(this);Event.observe(this.frameDoc,"mousemove",this.eventMoveOffset);},end:function(event){this.dragging=false;Event.stopObserving($('btn_resize'),"mouseup",this.eventEnd);Event.stopObserving(document,"mouseup",this.eventEnd);Event.stopObserving(this.frameDoc,"mouseup",this.eventEnd);Event.stopObserving(document,"mousemove",this.eventMove);Event.stopObserving(this.frameDoc,"mousemove",this.eventMoveOffset);},move:function(event,offset){if(this.dragging==true){var newHeight=(this.height+(Event.pointerY(event)-this.mousePos))+offset;if(newHeight>=385){$(this.frameId).style.height=newHeight.toString()+"px";}
else{$(this.frameId).style.height="385px";}}},afterInit:function(){this.settings=tinymce.EditorManager.settings;this.editor=tinymce.EditorManager.activeEditor;this.frameElem=$(this.frameId);this.frameDoc=this.frameElem.contentDocument;if(this.frameDoc==undefined){this.frameDoc=this.frameElem.contentWindow.document;}
this.editor.undoManager.clear();},showPagebreakPopup:function(){var popup=new Element('div',{'id':'pagebreak-popup'});popup.style.top=($('article_body_pagebreak').cumulativeOffset()[1]-40).toString()+"px";popup.style.left=($('article_body_pagebreak').cumulativeOffset()[0].toString()-18)+"px";var text=new Element('p');text.update("Click to Insert Page Break");popup.insert(text);$('sitewrapper').insert(popup);},hidePagebreakPopup:function(){if($('pagebreak-popup')){$('pagebreak-popup').remove();}},pagebreakCount:function(){var images=this.frameDoc.getElementsByTagName('img');var count=0;for(var x=0;x<images.length;x++){if(images[x].className.include('mcePageBreak')){count++;}}
return count;},removeAllPageBreaks:function(){var sep=new RegExp(this.settings.pagebreak_separator,"g");this.editor.setContent(this.body().replace(sep,""),{format:'html'});},body:function(){this.editor=tinymce.EditorManager.activeEditor;return tinymce.trim(this.editor.getContent({format:'html'}));}});jQuery.noConflict();jQuery(document).ready(function($){$(".user .article-author-link").hover(function(){$("#author-info-flyout").show();},function(){$("#author-info-flyout").hide();});$("#author-info-flyout").hover(function(){$(this).show();},function(){$(this).hide();});$("#like-this-share-it").hover(function(){$("#article-meta-box .share").show();},function(){$("#article-meta-box .share").hide();});$("#article-meta-box .share").hover(function(){$(this).show();},function(){$(this).hide();});$("#share-button").hover(function(){$("#article-actions .share").show();},function(){$("#article-actions .share").hide();});$("#article-actions .share").hover(function(){$(this).show();$("#share-button").addClass("active");},function(){$(this).hide();$("#share-button").removeClass("active");});$("#article-content-widget-tabs ul.brui-tabs-nav li").click(function(e){e.preventDefault();if($(this).attr("class").indexOf("active")>-1){return false;}else{$("#article-content-widget-tabs ul.brui-tabs-nav li").removeClass("active");$(this).addClass("active");$(".brui-tabs-content>div").css({display:"none"});if($(this).attr("id")=="tab1-tab"){$("#related-articles-body").css({display:"block"});}else if($(this).attr("id")=="tab2-tab"){$("#hot-debates-body").css({display:"block"});}else if($(this).attr("id")=="tab3-tab"){$("#more-author-body").css({display:"block"});}else{return false;}}});$(".leave-a-comment").click(function(e){e.preventDefault();var offset=$(".the-comment").offset().top-100;$("html,body").animate({scrollTop:offset},1000);});$('.number').changeFontSize();$("#select-all").click(function(e){$("#email-select-contacts input").attr("checked","checked");$("#select-none").attr("checked","");});$("#select-none").click(function(e){$("#email-select-contacts input").attr("checked","");$("#select-all").attr("checked","");});});jQuery.noConflict();jQuery(function($){var dom={pickButton:$(".article-pick-button"),pickCountersWithParantheses:$(".article-pick-counter"),pickCountersWithoutParantheses:$("#votes, #article-meta-box .article-pick-counter, #article-stats-info .likes .number"),pickHistory:$("#article-pick-history"),pickProgress:$("#article-pick-progress")}
dom.pickButton.click(function(){if(BR.currentUser){dom.pickProgress.show();if(dom.pickButton.hasClass("article-picked")){unpickArticle(BR.article,BR.currentUser);}else{pickArticle(BR.article,BR.currentUser);}}else{BR.signUp("You must sign up first to provide article feedback.")}});$("#article-pick-container").hover(function(){if(dom.pickButton.hasClass("article-picked")){showHistory();}},function(event){hideHistory();});var pickArticle=function(article,user){var cookie=$.cookie('pod_'+BR.currentArticle.id);$.post("/articles/"+article.id+"/picks",{article_id:article.id,author_id:article.author_id,user_id:user.id},function(data){var picks=eval(data);updateHistory(picks);updateCounter(1);dom.pickButton.addClass("article-picked");dom.pickProgress.hide();if(!cookie)
FacebookConnect.publishArticleLike();});};var unpickArticle=function(article,user){$.post("/articles/"+article.id+"/picks/destroy",{article_id:article.id,author_id:article.author_id,user_id:user.id},function(data){var picks=eval(data);updateHistory(picks);updateCounter(-1);dom.pickButton.removeClass("article-picked");dom.pickProgress.hide();});};var hideHistory=function(){dom.pickHistory.hide();};var showHistory=function(){if(dom.pickHistory.find("li").length>0){dom.pickHistory.show();}};var updateCounter=function(update){var count=0;if(dom.pickCountersWithoutParantheses.length>0){count=parseInt(dom.pickCountersWithoutParantheses.eq(0).text())+update;}else{count=parseInt(dom.pickCountersWithParantheses.eq(0).text().replace("(","").replace(")",""))+update;}
dom.pickCountersWithParantheses.text("("+count+")");dom.pickCountersWithoutParantheses.text(count);$(".number").changeFontSize();};var updateHistory=function(picks){dom.pickHistory.empty();dom.pickHistory.append("<h4>Who liked this article?</h4><ul></ul>");$.each(picks,function(i,pick){dom.pickHistory.children("ul").append('<li><img src="'+pick.user_thumbnail+'"><a href="/users/'+pick.user_permalink+'">'+pick.user_full_name+"</a></li>");});};});BR.Comments=function(testing){return new function()
{var delete_comment_delay=5000;var maximum_comment_depth=3;var $=jQuery;var events=$({});var cached_user_likes;var delete_comment_id;var delete_comment_timeout;var disable_comment_requests;var facebook;var page;if(!testing)
$(function()
{$.live(".comment-delete","click",deleteComment);$.live(".comment-edit","click",editComment);$.live(".comment-flag","click",flagComment);$.live(".comment-like","click",likeComment);$.live(".comment-options","click",openCommentOptions);$.live(".comment-reply","click",replyToComment);$.live(".comment-submit","click",submitComment);$.live(".comment-undo-delete","click",undoDeleteComment);$.live(".comment-update","click",updateComment)
$.live(".comment-update-cancel","click",cancelUpdateComment)
$.live(".comment-who-liked","click",openCommentLikes);$.live(".comment-signup","click",signUp);$("#top-level-comments").mousemove(mouseMoveInComments).mouseleave(mouseLeaveComments);$("#main-comment-form textarea").defaultText();$("#comments textarea").elastic();events.bind('onInjectComments',loadUserLikes);events.bind('onInjectRecentComments',loadUserLikes);events.bind('onInjectComments',updateCommentCount);events.bind('onInjectRecentComments',updateCommentCount);if(BR.CommentsFacebook)
facebook=BR.CommentsFacebook();attachScroll();injectComments();injectRecentComments();});$.extend(this,{attachScroll:attachScroll,injectComments:injectComments,injectCommentsResponse:injectCommentsResponse,injectRecentComments:injectRecentComments,injectRecentCommentsResponse:injectRecentCommentsResponse,overwriteFunction:overwriteFunction,submitComment:submitComment});function attachScroll(){var footer_height=$(document).height();footer_height-=Math.round($('#sitewrapper').position().top);footer_height-=$('#sitewrapper').height();$(window).scroll(function(){if($(window).scrollTop()>=$(document).height()-$(window).height()*2-footer_height)
injectComments();});}
function cancelUpdateComment(event)
{var comment_container=$(event.target).closest("dd");var comment_edit_body=$(".comment-edit-body:first",comment_container);$(".comment-body:first",comment_container).show();comment_edit_body.hide();comment_edit_body.next(".comment-edit-container").hide();comment_container.children("ul.footer").removeClass("fade");event.preventDefault();}
function createCommentLikes(comment_id,insertion_point)
{var comment_likes=$("#comment-likes-template").clone().removeAttr("id").css({"left":insertion_point.prevAll(".first").outerWidth(),"top":insertion_point.position().top+insertion_point.outerHeight()}).show();insertion_point.append(comment_likes);comment_likes.css("display","block");$.ajax({url:"/articles/comments/"+comment_id,dataType:"json",success:function(data){loadCommentLikes(comment_likes,data);}});}
function createCommentOptions(insertion_point)
{var comment_options=$("#comment-options-template").clone().removeAttr("id").css("top",insertion_point.position().top+insertion_point.outerHeight()).show();insertion_point.append(comment_options);return comment_options;}
function createReplyForm(insertion_point)
{var reply_form=$("#main-comment-form").clone().removeAttr("id").hide();var dt=insertion_point.closest("dd").prev("dt");var author=$(".author",dt).text();var first_name=$(".first_name",dt).text();$("textarea",reply_form).val("Reply to "+author+"'s comment").defaultText();insertion_point.after(reply_form);if(reply_form.parents("dd").length==maximum_comment_depth)
$(".comment-reply-to",reply_form).html('@'+first_name+':');reply_form.slideDown(function(){$("textarea",reply_form).elastic().focus();});}
function deleteComment(event)
{var delete_comment=$(event.target);var comment_body=delete_comment.closest("dd");var comment=comment_body.prev("dt");var comment_author_id=$(".author_id",comment).text();if(isUserAnAdmin()||(BR.currentUser&&BR.currentUser.id==comment_author_id))
{var delete_comment_overlay=$("#delete-comment-overlay");delete_comment_id=comment.attr("id");delete_comment.closest(".comment-options-container").hide();$("span.avatar",comment).hide();comment.addClass("being-deleted");comment_body.slideUp();if(comment_body.children("dl").length)
{$("span",delete_comment_overlay).hide();$("span.parent",delete_comment_overlay).show();}
else
{$("span",delete_comment_overlay).show();$("span.parent",delete_comment_overlay).hide();}
delete_comment_overlay.css({"top":comment.position().top,"height":comment.outerHeight()}).show();delete_comment_timeout=window.setTimeout(function()
{var url="/articles/"+BR.currentArticle.id+"/comments/"+getId(comment);if(BR.proxied_email)
url+='?proxied_email='+BR.proxied_email;$.ajax({type:"delete",url:url,dataType:"json",success:deleteCommentSuccess,error:deleteCommentError});},delete_comment_delay);}
event.preventDefault();}
function deleteCommentError()
{$("<div></div>").lightbox({content:"Bleacher Report experienced an error - please try deleting the comment again.  If the problem persists, please contact us to let us know about the problem.",header:"There was an error"})}
function deleteCommentSuccess(data)
{var comment=$("#comment-"+data);comment.next("dd").remove();comment.remove();$("#delete-comment-overlay").hide();updateCommentCount();}
function editComment(event)
{var edit_comment=$(event.target);var comment=edit_comment.closest("dd").prev("dt");var comment_author_id=$(".author_id",comment).text();if(isUserAnAdmin()||(BR.currentUser&&BR.currentUser.id==comment_author_id))
{var comment_container=edit_comment.closest("dd");var comment_edit_body=$(".comment-edit-body:first",comment_container);edit_comment.closest(".comment-options-container").hide();$(".comment-body:first",comment_container).hide();comment_edit_body.show().elastic().after(comment_edit);if(!comment_edit_body.next(".comment-edit-container").length)
{var comment_edit=$("#comment-edit-template").clone().removeAttr("id");comment_edit_body.after(comment_edit);}
comment_edit_body.next(".comment-edit-container").show();comment_container.children("ul.footer").addClass("fade");}
event.preventDefault();}
function flagComment(event)
{$(event.target).closest(".comment-options-container").hide();if(!isUserABozo())
{$.ajax({type:"post",url:"/flaggings",data:{comment_id:getId($(event.target).closest("dd"))},dataType:"json",success:flagCommentSuccess});}
event.preventDefault();}
function flagCommentSuccess()
{$("<div></div>").lightbox({content:"The comment has been flagged for review.",header:"Comment flagged"})}
function getId(el){switch(el.get(0).tagName){case'DT':return el.attr("id").replace(/comment-/,"");case'DD':return el.prev("dt").attr("id").replace(/comment-/,"");default:throw"you can only pass a DD or DT element to getId(el)";}}
function hideAllCommentOptions(comment)
{if(comment)
{var element=null;$(".comment-actions:visible, .comment-options-container:visible").each(function()
{element=$(this);if(element.closest("dd").prev("dt").attr("id")!=comment)
{element.hide();}});}
else
{$(".comment-actions:visible, .comment-options-container:visible").hide();}}
function injectComments(){if(disable_comment_requests)return;disable_comment_requests=true;page=page?page+1:1;$('#comments_loading').show();var url="/articles/"+BR.currentArticle.id+"/comments/page/"+page;BR.AjaxQueue.queue(function(){$.get(url,injectCommentsResponse,'html');});}
function injectCommentsResponse(comments){$('#comments_loading').hide();if($.trim(comments)!=''){$('#top-level-comments').append(comments);updateRecentComments();if(!$('#end_of_comments').length)
disable_comment_requests=false;events.trigger('onInjectComments');}
BR.AjaxQueue.dequeue();}
function injectRecentComments(){var url="/articles/"+BR.currentArticle.id+"/comments/recent";BR.AjaxQueue.queue(function(){$.get(url,injectRecentCommentsResponse,'html');});}
function injectRecentCommentsResponse(html){$('body').append(html);updateRecentComments();events.trigger('onInjectRecentComments');BR.AjaxQueue.dequeue();}
function isUserAnAdmin()
{return isUserLoggedIn()&&BR.currentUser.isAdmin;}
function isUserABozo()
{return isUserLoggedIn()&&BR.currentUser.is_a_bozo;}
function isUserLoggedIn()
{return BR.currentUser;}
function isUserOnProbation()
{return isUserLoggedIn()&&BR.currentUser.on_probation;}
function likeComment(event)
{var comment=$(event.target).closest("dd").prev("dt");var comment_author_id=$(".author_id",comment).text();if(isUserOnProbation())
{showProbationLightbox();}
else if(!isUserABozo()&&(!BR.currentUser||BR.currentUser.id!=comment_author_id))
{$.ajax({type:"post",url:"/articles/"+BR.currentArticle.id+"/comments/"+getId(comment)+"/vote",data:{type:1},dataType:"json",success:likeCommentSuccess});}
event.preventDefault();}
function likeCommentSuccess(data)
{var like_button=markCommentLiked(data.comment_id,data.liked);if(data.count==1)
{$("span.count",like_button).text(data.count+" like");}
else
{$("span.count",like_button).text(data.count+" likes");}}
function loadCommentLikes(comment_likes_container,data)
{var comment_likes=data.also_liked;var guest_likes=data.guest_count;$(".loading",comment_likes_container).hide();if((comment_likes.length+guest_likes)>0)
{var comment_like;$(".no-likes",comment_likes_container).hide();for(var i=0,l=comment_likes.length;i<l;i++)
{comment_like=comment_likes[i];comment_likes_container.append('<li><a href="'+comment_like.profile_url+'"><img src="'+comment_like.picture+'"> '+comment_like.name+'</a></li>');}
if(guest_likes==1)
{comment_likes_container.append('<li class="guests">'+guest_likes+' guest</li>');}
else if(guest_likes>1)
{comment_likes_container.append('<li class="guests">'+guest_likes+' guests</li>');}}
else
{$(".no-likes",comment_likes_container).show();}}
function loadUserLikes()
{if(BR.currentUser)
{if(cached_user_likes)
{markCurrentUserLikes(cached_user_likes);}
else
{BR.AjaxQueue.queue(function(){if(cached_user_likes)
{markCurrentUserLikes(cached_user_likes);BR.AjaxQueue.dequeue();}
else
{$.ajax({url:"/articles/"+BR.currentArticle.id+"/votes/"+BR.currentUser.id,dataType:"json",success:function(data){cached_user_likes=data;markCurrentUserLikes(data);BR.AjaxQueue.dequeue();}});}});}}
try
{if(DD_belatedPNG)
{DD_belatedPNG.fix(".png-fix");}}
catch(exception)
{}}
function markCommentLiked(comment_id,liked)
{var like_button=$("ul.footer:first a.comment-like",$("#comment-"+comment_id).next()).parent();if(liked)
{like_button.addClass("liked");}
else
{like_button.removeClass("liked");}
return like_button;}
function markCurrentUserLikes(comment_ids)
{for(var i=0,l=comment_ids.length;i<l;i++)
{markCommentLiked(comment_ids[i],true);}}
function mouseLeaveComments()
{hideAllCommentOptions();}
function mouseMoveInComments(event)
{var eventTarget=$(event.target);var comment=eventTarget.closest("dt");if(comment.length)
{comment=comment.next("dd");}
else
{comment=eventTarget.closest("dd");}
hideAllCommentOptions(comment.prev("dt").attr("id"));$(".comment-actions:hidden",comment.children("ul.footer")).show();}
function openCommentLikes(event)
{var insertion_point=$(event.target).parent();var existing_comment_likes=insertion_point.children(".comment-likes-container");if(existing_comment_likes.length)
{existing_comment_likes.toggle();}
else
{createCommentLikes(getId(insertion_point.closest("dd")),insertion_point);}
event.stopPropagation();event.preventDefault();return false;}
function openCommentOptions(event)
{var insertion_point=$(event.target).closest("li");var existing_comment_options=insertion_point.children(".comment-options-container");if(existing_comment_options.length)
{existing_comment_options.toggle();}
else
{var comment=insertion_point.closest("dd").prev("dt");var comment_author_id=$(".author_id",comment).text();var comment_options=createCommentOptions(insertion_point);if(!isUserAnAdmin()&&(!BR.currentUser||BR.currentUser.id!=comment_author_id))
{$(".comment-delete",comment_options).parent().hide();$(".comment-edit",comment_options).parent().hide();}}
event.preventDefault();}
function overwriteFunction(name,fn){fn=fn||function(){};eval(name+' = fn');this[name]=fn;}
function replyToComment(event)
{if(isUserOnProbation())
{showProbationLightbox();}
else
{var insertion_point=$(event.target).closest("dd");var existing_reply_form=insertion_point.children(".comment-form-container");$(this).closest("li").toggleClass("replying");if(existing_reply_form.length)
{existing_reply_form.slideUp(function(){$(this).remove();});}
else
{createReplyForm($("div.clear",insertion_point).eq(0));}}
event.preventDefault();}
function showProbationLightbox()
{$("<div></div>").lightbox({content:"You have been benched due to inappropriate behavior. To plead your case for renewal, please contact administrator@bleacherreport.com",header:"You have been benched!"})}
function signUp(event)
{BR.signUp();event.preventDefault();}
function submitComment(event)
{if(isUserOnProbation())
{showProbationLightbox();}
else
{var textarea=$(this).parent().prevAll("textarea");var textarea_value=textarea.val();if(textarea_value&&textarea_value!=textarea.data("default-text"))
{var data={body:textarea_value,article_id:BR.currentArticle.id};var parent_comment,real_parent_comment;if(BR.proxied_email)
$.extend(data,{proxied_email:BR.proxied_email});parent_comment=real_parent_comment=$(this).closest("dd");if($(this).parents("dd").length==maximum_comment_depth)
{parent_comment=real_parent_comment.parents("dd").eq(0);}
if(parent_comment.length)
{$.extend(data,{parent_id:getId(parent_comment)})}
if(real_parent_comment.length)
{$.extend(data,{real_parent_id:getId(real_parent_comment)})}
$(this).addClass("brui-inactive");$(this).next("img").show();textarea.addClass("inactive");$.ajax({type:"post",url:"/articles/"+BR.currentArticle.id+"/comments",data:data,dataType:"json",success:submitCommentSuccess,error:submitCommentError});}}
if(event)
event.preventDefault();}
function submitCommentError()
{$("<div></div>").lightbox({content:"Bleacher Report experienced an error - please try submitting your comment again.  If the problem persists, please contact us to let us know about the problem.",header:"There was an error"})}
function submitCommentSuccess(comment)
{var comment_body=$("#comment-template dd").clone();var comment_header=$("#comment-template dt").clone();var comment_id=comment.id;var insertion_point=$("#top-level-comments");if(comment.parent_id)
{var parent_comment_body=$("#comment-"+comment.parent_id).next("dd");var parent_comment_children=$("dl",parent_comment_body);if(parent_comment_children.length)
{insertion_point=parent_comment_children.eq(0);}
else
{parent_comment_body.append('<dl class="child"></dl>');insertion_point=$("dl",parent_comment_body);}
$("li.replying",parent_comment_body).removeClass("replying");}
else
{$(".comment-form textarea").val("Post a comment").removeClass("inactive");$(".comment-submit").removeClass("brui-inactive");$(".comment-submit-loading").hide();comment_body.addClass("parent");}
if(!BR.currentUser)
$('.avatar',comment_header).html('<img src="'+comment.avatar+'" />');comment_header.attr("id","comment-"+comment_id);insertion_point.append(comment_header);$(".comment-body",comment_body).html(comment.public_body);$(".comment-edit-body",comment_body).val(comment.body);insertion_point.append(comment_body);if(comment.parent_id)
{$(".comment-form-container",parent_comment_body).slideUp(function(){$(this).remove();window.scrollTo(0,$("#comment-"+comment_id).position().top-50);});}
else
{window.scrollTo(0,$("#comment-"+comment_id).position().top-50);}
try
{if(DD_belatedPNG)
{DD_belatedPNG.fix(".png-fix");}}
catch(exception)
{}
updateCommentCount();FacebookConnect.publishComment({body:comment.body});}
function undoDeleteComment(event)
{var comment=$("#"+delete_comment_id);window.clearTimeout(delete_comment_timeout);$("#delete-comment-overlay").hide();$("span.avatar",comment).show();comment.removeClass("being-deleted").next("dd").slideDown();event.preventDefault();}
function updateComment(event)
{var textarea=$(this).parent().prev("textarea");var textarea_value=textarea.val();if(textarea_value)
{var data={body:textarea_value,'_method':'put'};var parent_comment=$(this).closest("dd");if(BR.proxied_email)
$.extend(data,{proxied_email:BR.proxied_email});$(this).addClass("brui-inactive");$(this).prev("img").show();$(this).prevAll("a").hide();textarea.addClass("inactive");$.ajax({type:"post",url:"/articles/"+BR.currentArticle.id+"/comments/"+getId(parent_comment),data:data,dataType:"json",success:updateCommentSuccess,error:updateCommentError});}
event.preventDefault();}
function updateCommentCount()
{var comment_count=$("#top-level-comments dt").length;var el=$(".comment_count");el.text(comment_count);if(comment_count==0)
{el.eq(0).parent().hide();$('#no_comments').show();}
else
{el.eq(0).parent().show();$('#no_comments').hide();if(comment_count==1)
{$(".comment-label").text("Comment");}
else
{$(".comment-label").text("Comments");}}}
function updateCommentError()
{$("<div></div>").lightbox({content:"Bleacher Report experienced an error - please try submitting your comment again.  If the problem persists, please contact us to let us know about the problem.",header:"There was an error"})}
function updateCommentSuccess(comment)
{var comment_id=comment.id;var comment_container=$("#comment-"+comment_id).next("dd");var comment_content=comment.public_body;var comment_edit_body=$(".comment-edit-body:first",comment_container);var comment_edit_container=comment_edit_body.next(".comment-edit-container");$(".comment-body",comment_container).html(comment_content);$(".comment-body:first",comment_container).show();comment_edit_body.hide();comment_edit_container.hide();$(".comment-update",comment_edit_container).removeClass("brui-inactive");$(".comment-update-loading",comment_edit_container).hide();comment_container.children("ul.footer").removeClass("fade");}
function updateRecentComments(){var recent_comments=$('#recent_comments dt');if(recent_comments.length)
recent_comments.each(function(){var id=$('.comment_id',this).html();var parent_id=$('.parent_id',this).html();var date=parseInt($('.date_to_integer',this).html());var dt=$(this);var dd=$(this).next();var match=$('#comment-'+id);if(match.length){dd.append($('> dl',match.next()));match.next().replaceWith(dd);match.replaceWith(dt);setId(dt,id);}else{var scope=parent_id==''?'s > dl':'-'+parent_id+' + dd > dl';var comments=$('#comment'+scope+' > dt > .date_to_integer').map(function(){return{dt:$(this).parent(),dd:$(this).parent().next(),date:parseInt(this.innerHTML)};});$.each(comments,function(index,comment){var next_comment=comments[index+1];if(index==0&&date<comment.date){comment.dt.before(dt);comment.dt.before(dd);setId(dt,id);return false;}else if(next_comment&&date>=comment.date&&date<=next_comment.date){comment.dd.after(dd);comment.dd.after(dt);setId(dt,id);return false;}else if(!next_comment&&date>=comment.date&&($('#end_of_comments').length||parent_id!='')){comment.dd.after(dd);comment.dd.after(dt);setId(dt,id);return false;}});if(comments.length==0){if(parent_id){var parent_dd=$('#comment-'+parent_id+' + dd');if(parent_dd.length){parent_dd.append('<dl class="child"></dl>').children('dl').append(dt).append(dd);setId(dt,id);}}else{$('#top-level-comments').prepend(dd).prepend(dt);setId(dt,id);}}}});var deleted=$('#recent_comments .deleted');if(deleted.length)
$.each(deleted.html().split(/\s/),function(index,id){$('#comment-'+id+', #comment-'+id+' + dd').remove();});var count=$('#recent_comments .count');if(count.length)
$('.comment_count').html(count.html());var liked=$('#recent_comments .liked');if(liked.length)
$.each(eval(liked.html()),function(index,item){$('> ul .comment-like .count',$('#comment-'+item.comment_id).next('dd')).html(item.count+' likes');});function setId(dt,id){dt.attr('id','comment-'+id);}}};};jQuery(function($){var call_ajax=true;var viewed_articles=$.cookie('viewed_articles');if(viewed_articles)
$.each(viewed_articles.split('+'),function(index,item){if(parseInt(item)==BR.currentArticle.id)
call_ajax=false;});if(call_ajax)
BR.AjaxQueue.queue(function(){$.get('/articles/'+BR.currentArticle.id+'/hit_count',null,response);});function response(){BR.AjaxQueue.dequeue();}});(function($)
{var bs_param_name="bs";var bs_param_value="hide";var cookie_expiration=180;var cookie_name="hide-barely-sports";var utm_source_param_name="utm_source";var bs_param=$(document).getUrlParam(bs_param_name);var utm_source_param=$(document).getUrlParam(utm_source_param_name);var referrer=document.referer;if((bs_param&&bs_param==bs_param_value)||(utm_source_param&&utm_source_param=="nhl.com")||(referrer&&referrer.indexOf("nhl.com")>0))
{$.cookie(cookie_name,"true");}
if($.cookie(cookie_name))
{$("#barely-sports-widget").remove();}
$("#barely-sports-hide").click(hideBarelySportsWidget);function hideBarelySportsWidget(event)
{$("#barely-sports-widget").remove();$.cookie("hide-barely-sports","true",{expires:cookie_expiration});BR.Analytics.sendEvent("barely-sports-hidden","#");event.preventDefault();}})(jQuery);function getCookie(name){var start=document.cookie.indexOf(name+"=");var len=start+name.length+1;if((!start)&&(name!=document.cookie.substring(0,name.length))){return null;}
if(start==-1)return null;var end=document.cookie.indexOf(';',len);if(end==-1)end=document.cookie.length;return unescape(document.cookie.substring(len,end));}
function setCookie(name,value,expires,path,domain,secure){var today=new Date();today.setTime(today.getTime());if(expires){expires=expires*1000*60*60*24;}
var expires_date=new Date(today.getTime()+(expires));document.cookie=name+'='+escape(value)+
((expires)?';expires='+expires_date.toGMTString():'')+
((path)?';path='+path:'')+
((domain)?';domain='+domain:'')+
((secure)?';secure':'');}
function deleteCookie(name,path,domain){if(getCookie(name))document.cookie=name+'='+
((path)?';path='+path:'')+
((domain)?';domain='+domain:'')+';expires=Thu, 01-Jan-1970 00:00:01 GMT';}
var hideAuthorArticle=function(){var recent_articles=$$('#author-articles a');var rm=function(item){item=item.parentNode;if(item)
item.remove();};recent_articles.each(function(item,index){if(item.readAttribute('href')){if(item.readAttribute('href').split('/')[2]==BR.currentArticle.permalink){rm(item);throw $break;}}
if(index==recent_articles.length-1)
rm(item);});};var hideMustRead=function(){var must_reads=$$('#top-related-stories .story a');var rm=function(item){item=item.parentNode;if(item)
item.remove();};must_reads.each(function(item,index){if(item.readAttribute('href'))
if(item.readAttribute('href').split('/')[2]==BR.currentArticle.permalink){rm(item);throw $break;}
if(index==must_reads.length-1)
rm(item);});};BR.CreatePoll=Class.create({initialize:function(opts){this.poll=new Object();this.articleId=opts.articleId;this.choices=new Array();this.choiceList=$('poll-choice-list');this.questionList=$('poll-question-list');this.questionBox=$('poll-question');this.createPollBox=$('create-poll');this.addPollBox=$('add-poll');this.reviewButton=$('review-poll');this.saveButton=$('save-poll');this.editButton=$('edit-poll');this.pollForm=$('poll-form');this.pollReview=$('poll-review');this.messageBox=$('poll-messages');this.errorMessage=$('error-messages');this.serverError=$('server-error');this.displayNextChoice();Event.observe(this.reviewButton,'click',this.review.bindAsEventListener(this),false);Event.observe(this.saveButton,'click',this.save.bindAsEventListener(this),false);Event.observe(this.editButton,'click',this.edit.bindAsEventListener(this),false);},displayNextChoice:function(){if(this.choices.length<10){var li=new Element('li');var input=new Element('input',{'type':'text','id':'choice'+this.choices.length,'class':'text-input'});Event.observe(input,'focus',function(){if(this.choices.indexOf(input)==this.choices.length-1)
this.displayNextChoice();}.bindAsEventListener(this));Event.observe(input,'blur',function(){if(input.value=='')this.hideNextChoice();}.bindAsEventListener(this));this.choices[this.choices.length]=input;this.choiceList.insert(li);li.insert(input);}},hideNextChoice:function(){var choice=this.choices[this.choices.length-1];if(choice.value==''){choice.parentNode.replace();this.choices.splice(this.choices.length-1,1);}},save:function(e){var that=this;var url='/articles/'+this.poll.article_id+'/polls';if(that.valid()){new Ajax.Request(url,{method:'post',parameters:that.poll,onLoading:function(){that.saving();},onSuccess:function(res){if(res.responseJSON.saved){that.finish(res.responseJSON);}else{that.messageBox.hide();that.editButton.show();that.saveButton.show();that.errorMessage.show();}},onFailure:function(){that.messageBox.hide();that.editButton.show();that.saveButton.show();that.serverError.show();}});}else{that.errorMessage.show();}
e.stop();return false;},valid:function(){if(this.poll.question==''){return false;}
if(this.poll.choice0==''||this.poll.choice1==''){return false;}
return true;},mock:function(){var that=this;var i=0;that.poll=new Object();that.poll.question=that.questionBox.value;that.poll.article_id=that.articleId;that.choices.each(function(choice){if(choice.value!=''){eval('that.poll.choice'+i+' = choice.value');i++;}});},review:function(e){this.mock();if(this.valid()){var that=this;var tempObj=new Object();var pollTemp=new Template('<div id="poll"><h5>Author Poll Preview</h5><p class="poll-question">#{question}</p><form><ul id="poll-choices"></ul><input disabled type="submit" value="Vote" /></form><small>vote to see results</small></div>');that.pollForm.hide();that.reviewButton.hide();that.pollReview.update('');that.saveButton.show();that.editButton.show();that.pollReview.update(pollTemp.evaluate(that.poll));that.choices.each(function(choice){if(choice.value!=''){var choiceInput=new Element('input',{'type':'radio','name':'vote'});var choiceLi=new Element('li',{'class':'option radio'}).update(choiceInput);choiceLi.insert(' '+choice.value);$('poll-choices').insert(choiceLi);}});that.pollReview.show();}else{that.errorMessage.show();}
e.stop();return false;},edit:function(e){this.pollForm.show();this.reviewButton.show();this.pollReview.hide();this.saveButton.hide();this.editButton.hide();e.stop();return false;},finish:function(response){this.addPollBox.update('You successfully created a poll for this article!');this.createPollBox.hide();this.createPollBox.replace();$('poll').update(response.poll);},saving:function(){this.messageBox.show();this.editButton.hide();this.saveButton.hide();}});BR.showArticle=new Object();BR.showArticle.startScroll=null;BR.showArticle.moveRelatedBox=function(amount){var scrollBox=$('related-articles-scroller');var relatedTop=$('about-the-author').cumulativeOffset()[1]+$('about-the-author').getHeight();var footerTop=$('footer').cumulativeOffset()[1];var scrollBoxTop=scrollBox.cumulativeOffset()[1];var scrollBoxHeight=$('related-articles-scroller').getHeight()+$('popular-comments').getHeight()+$('recommended-pages').getHeight();if($('recommended-articles'))
scrollBoxHeight+=$('recommended-articles').getHeight();if(amount>(relatedTop-4)){if(scrollBoxHeight>(footerTop-amount)){new Effect.Move(scrollBox,{x:0,y:((footerTop-scrollBoxHeight)-(relatedTop-4)),mode:'absolute'});}
else{new Effect.Move(scrollBox,{x:0,y:(amount-(relatedTop-4)),mode:'absolute'});}}
else{new Effect.Move(scrollBox,{x:0,y:0,mode:'absolute'});}
scrollBox=null;};BR.showArticle.relatedScrollObserver=function(event){if(BR.showArticle.scrollTimer){clearInterval(BR.showArticle.scrollTimer);}
else{BR.showArticle.startScroll=document.documentElement.scrollTop;}
BR.showArticle.scrollTimer=setInterval("BR.showArticle.moveRelated()",100);};BR.showArticle.moveRelated=function(){var amount=document.viewport.getScrollOffsets()[1];if(BR.showArticle.startScroll==amount){clearInterval(BR.showArticle.scrollTimer);BR.showArticle.scrollTimer=null;BR.showArticle.moveRelatedBox(amount);}
BR.showArticle.startScroll=amount;};document.observe('dom:loaded',function(){$('flag-article-button').observe('click',BR.showArticle.showFlagArticle);});BR.showArticle.flag={};BR.showArticle.showFlagArticle=function(){if(BR.currentUser){if(BR.currentUser.on_probation){return(null);}
BR.showArticle.flaggingLightBox=new BR.Lightbox({title:'Why are you flagging this article?',class_name:'flagging',parent_element:$('article-column'),box_type:'narrow',content:BR.showArticle.flag.view,on_open:BR.showArticle.flag.controller});}else{BR.signUp();}}
BR.showArticle.flag.controller=function(){$('article-flagging').observe("click",BR.showArticle.flag.eventHandler);}
BR.showArticle.flag.eventHandler=function(event){if(event.target.parentNode.name=="flag_type"){BR.showArticle.flag.typeChange(event.target.value);}
if(event.target.id=="flagging-submit"){BR.showArticle.flag.submit();}}
BR.showArticle.flag.typeChange=function(value){switch(value){case'plagiarism':$('flaggings-comment-info').update("Where is this article plagiarized from?");break;case'offensive':$('flaggings-comment-info').update("Why is this article offensive?");break;case'duplicate':$('flaggings-comment-info').update("What is the duplicate article?");break;}}
BR.showArticle.flag.submit=function(){var attributes={};attributes.comments=$('flaggings-comments').value;attributes.flag_type=$('flaggings-type').value;new Ajax.Request('/articles/'+BR.currentArticle.id+'/flaggings',{method:"post",parameters:attributes});BR.showArticle.flaggingLightBox.close();}
BR.showArticle.flag.view=function(){var div=new Element('div',{'id':'article-flagging'});var flagType=new Element('div',{'class':'flag-type'}).update("This article is ");var select=new Element('select',{'id':'flaggings-type','name':'flag_type'});select.insert(new Element('option',{'value':'plagiarism'}).update("plagiarized"));select.insert(new Element('option',{'value':'offensive'}).update("offensive"));select.insert(new Element('option',{'value':'duplicate'}).update("a duplicate"));var commentInfo=new Element('div',{'id':'flaggings-comment-info'}).update("Where is this article plagiarized from?");var commentBox=new Element('textarea',{'id':'flaggings-comments','name':'comments'});var submit=new Element('a',{'id':'flagging-submit','class':'button standard'}).update("Flag This Article");div.insert(flagType);div.insert(select);div.insert(commentInfo);div.insert(commentBox);div.insert(submit);return div;}
Event.observe(window,'load',function(){$('comments').observe("click",function(event){if(event.target.className.include('post_comment_button')){BR.showArticle.createCommentLoggedOut(event);event.stop();}});})
BR.showArticle.createCommentLoggedOut=function(event){var comment=Form.serializeElements(Form.getElements(event.element().ancestors()[0]),true);comment.article_id=BR.currentArticle.id;BR.Hat.signUpFromCommentSubmit(comment);event.stop();}
document.observe("dom:loaded",function(){if(BR.currentUser&&BR.currentUser.is_a_bozo){$$('.bozo').each(function(elmnt){elmnt.show();});}});BR.CommentsFacebook=function(){return new function(){var $=jQuery;var comment;FacebookConnect.bind('login',updateFormForLogin);FacebookConnect.bind('logout',updateFormForLogout);$.live('.facebook_connect_from_comment','click',function(){if(!$(this).indicate(true))return false;comment=$(this).parent();FacebookConnect.login(dialog);return false;});function dialog(reload){FacebookConnect.user(function(result){if(reload)
dialogInit(result,reload);else
$.post("/accounts/login_via_facebook",{first_name:result.first_name,last_name:result.last_name,proxied_email:result.proxied_email,pic_big:result.pic_big,profile_url:result.profile_url},function(json){if(json==0)
dialogInit(result);else
respond(json);},'json');});}
function dialogInit(result,reload){if(!reload)
$('<div id="facebook_lightbox"></div>').lightbox({header:"Facebook Settings",subHeader:"We need some more details to submit your comment.",content:$('#comment-facebook-template textarea').val(),onClose:function(){FacebookConnect.loggedIn(function(){FacebookConnect.logout();});}});$("#facebook_lightbox .full_name").html('('+result.name+')');$('#new_facebook_user .profile_pic').attr('src',result.pic_square);$("#facebook_user_facebook_id").val(result.uid);$("#facebook_user_first_name").val(result.first_name);$("#facebook_user_last_name").val(result.last_name);$("#facebook_user_profile_pic").val(result.pic_big);$("#facebook_user_profile_url").val(result.profile_url);$("#facebook_user_proxied_email").val(result.proxied_email);$("#facebook_connect_submit").click(submit);var change=$.browser.msie?"click":"change";$('#facebook_user_use_full_name').bind(change,function(){$('#new_facebook_user .full-name-edit:last')[$(this).attr('checked')?'hide':'show']();$("#facebook_user_first_name").val(result.first_name);$("#facebook_user_last_name").val(result.last_name);$('#facebook_user_first_name:visible').select();});};function updateFormForLogin(submit){if($.cookie('logged_in_to_br_through_facebook')=='true'){$('#comment-template .author').html($.cookie('facebook_full_name'));$('.comment-avatar .profile_photo').attr('src',$.cookie('facebook_avatar'));$('#comment-template .avatar').html('<img src="'+$.cookie('facebook_avatar')+'" />');$('.not-logged-in').hide();$('.comment-submit-container').show();if(submit)
scope(BR.comments.submitComment,$('.comment-submit'))();}}
function updateFormForLogout(submit){$('.comment-submit-container').hide();$('.not-logged-in').show();}
function respond(json){$('.facebook_connect_from_comment').indicate(false);$('#facebook_lightbox').remove();FacebookConnect.settingsToCookies(json.settings);updateFormForLogin(true);}
function scope(fn,bind){var args=Array.prototype.slice.call(arguments,2);return function(){return fn.apply(bind,args);}}
function submit(){if(!$('img',this).indicate(true))return false;FacebookConnect.user(function(result){var form=$('.new_facebook_user');$.post(form.attr('action'),form.serialize()+'&facebook_user[friends]='+result.friends.join(',')+'&facebook_user[app_friends]='+result.app_friends.join(','),function(json){if(json==0)
dialogInit(result,true);else if(json.html){$('#new_facebook_user').parent().html(json.html)
dialog(true);}else
respond(json);},'json');});}}};