/* From: wfe8-nyc : 21765 */
(function(){function HPScrollbar(element_or_id,sb_target_el_or_id,height){this.target=undefined;this.sb_container=undefined;this.height=undefined;this.rendered=false;this._hp_scrollbar=undefined;this._scroller=undefined;this._hp_sb_up=undefined;this._hp_sb_down=undefined;this._hp_sb_scroll_t=undefined;this._hp_sb_scroll_b=undefined;this._hp_sb_track=undefined;this._first_click_y=undefined;this._can_drag=false;this._step_delta=40;this._step=0;this._scroller_height=undefined;this._scroll_delta=0;this._can_draw=false;this._on_bottom_callback=undefined;this._on_bottom_callback_ctx=undefined;this._on_bottom_callback_indent=20;this._update_on_init=false;this._run_in_progress=false;this._applyTo(element_or_id,sb_target_el_or_id,height);};HPScrollbar.prototype._applyTo=function(element_or_id,sb_target_el_or_id,height){if(!element_or_id){return;}
var D=Dom;this.target=typeof element_or_id=='string'?D.get(element_or_id):element_or_id;this.sb_container=typeof sb_target_el_or_id=='string'?D.get(sb_target_el_or_id):sb_target_el_or_id;this.height=height||parseInt(this.target.offsetHeight);this.run();};HPScrollbar.prototype.onBottom=function(callback,context,indent){if(callback){this._on_bottom_callback=callback;this._on_bottom_callback_ctx=context||this;if(indent){this._on_bottom_callback_indent=indent;}}};HPScrollbar.prototype.run=function(){var sprite=new Image();this._run_in_progress=true;E.addListener(sprite,'load',function(){this._setScrollerHeight();if(this._can_draw){this._draw();this._init();this._applyEvents();this.reset();this.rendered=true;if(this._update_on_init){this.update();this._update_on_init=false;}}
this._run_in_progress=false;},undefined,this);sprite.src='http://s.huffpost.com/images/hp_scrollbar.png';};HPScrollbar.prototype.reset=function(){this._moveScroll(0);};HPScrollbar.prototype._setScrollerHeight=function(){var scroller_height=20;if(this.target.scrollHeight>this.target.clientHeight){scroller_height=(this.height*(this.height-34))/this.target.scrollHeight;scroller_height=Math.round(scroller_height);scroller_height=scroller_height<15?15:scroller_height;this._can_draw=true;this._show();}else{this._hide();}
this._scroller_height=scroller_height;};HPScrollbar.prototype._draw=function(){var sb_html='\
          <div class="hp_scrollbar">\
            <div class="hp_sb_up hp_sb_bg"><b></b></div>\
            <div class="hp_sb_c hp_sb_bg" style="height: '+(this.height-34)+'px">\
                <div class="hp_sb_scroll hp_sb_bg" style="height: '+this._scroller_height+'px">\
                    <div class="hp_sb_scroll_t hp_sb_bg"><b></b></div>\
                    <div class="hp_sb_scroll_b hp_sb_bg" style="margin-top: '+(this._scroller_height-4)+'px"><b></b></div>\
                </div>\
            </div>\
            <div class="hp_sb_down hp_sb_bg"><b></b></div>\
          </div>\
        ';if(this.sb_container){this.sb_container.innerHTML=sb_html;}};HPScrollbar.prototype._show=function(){if(this._is_hidden()){Dom.removeClass(this.sb_container,'invisible');}};HPScrollbar.prototype._hide=function(){if(!this._is_hidden()){Dom.addClass(this.sb_container,'invisible');}};HPScrollbar.prototype._is_hidden=function(){return Dom.hasClass(this.sb_container,'invisible');};HPScrollbar.prototype._init=function(){this._scroller=Dom.getElementsByClassName('hp_sb_scroll','div',this.sb_container)[0];this._hp_sb_up=Dom.getElementsByClassName('hp_sb_up','div',this.sb_container)[0];this._hp_sb_down=Dom.getElementsByClassName('hp_sb_down','div',this.sb_container)[0];this._hp_sb_scroll_t=Dom.getElementsByClassName('hp_sb_scroll_t','div',this.sb_container)[0];this._hp_sb_scroll_b=Dom.getElementsByClassName('hp_sb_scroll_b','div',this.sb_container)[0];this._hp_sb_track=Dom.getElementsByClassName('hp_sb_c','div',this.sb_container)[0];this._hp_scrollbar=Dom.getElementsByClassName('hp_scrollbar','div',this.sb_container)[0];this.recalculateStep();};HPScrollbar.prototype._moveScroll=function(y,animate){y=Math.ceil(y);var max_y=this.height-34-this._scroller_height-4;if(y<0){y=0;}else if(y>max_y){y=max_y;}
var scrollTop=y*(this.target.scrollHeight-this.height)/max_y;var delta=(this.target.scrollHeight-this.height)/max_y;if(animate){var current_position=this._getScrollPosition();var attributes={marginTop:{from:current_position,to:y}};var anim_sb=new YAHOO.util.Anim(this._scroller,attributes,0.25);anim_sb.animate();attributes={scroll:{to:[current_position,scrollTop]}};var anim_cnt=new YAHOO.util.Scroll(this.target,attributes,0.25);anim_cnt.animate();}else{Dom.setStyle(this._scroller,'margin-top',y+'px');this.target.scrollTop=scrollTop;}
var scrollBottom=this.target.scrollHeight-(this.target.scrollTop+this.height);if(this._on_bottom_callback&&scrollBottom<this._on_bottom_callback_indent){this._on_bottom_callback.apply(this._on_bottom_callback_ctx);this._on_bottom_callback=undefined;}};HPScrollbar.prototype._applyEvents=function(){var hp_sb_up=this._hp_sb_up;var hp_sb_down=this._hp_sb_down;var hp_sb_scroll=this._scroller;var hp_sb_scroll_t=this._hp_sb_scroll_t;var hp_sb_scroll_b=this._hp_sb_scroll_b;var hp_scrollbar=this._hp_scrollbar;E.on(hp_sb_up,'mouseover',function(){Dom.addClass(this,'hp_sb_up_hv');});E.on(hp_sb_up,'mouseout',function(){Dom.removeClass(this,'hp_sb_up_hv');});E.on(hp_sb_down,'mouseover',function(){Dom.addClass(this,'hp_sb_down_hv');});E.on(hp_sb_down,'mouseout',function(){Dom.removeClass(this,'hp_sb_down_hv');});E.on(hp_sb_scroll,'mouseover',function(e,args){Dom.addClass(args[0],'hp_sb_scroll_t_hv')
Dom.addClass(this,'hp_sb_scroll_hv');Dom.addClass(args[1],'hp_sb_scroll_b_hv');},[hp_sb_scroll_t,hp_sb_scroll_b]);E.on(hp_sb_scroll,'mouseout',function(e,args){Dom.removeClass(args[0],'hp_sb_scroll_t_hv')
Dom.removeClass(this,'hp_sb_scroll_hv');Dom.removeClass(args[1],'hp_sb_scroll_b_hv');},[hp_sb_scroll_t,hp_sb_scroll_b]);E.on(hp_scrollbar,'mousedown',this._dispatchMouseDownEvents,undefined,this);E.on(document,'mousemove',this._handleScrollMouseMove,undefined,this);E.on(document,'mouseup',this._handleScrollMouseUp,undefined,this);E.on(document,'click',this._disableScrolling,undefined,this);E.on([this.target,this.sb_container],'click',this._enableScrolling,undefined,this);};HPScrollbar.prototype._enableScrolling=function(e){E.on([this.target,this.sb_container],'mousewheel',this._handleScrollMouseWheel,undefined,this);E.on([this.target,this.sb_container],'DOMMouseScroll',this._handleScrollMouseWheel,undefined,this);E.stopPropagation(e);};HPScrollbar.prototype._disableScrolling=function(){E.removeListener([this.target,this.sb_container],'mousewheel');E.removeListener([this.target,this.sb_container],'DOMMouseScroll');};HPScrollbar.prototype._dispatchMouseDownEvents=function(e){var target=E.getTarget(e);if(Dom.hasClass(target,'hp_sb_scroll')){this._handleScrollMouseDown(e);}else if(Dom.hasClass(target,'hp_sb_c')){this._handleTrackMouseClick(e,target);}else if(Dom.hasClass(target,'hp_sb_down')){this._handleScrollDownMouseClick(e,target);}else if(Dom.hasClass(target,'hp_sb_up')){this._handleScrollUpMouseClick(e,target);}};HPScrollbar.prototype._handleTrackMouseClick=function(e,target){target=target||E.getTarget(e);if(!Dom.hasClass(target,'hp_sb_c')){return;}
var current_scroller_position=this._getScrollPosition();var click_y_on_track=E.getPageY(e)-Dom.getY(this._hp_sb_track);var scroller_height=this._scroller_height;if(click_y_on_track<current_scroller_position){scroller_height=(-1)*scroller_height;}
var target_scroller_position=current_scroller_position+scroller_height;this._moveScroll(target_scroller_position);};HPScrollbar.prototype._handleScrollMouseWheel=function(e){e=E.getEvent(e);E.stopEvent(e);var delta;if(e.wheelDelta){delta=e.wheelDelta;}else if(e.detail){delta=-e.detail;}
if(delta>0){this._scroll_delta=-1;}else{this._scroll_delta=1;}
this._moveScroll(this._getScrollPosition()+(this._step*this._scroll_delta));};HPScrollbar.prototype._handleScrollUpMouseClick=function(e,target){this._moveScroll(this._getScrollPosition()-this._step,true);};HPScrollbar.prototype._handleScrollDownMouseClick=function(e,target){this._moveScroll(this._getScrollPosition()+this._step,true);};HPScrollbar.prototype._handleScrollMouseDown=function(e){this._can_drag=true;this._first_click_y=E.getPageY(e)-Dom.getY(this.target)-17-this._getScrollPosition();E.stopEvent(e);};HPScrollbar.prototype._handleScrollMouseUp=function(){this._can_drag=false;};HPScrollbar.prototype._handleScrollMouseMove=function(e){if(this._can_drag){var y=E.getPageY(e)-Dom.getY(this.target)-17-this._first_click_y;this._moveScroll(y);E.stopEvent(e);}};HPScrollbar.prototype._getScrollPosition=function(){return parseInt(Dom.getStyle(this._scroller,'margin-top'));};HPScrollbar.prototype.update=function(callback){if(!this._scroller&&this._run_in_progress){this._update_on_init=true;if(callback){callback();}
return;}else if(!this._scroller&&!this._run_in_progress){this.run();if(callback){callback();}
return;}
var target_height=this.target.offsetHeight;var anim_total_time=1;if(target_height!==this.height){this.height=target_height;this._hp_sb_track.style.height=(target_height-34)+'px';anim_total_time=0;}
var scroller_height=this._scroller_height;this._setScrollerHeight();var max_y=this.height-34-this._scroller_height-4;var new_scroller_position=this.target.scrollTop*max_y/(this.target.scrollHeight-this.height);var attributes={height:{from:scroller_height,to:this._scroller_height},marginTop:{to:new_scroller_position}};var anim_sb=new YAHOO.util.Anim(this._scroller,attributes,anim_total_time);attributes={marginTop:{to:this._scroller_height-4}};var anim_sbb=new YAHOO.util.Anim(this._hp_sb_scroll_b,attributes,anim_total_time);if(callback){anim_sbb.onComplete.subscribe(callback);}
anim_sb.animate();anim_sbb.animate();this.recalculateStep();};HPScrollbar.prototype.recalculateStep=function(){this._step=this._step_delta*(this.height-34)/this.target.scrollHeight;};window.HPScrollbar=HPScrollbar;})();
var TwitterUtil={elapsedTime:function(created_at,need_ie_fix)
{var date=created_at;var ageInSeconds;if(need_ie_fix){date=this.fixDate(date);ageInSeconds=(new Date().getTime()-new Date(date).getTime())/1000;if(isNaN(ageInSeconds)){ageInSeconds=(new Date().getTime()-new Date(created_at).getTime())/1000;}}else{ageInSeconds=(new Date().getTime()-new Date(created_at).getTime())/1000;}
var s=function(n){return n==1?'':'s';};if(ageInSeconds<60){return'less than a minute ago';}
if(ageInSeconds<60*60){var n=Math.floor(ageInSeconds/60);return n+' minute'+s(n)+' ago';}
if(ageInSeconds<60*60*24){var n=Math.floor(ageInSeconds/60/60);return n+' hour'+s(n)+' ago';}
if(ageInSeconds<60*60*24*7){var n=Math.floor(ageInSeconds/60/60/24);return n+' day'+s(n)+' ago';}
if(ageInSeconds<60*60*24*31){var n=Math.floor(ageInSeconds/60/60/24/7);return n+' week'+s(n)+' ago';}
if(ageInSeconds<60*60*24*365){var n=Math.floor(ageInSeconds/60/60/24/31);return n+' month'+s(n)+' ago';}
var n=Math.floor(ageInSeconds/60/60/24/365);return n+' year'+s(n)+' ago';},fixDate:function(d)
{if(Y.util.Event.isIE)
{var a=d.split(' ');var year=a.pop();return a.slice(0,3).concat([year]).concat(a.slice(3)).join(' ');}
else
return d;},updateContent:function(id,msg,callback){var fadeOut=new YAHOO.util.Anim(id,{opacity:{to:0}},0.5);var fadeIn=function(type,args){$(id).innerHTML=msg;var fadeIn=new YAHOO.util.Anim(id,{opacity:{to:1}},0.5);if(callback){fadeIn.onComplete.subscribe(callback);}
fadeIn.animate();};fadeOut.onComplete.subscribe(fadeIn);fadeOut.animate();},linkifyTextLinks:function(arg)
{return arg.replace(/[a-z]+:\/\/[a-z0-9-_]+\.[a-z0-9-_:~%&\?\/.=]+[^:\.,\)\s*$]/ig,function(m){return'<a href="'+m+'" target="_blank">'+((m.length>25)?m.substr(0,24)+'...':m)+'</a>';});},twittify:function(tweet_text){var at=function(t){return t.replace(/(^|[^\w]+)\@([a-zA-Z0-9_]{1,15})/g,function(m,m1,m2){return m1+'<a href="http://twitter.com/'+m2+'" target="_blank" class="twitter-anywhere-user">'+'@'+m2+'</a>';});};var hash=function(t){return t.replace(/(^|[^\w'"]+)\#([a-zA-Z0-9_]+)/g,function(m,m1,m2){return m1+'#<a href="http://search.twitter.com/search?q=%23'+m2+'" target="_blank">'+m2+'</a>';});};return hash(at(this.linkifyTextLinks(tweet_text)));},arrayChunk:function(startArr,chunkSize){chunkSize=parseInt(chunkSize,10);chunkSize=isNaN(chunkSize)||!chunkSize?1:chunkSize;var base=[];var startArr_len=startArr.length;for(var i=0;i<startArr_len;i+=chunkSize){base.push(startArr.slice(i,i+chunkSize));}
return base;},ucwords:function(str){str=str||'';return str.toLowerCase().replace(/\w+/g,function(s){return s.charAt(0).toUpperCase()+s.substr(1);});}};
(function(){var TwitterSearch=function(config){this.search_tag=config.search_tag;this.language=config.language;var rpp=parseInt(config.rpp);this.rpp=isNaN(rpp)||!rpp?5:rpp;this.tweet_html='\
            <div class="single_tweet">\
                <div class="twitter_left_part">\
                    <img src="{profile_image_url}" width="48" height="48">\
                </div>\
                <div class="bg1 triangle"></div>\
                <table>\
                    <tr>\
                        <td class="bg2" colspan="3">\
                            <div class="bg1 top_right"><!-- --></div>\
                            <div class="bg1 top_left"><!-- --></div>\
                        </td>\
                    </tr>\
                    <tr>\
                        <td class="bg1 tweet_left_border">\
                            <div><!-- --></div>\
                        </td>\
                        <td class="tweet_content">\
                            <a class="twi_search_links twitter-anywhere-user" rel="nofollow" href="http://twitter.com/{from_user}">{from_user}</a>\
                            {text}\
                            <div class="twitt_status">\
                                <a href="http://twitter.com/{from_user}/statuses/{id}">{created_at}</a> from <span class="twitt_source">{source}</span>\
                            </div>\
                        </td>\
                        <td class="bg1 tweet_right_border">\
                            <div><!-- --></div>\
                        </td>\
                    </tr>\
                    <tr>\
                        <td class="bg2 tweet_bottom_border" colspan="3">\
                            <div class="bg1 bottom_left"><!-- --></div>\
                            <div class="bg1 bottom_right"><!-- --></div>\
                        </td>\
                    </tr>\
               </table>\
               <div class="clear"></div>\
           </div>\
        ';this.tweets_elem=undefined;this.queue=[];this.since_id=1;this.tweet_height=78;this.updatesTimeout=undefined;this.queueTimeout=undefined;this.sb=undefined;this.search_mode=config.search_mode||'mixed';this.module_mode=config.module_mode||null;if(this.module_mode=='user')
this.atUser=this.search_tag;var form=$('featured_twitter_form');E.on(form,'submit',this.searchTweets,undefined,this);};TwitterSearch.prototype={show:function(id){if(!id){return;}
this.tweets_elem=$(id);if(!this.tweets_elem){return;}
TwitterAnywhere.anywhere(this.tweets_elem);this.initScrollbar(id);var twitter_params={callback:'twitter.callback'};if(this.language&&this.language!='all'){twitter_params.lang=this.language;}
this.getTweets(this.search_tag,twitter_params);},initScrollbar:function(id){if(this.sb){return;}
var height=this.tweet_height*5;if(this.rpp<5)
{height=this.tweet_height*this.rpp;}
if(height<90){height=90;}
if(this.module_mode=='user')
height=this.tweet_height*3;this.tweets_elem.style.height=height+'px';this.sb=new HPScrollbar(id,'twitter_search_scrollbar');this.setScrollbarBottomEvent();},setScrollbarBottomEvent:function(){this.sb.onBottom(function(){if(!this.callOldTweets()){return;}
if(Dom.hasClass('ot_loader','hidden')){Dom.removeClass('ot_loader','hidden');}},this,35);},callOldTweets:function(){var next_page=this.next_page;if(next_page){var query=next_page+'&callback=twitter.oldTweetsCallback';this.getTweets(undefined,undefined,query);return true;}
return false;},oldTweetsCallback:function(data){this.next_page=this.getNextPageQuery(data);var loader=$('ot_loader');if(loader){this.tweets_elem.removeChild(loader);}else{var div=document.createElement('div');div.innerHTML=this.loader;loader=div;}
if(!data||!data.results||!data.results.length){loader.innerHTML='No more tweets';this.tweets_elem.appendChild(loader);return;}
var tweets=data.results;var tweets_len=tweets.length;var df=document.createDocumentFragment();for(i=tweets_len;i--;){var odiv=document.createElement("div");odiv.innerHTML=this.renderTweet(tweets[i]);df.appendChild(odiv);}
df.appendChild(loader);this.tweets_elem.appendChild(df);this.setScrollbarBottomEvent();this.sb.update();},getNextPageQuery:function(tw_object){if(tw_object.next_page){return tw_object.next_page+'&rpp='+(tw_object.page+1)*this.rpp;}else{return undefined;}},getTweets:function(search_tag,params,force_query){search_tag=search_tag||'';var query_fields=[];if(params){if(params.lang){query_fields.push('lang='+params.lang);}
if(params.callback){query_fields.push('callback='+params.callback);}
if(params.since_id){query_fields.push('since_id='+params.since_id);}
if(params.show_user){query_fields.push('show_user='+params.show_user);}}
var query;if(!force_query){query='?q='+escape(search_tag);if(this.module_mode=='user'&&HuffPoUtil.trim(search_tag)==this.atUser){var twitter_name=search_tag.replace('@','');query='?q=from:'+escape(twitter_name)+'+OR+'+escape(search_tag);}
if(query_fields.length){query+='&'+query_fields.join('&');}}else{query=force_query;}
if(this.search_mode)
{query+="&result_type="+this.search_mode;}
var url='http://search.twitter.com/search.json'+query;HuffPoUtil.loadAndRun(url);},callback:function(data){if(!data||!data.results||!data.results.length){this.nothingFound();return;}
var tweets=data.results;this.since_id=tweets[0].id;this.next_page=this.getNextPageQuery(data);var tweets_len=tweets.length;var html='';for(var i=0;i<tweets_len;i++){html+=this.renderTweet(tweets[i]);}
this.loader='<div id="ot_loader" class="hidden center"><img width="32" height="32" src="http://s.huffpost.com/images/loader.gif" alt="" /></div>';html+=this.loader;var self=this;HPUtil.updateContent(this.tweets_elem,html,function(){self.sb.update();self.sb.reset();});this.updatesTimeout=this.setTimeout(this.runUpdates,10000);this.processQueue();},nothingFound:function(){HPUtil.updateContent(this.tweets_elem,'There is no info on Twitter for this entry for that keyword');},renderTweet:function(tweet){var pattern=this.search_tag.replace(/ /g,'|');var source=tweet.source.replace(/&lt;/gi,'<').replace(/&gt;/gi,'>').replace(/&quot;/gi,'"').replace(/&amp;/gi,'&');var regex=new RegExp('('+pattern+')(?![^<]*[>\Z])','ig');var text=TwitterUtil.twittify(tweet.text);text=text.replace(regex,'<span class="hl_term">$1</span>');return this.tweet_html.replace('{profile_image_url}',tweet.profile_image_url).replace('{created_at}',TwitterUtil.elapsedTime(tweet.created_at,true)).replace('{source}',source).replace('{text}',text).replace(/{from_user}/g,tweet.from_user).replace('{id}',tweet.id);},runUpdates:function(){var twitter_params={since_id:this.since_id,callback:'twitter.queueCallback'};if(this.language&&this.language!='all'){twitter_params.lang=this.language;}
this.getTweets(this.search_tag,twitter_params);},queueCallback:function(data){if(!data||!data.results||!data.results.length){this.updatesTimeout=this.setTimeout(this.runUpdates,90000);return;}
var tweets=data.results;var tweets_len=tweets.length;for(var i=0;i<tweets_len;i++){this.queue.unshift(tweets[i]);}
this.since_id=tweets[tweets_len-1].id;this.updatesTimeout=this.setTimeout(this.runUpdates,90000);},processQueue:function(){if(!this.queue.length){this.queueTimeout=this.setTimeout(this.processQueue,60000);return;}
var tweet=this.queue.pop();if(!tweet){this.queueTimeout=this.setTimeout(this.processQueue,60000);return;}
var new_tweet_node=document.createElement('div');new_tweet_node.className='new_tweet';new_tweet_node.innerHTML=this.renderTweet(tweet);var first_node=Dom.getFirstChild(this.tweets_elem);this.tweets_elem.insertBefore(new_tweet_node,first_node);var marginTop=new_tweet_node.offsetHeight*(-1);new_tweet_node.style.marginTop=marginTop+'px';Dom.removeClass(new_tweet_node,'new_tweet');var attributes={marginTop:{from:marginTop,to:0}};var anim=new YAHOO.util.Anim(new_tweet_node,attributes,0.7,YAHOO.util.Easing.easeIn);anim.animate();this.queueTimeout=this.setTimeout(this.processQueue,60000);this.sb.update();},searchTweets:function(e){clearTimeout(this.updatesTimeout);clearTimeout(this.queueTimeout);var input=$('search_tag');this.since_id=1;this.search_tag=input.value;this.queue=[];this.killScrollbar();this.tweets_elem.innerHTML='<i>Loading...</i>';this.show(this.tweets_elem.id);this.showLinks();E.stopEvent(e);},showLinks:function(){if(!this.search_tag){return;}
if(this.showLinksRequest&&C.isCallInProgress(this.showLinksRequest)){C.abort(this.showLinksRequest);}
var show_top_links=function(o){var resp=JSON.parse(o.responseText);if(!resp){return;}
var links_length=resp.links.length;var links='';for(var i=0;i<links_length;i++){links+=resp.links[i];}
HPUtil.updateContent('twitter_top_links',links);};var callback={success:show_top_links};var tag=encodeURIComponent(this.search_tag);this.showLinksRequest=C.asyncRequest('GET','/get_json_tweet_links.php?tag='+tag,callback);},killScrollbar:function(){if(this.sb&&this.sb.sb_container){this.sb.sb_container.innerHTML='';delete this.sb;}},setTimeout:function(method,msec){var that=this;var args=Array.prototype.slice.apply(arguments,[2]);if(typeof method==='string'){method=that[method];}
return setTimeout(function(){method.apply(that,args);},msec);}};window.TwitterSearch=TwitterSearch;})();

/* From: wfe8-nyc : 21765 */