function initializeTimeline(){$("#timeline").Timeline()}(function(){$(document).ready(function(){$().Page();initializeTimeline();$("#pagination #more").isMoreButton()});$.fn.Page=function(){var A=$('meta[name="session-user-screen_name"]:first').get(0);var C=$('meta[name="page-user-screen_name"]:first').get(0);var B=A&&C&&A.content==C.content;if(!page){page={}}page=$.extend(page,{timeline:null,sessionUserScreenName:(A?A.content:null),pageUserScreenName:(C?C.content:null),loggedIn:$('meta[name="session-loggedin"][content="y"]').length>0,replyable:$("body.replyable").get(0),hideUnfavorited:B})};$.fn.Timeline=function(){page.timeline=$(this);return this.each(function(){var A=$(this);var B={};$.Timeline.settings=$.extend({},$.Timeline.defaults);settings=$.extend($.Timeline.settings,page);var C=A.find(".hentry");if(settings.loggedIn){$.each($.Timeline.actions.tweet,function(){this.apply(C,[settings])})}})};$.Timeline={defaults:{timeline:$("#timeline")},prepend:function(A){$.Timeline.settings.timeline.prepend(A)},append:function(A){$.Timeline.settings.timeline.append(A)},actions:{tweet:{isHoverable:function(A){if($("body.ie,body.ie6").get(0)){return this.livequery(function(){var B=$(this);B.hover(function(){console.log(B);B.addClass("hover")},function(){B.removeClass("hover")})})}},isFavoriteable:function(A){return this.find(".fav-action").livequery(function(){var B=$(this);B.click(function(){var C=B.parents(".hentry:first");var F=C.attr("id").replace(/status_/,"");var E=B.hasClass("fav");var D=E?"destroy":"create";twttr.googleAnalytics("/favorites/"+D+"/refresh/"+F);$.ajax({type:"POST",url:"/favorites/"+D+"/"+F,data:{authenticity_token:twttr.form_authenticity_token},beforeSend:function(){B.attr("title","").removeClass(E?"fav":"non-fav").addClass("fav-throb");twttr.loading()},success:function(){if($("body#favourings").hasClass("favourings")&&A.hideUnfavorited){C.fadeOut(500,function(){C.remove()})}else{B.attr("title",(E?"favorite":"un-favorite")+" this update").removeClass("fav-throb").addClass(E?"non-fav":"fav")}}});return false})})},isReplyable:function(A){if(A.replyable){return this.find(".reply").livequery(function(){var B=$(this);B.click(function(){var E=B.parents(".hentry:first");var H=E.attr("id").replace(/status_/,"");var C=E.attr("class").match(/u-([A-Za-z0-9_]+)/);var D=C[1];if(!D){alert(_("Whoops! Something went wrong. Please refresh the page and try again!"));return }if(E.hasClass("status")){var G=$("#status");twttr.googleAnalytics("/reply/"+D+"/"+H);G.val("@"+D+" "+G.val().replace(RegExp("@"+D+" ?","i"),"")).trigger("update");$("#status").focusEnd();$("#in_reply_to_status_id").val(H);$("#in_reply_to").val(D);window.scroll(0,0)}else{if(E.hasClass("direct_message")){var G=$("#text");twttr.googleAnalytics("/direct_messages/reply/"+D+"/"+H);var F=$("#direct_message_user_id");if(!F.find("option[text='"+D+"']").attr("selected",true).length){F.append('<option value="'+D+'" selected="selected">'+D+"</option>")}G.trigger("update");$("#text").focusEnd()}}window.scroll(0,0);return false})})}},isDeleteable:function(A){return this.find(".del").livequery(function(){var B=$(this);B.click(function(){var C=B.parents(".hentry:first");var F;var E=C.hasClass("latest-status");var D;if(C.hasClass("status")){D="/status/destroy";F=C.attr("id").replace(/status_/,"")}else{if(C.hasClass("direct_message")){F=C.attr("id").replace(/direct_message_/,"");D="/direct_messages/destroy"}}if(confirm("Sure you want to delete this update? There is NO undo!")){twttr.googleAnalytics(D+"/refresh/"+F);$.ajax({type:"POST",url:D+"/"+F,data:{authenticity_token:twttr.form_authenticity_token,latest_status:E},dataType:(D=="/status/destroy"?"json":null),beforeSend:function(){B.attr("title","").removeClass("del").addClass("del-throb")},success:function(G){var H=C.parents(".conversation");var I=H.get(0)?H:C;I.fadeOut(500,function(){I.remove();if(D=="/status/destroy"){if(E){twttr.processJson(G);updateLatest()}}})}})}return false})})}}}}})();(function(){$.fn.isMoreButton=function(){return this.livequery(function(){$(this).click(function(){var B=$(this);B.blur();var A=B.attr("href");if(!window.onPageChange){twttr.trackPageView()}$.ajax({type:"GET",url:A,dataType:"json",beforeSend:function(){$("#more").addClass("loading").html("")},success:function(C){$("#timeline").append($(C["#timeline"]).find(".hentry"));$("#pagination").html(C["#pagination"]);if(window.onPageChange){onPageChange()}},error:function(){alert(_("Whoops! Something went wrong. Please try refreshing the page."))}});return false})})}})();function updateLatest(){var A=$("#latest_status");if(A.length){A.isCurrentStatus(true)}$("#timeline li:first").addClass("latest-status")}$.fn.isLoading=function(){$(this).addClass("loading");twttr.loading()};$.fn.isLoaded=function(){$(this).removeClass("loading");twttr.loaded()};
