var testing=0;var latestConanID=0;var latestTweetID=0;var oldestTweetID=0;var updateRequest;var feedRefresh;var oldFeedURL="";window.addEvent("domready",function(){initFeed(30)});function initFeed(A){if(!$("feed")||feedURL==undefined){return }if($("loadmore")){$("loadmore").addEvent("click",function(B){if(B){B.stop()}updateFeed("feed",0,oldestTweetID,true)})}if($("feed_coco")){$("feed_coco").addEvent("click",function(B){if(B){B.stop()}feedButtonAction(this,"get/feedCoco?",A)})}if($("feed_featured")){$("feed_featured").addEvent("click",function(B){if(B){B.stop()}feedButtonAction(this,"get/feed?",A)})}if($("feed_world")){$("feed_world").addEvent("click",function(B){if(B){B.stop()}feedButtonAction(this,"get/feedWorld?",A)})}updateFeed("feed");feedRefresh=refreshFeed.periodical(A*1000,this)}function refreshFeed(){updateFeed("feed",latestTweetID)}function updateFeed(A,B,D,C){if(updateRequest instanceof Request){if(C===true){updateRequest.cancel()}else{return }}if(D!=undefined){$("feedloader").slide("in")}newBubbleTweet="";url=baseurl+feedURL;if(B){url+="since="+B}if(D){url+="&to="+D}updateRequest=new Request.JSON({url:url,onComplete:function(E){if(E==null||E.length<1){$("feedloader").slide("out");if(D!=undefined){$("loadmore").slide("out")}updateRequest=null;return }if(E[0].id>latestTweetID){latestTweetID=E[0].id}if(oldestTweetID==0||E[E.length-1].id<oldestTweetID){oldestTweetID=E[E.length-1].id}if(D==undefined){E.reverse()}if(D==undefined&&(feedURL=="get/feedWorld?")){removeRecentTags(A)}E.each(function(F){if(F.user.screen_name=="ConanOBrien"&&F.id.toInt()>latestConanID){newBubbleTweet=F.text;latestConanID=E[0].id.toInt()}if(D!=undefined){addNewTweet(F,A,true)}else{addNewTweet(F,A)}});if(newBubbleTweet!=""){updateBubble(newBubbleTweet)}if($("feedloader").getStyle("height").toInt()>0){$("feedloader").slide("out")}if($("loadmore").getStyle("display")=="none"){$("loadmore").setStyle("display","block")}else{$("loadmore").slide("in")}updateRequest=null;if(feedURL!=oldFeedURL){oldFeedURL=feedURL;if(!pageLoading){pageTracker._trackPageview(feedURL)}else{pageLoading=false}}},onFailure:function(){updateRequest=null}}).send()}function addNewTweet(D,E,C){html="";html+='<a href="http://www.twitter.com/'+D.user.screen_name+'" target="_blank">';html+='	<img src="'+D.user.profile_image_url+'" class="twitter_image">';html+="</a>";html+='<div class="extras">';html+='	<a class="retweet" target="_blank" href="'+reTeweetLink(D.user.screen_name,D.text_raw)+'">';html+='		<img src="'+baseurl+'images/retweet.png" alt="" />';html+="	</a>";html+="</div>";html+='<span class="author">';html+='	<a href="http://www.twitter.com/'+D.user.screen_name+'" target="_blank">';html+=D.user.screen_name+"</a>";html+="</span>: "+D.text;html+='<hr class="fix" />';var A=new Element("div",{"class":"tweet recent",html:html});if(D.user.screen_name=="ConanOBrien"){A.addClass("coco")}if(C!=undefined){A.inject($(E),"bottom")}else{A.inject(E,"top")}new Fx.Slide(A).hide().slideIn();A.addEvent("mouseenter",function(F){A.getElement(".extras").setStyle("display","block")});A.addEvent("mouseleave",function(F){if(F){F.stop()}A.getElement(".extras").setStyle("display","none")});var B=A.getElements("a.retweet");B.each(function(F){F.addEvent("click",function(G){analyticsEvent("feature","retweet")})});lightboxify(A)}function removeRecentTags(B){var A=$$("div#"+B+" div.recent");A.each(function(D,C){var E=new Fx.Tween(D,{duration:"long"});E.start("opacity","0.8");D.removeClass("recent")})}function changeFeedButton(A){var B=$$("#feed_controls a");B.each(function(C){C.removeClass("selected")});A.addClass("selected");$("loadmore").slide("out")}function feedButtonAction(C,B,A){changeFeedButton(C);var D=$$($("feed").getElements("div"));D.destroy();feedURL=B;latestTweetID=0;oldestTweetID=0;updateFeed("feed",0,oldestTweetID,true);$clear(feedRefresh);feedRefresh=refreshFeed.periodical(A*1000,this)}function reTeweetLink(B,A){url="http://twitter.com/home?status=";url+=escape("RT+@"+B+"+"+A);return url};