GB_showCenter=function(b,d,a,e,g){var c={caption:b,overlay_click_close:true,height:a||440,width:e||440,fullscreen:false,callback_fn:g,use_fx:false};var f=new GB_Window(c);return f.show(d)};GB_showFullScreen=function(a,c,e){var b={caption:a,fullscreen:true,callback_fn:e,overlay_click_close:true,use_fx:false};var d=new GB_Window(b);return d.show(c)};TopBar={init:function(){if(!$("top_login")){return}var c=DIV({id:"top_bar"});var d;ACN(c,TABLE(TBODY(TR(d=TD({c:"content"})))));var a=SiteState.getSessionUser();if(a){var h=this.createItem("front",_("Front page"),this.showFrontPage,"front","/t/");ACN(d,h);if(window.location.pathname.indexOf("/t/")==0){addClass(h,"on always_on")}var g="/"+SiteState.getSessionUser().nick_name;var f=this.createItem("home",_("My Profile"),this.showProfile,"profile_item",g);ACN(d,f);if(window.location.pathname.indexOf(g)==0){addClass(f,"on always_on")}var b=A({href:"/Settings/show",id:"edit_link"},_("edit"));AEV(b,"click",$p(TopBar.showProfileSettings,"profile"));ACN(d,b);ACN(d,this.span_fri=this.createItem("friends",_("My Friends"),this.showFriends));ACN(d,this.createItem("notifications",SPAN(_("Alerts")+" (",SPAN({id:"noti_count"},"0"),")"),this.showNotifications))}else{var e=TopBar.createItem("front",_("Front page"),function(){window.location="/t/"});ACN(d,e)}TopBar.updateTitle();setTop(c,$("top_login").offsetTop+4);ACN(getBody(),c);AEV(window,"resize",TopBar.updateTitle);if(a){TopBar.updateNotificationCount(a.notifications_count)}},showProfileSettings:function(b){if(!b){b="profile"}var a="/Settings/show?page="+b;if(window.SiteState&&SiteState.canEdit()){return GB_showCenter(_("Profile settings"),a,400,650)}else{window.location="/?window="+a}return false},noti_count:null,updateNotificationCountAJAX:function(){if(!SiteState.getSessionUser()){return false}var a=getRequest("/Notifications/getCount");a.addCallback(TopBar.updateNotificationCount);a.sendReq({})},showFriends:function(a){if(!isString(a)){a=""}return(function(){GB_showCenter(_("My Friends"),"/Friends/"+a,500,650,function(){TopBar._updateTL()});if(top){top.Misc.promoteTab("/Friends/")}else{Misc.promoteTab("/Friends/")}return false})()},showPrivacy:function(){return GB_showCenter(_("My account"),"/Settings/privacy",500,650)},showMyAccount:function(a){return GB_showCenter(_("My account"),a,500,650)},showMobile:function(){return GB_showCenter(_("My account"),"/Settings/showMobile",500,650)},_updateFriends:function(){if(TopBar.update_friends){TopBar.update_friends=false;TimeLine.showLoading();var a=loadJSON("/Friends/get");a.addCallback(function(b){FRIENDS=b;buildFriendCollection(null,true);TimeLine.hideLoading();TopBar._updateTL();Profile.renderFriends();if(TimeLine.mode=="all"){TimeLine.user_ids=keys(FRIENDS);TimeLine.user_ids.push(SiteState.getPageUser().id)}});a.sendReq({})}},_updateTL:function(){if(TopBar.update_tl){TimeLine.reset();TimeLine.showLoading();TimeLine.getPlurks()}TopBar.update_tl=false},updateNotificationCount:function(a){var b=""+a;if(a>=0){a=""+a;if(!$("alert_beacon")){b=SPAN({c:"count",id:"alert_beacon"},a)}else{b=setHTML($("alert_beacon"),a)}}if(a>0){addClass($("noti_count"),"unread")}else{removeClass($("noti_count"),"unread")}RCN($("noti_count"),b)},showNotifications:function(){return GB_showCenter(_("Alerts"),"/Notifications",400,670,function(){TopBar.updateNotificationCountAJAX(false);if(SiteState.canEdit()){TopBar._updateTL();TopBar._updateFriends()}})},showProfile:function(){if(SiteState.canEdit()){Plurks.removeCurrentOpen();if(Poll.mode=="new"){Poll._viewAll()}else{if(PlurkSearch.current_pane=="search"){PlurkSearch.showPane($("plurks_pane_li"),"plurk")}else{TimeLineCache.cache.all=null;DisplayOptions.filterTimeline("all",$("all_plurks"))}}return false}else{window.location="/"+SiteState.getSessionUser().nick_name}},showFrontPage:function(){window.location="/t/"},showRegister:function(){if(window.GettingStarted){GettingStarted.hide()}GB_showCenter(_("Sign up for Plurk"),"/Users/showRegister?overlay=1",500,670);return false},updateTitle:function(){if(!SiteState.getPageUser()){return}if(TopBar.cur_page_title==SiteState.getPageUser().page_title){return}var a=$("page_title");if(!a){a=DIV({id:"page_title"});setTop(a,$("top_login").offsetTop);ACN(getBody(),a)}var b=SiteState.getPageUser().page_title;TopBar.cur_page_title=b;if(b){b=b.replace(/</g,"&lt;").replace(/>/g,"&gt;")}setHTML(a,b);setLeft(a,getWindowSize().w/2-(a.offsetWidth/2));if(window.Users){Users.updateTitle()}},createItem:function(d,g,e,b,a){var f=$static_path("/static/top_bar/icon_"+d+".png");if(window.Themes&&Themes.useDarkIcons()){f=$static_path("/static/top_bar/icon_"+d+"_dark.png")}var c=A({c:"item",href:a||"#"},PNGIMG({src:f,width:11,height:11,id:"icon_"+d}),g);if(b){addClass(c,b)}AEV(c,"mouseover",function(){addClass(c,"on")});AEV(c,"mouseout",function(){if(!hasClass(c,"always_on")){removeClass(c,"on")}});if(!a){AEV(c,"click",e)}return c},showConfirmEmail:function(){return GB_showCenter(_("Confirm your email"),"/Users/showConfirmEmail",400,650)}};SiteState={user_data:null,init:function(){AmiTooltip.init()},getPageUser:function(){if(!window.GLOBAL){return{}}return GLOBAL.page_user},getSessionUser:function(){if(!window.GLOBAL||!GLOBAL.session_user){return null}return GLOBAL.session_user},getToken:function(){var a=SiteState.getSessionUser();if(a){return a.token}return""},goToHomePage:function(){var a=SiteState.getSessionUser();if(a==null){window.location.href="http://www.plurk.com"}else{window.location.href="/"+a.nick_name}},canEdit:function(){if(SiteState.getPageUser()&&SiteState.getPageUser().public_view){return false}var a=SiteState.getPageUser();var b=SiteState.getSessionUser();if(!b||!a){return false}if(a.uid==b.uid){var c=window.location.toString();if(c.indexOf("/"+a.nick_name)!=-1){return true}}return false},isPermanentPage:function(){var a=""+window.location;return a.indexOf("/p/")!=-1},isIMActivated:function(){if(!window.FRIENDS){return null}return IM_ACTIVATE},getUserByNick:function(b){var c={};if(!window.FRIENDS){return null}if(window.COMPLETION){update(c,COMPLETION)}update(c,USERS);update(c,FRIENDS);var a=map(keys(c),function(e){var d=c[e];if(d.nick_name==b){d.id=d.uid=e;return d}});return a},getUserById:function(d){var b=SiteState.getPageUser();var c=SiteState.getSessionUser();if(b&&d==b.uid){return b}else{if(c&&c.id==d){return c}else{var a=FRIENDS[d];if(!a&&window.DisplayOptions&&DisplayOptions._backup_friends){return DisplayOptions._backup_friends[d]}if(!a){a=FANS[d]}if(!a){a=USERS[d]}return a}}},getPlurkUser:function(a){if(a.user){return a.user}return SiteState.getUserById(a.owner_id||a.user_id)},show_login_status:true,updateLoginLink:function(){var c=$("login_link");var a=SiteState.getSessionUser();if(c&&a&&SiteState.show_login_status){c.href="/Users/logout?token="+SiteState.getToken();var b=format(_("Sign out [%s]",true),a.nick_name);c.innerHTML=b;removeElement($("sign_up"));setHTML($("account"),_("My Account"));if(a.num_of_friends<=5){addClass($("interesting_plurkers"),"int_plurkers_post_it")}}if($("top_login")){setStyle($("top_login"),{visibility:"visible"})}},removeFriend:function(a){delete FRIENDS[a]},checkIfLoggedIn:function(){var a=document.cookie;if(a&&a.indexOf("plurkcookie")!=-1&&a.indexOf("user_id=")!=-1){return true}else{return false}},dont_reload:false,_setPacksHash:function(a){if(!a){return}var c=SiteState;if(c.dont_reload||!c.canEdit()){return false}if(a!=c.getSessionUser().packs_hash){var b=confirm(_("A new version of Plurk is avaiable. This release could include important bug fixes or new features.\nPress OK to reload your browser OR cancel to continue using older version of Plurk."));if(b){window.location.reload()}else{c.dont_reload=true}return}c.getSessionUser()["packs_hash"]=a}};Misc={setTimezone:function(a,b){var d=window.GLOBAL.tz;if(!a.tz_set){var c=d.hh;if(d.dst&&b!=null){c--}if(b==1){c++}a.setHours(a.getHours()+c);a.setMinutes(a.getMinutes()+d.mm);a.tz_set=true}},showPaste:function(a){var b=document.getElementById("pane_plurk");var c="/Shares/showPaste";if(a=="input_small"){c+="?mini=1"}GB_showCenter(_("Plurk Paste"),c,500,650);return false},promoteTab:function(e,c){if(e){if(e=="/Friends/"){var b=$bytc("div","GB_window");var a=ACN(b[0],DIV({id:"promote-multicast"},P(_("Invite your friends to Plurk via email, link and many more."),IMG({src:"http://statics.plurk.com/ffdca9715cfcd8ea7adc140c1f9d37df.png",style:"position:absolute;margin:0 0 0 1px"}))));AEV(a,"click",function(h){$("settingFrame").src="/Friends/inviteFriends"})}else{if(e=="http://paste.plurk.com/"){var d=document.getElementById("pane_plurk");var f="/Shares/showPaste?code="+encodeURIComponent(d.input_big.value);GB_showCenter(_("Plurk Paste"),f,500,650);return false}else{GB_showCenter(_("My account"),e,500,650);var b=$bytc("div","GB_window");var a=ACN(b[0],DIV({id:"promote-multicast"},P(_("Share your plurks on Facebook, Twitter and many more."),IMG({src:"http://statics.plurk.com/27c27fec8ea28b9e9fe3fc445c827552.gif",style:"margin:0 0 0 3px"}))));AEV(a,"click",function(h){$("settingFrame").src="/MultiCast"});return false}}}else{var g=$("promote-multicast").style;g.left=c+"px";g.display="block"}}};OverlayUpdater={updateImage:function(a,b){if(!SETTINGS.seed){SETTINGS.seed=0}SETTINGS.seed+=1;SETTINGS.has_profile_image=a;TimeLine.reset();TimeLine.getPlurks()}};
