function observePagination(){$$("div.pagination a").each(function(a){a.observe("click",function(b){new Ajax.Request(a.href,{onCreate:function(){$("pagination_loader").show()},onComplete:function(){$("pagination_loader").hide();observePagination()}});Event.stop(b)})})}document.observe("dom:loaded",function(){observePagination()});var ProfileReply={trigger:function(f,a,c){var d=f.up();var b=d.up().select("form").first();if(!b){b=new Element("form",{"class":"reply_form",action:a,method:"post"}).update("");b.observe("submit",function(j){AlertReply.submitForm(b);Event.stop(j)},true);var h=new Element("input",{type:"text",name:"comment[text]","class":"comment_text",style:"width:450px"});if(c){var i=new Element("input",{type:"hidden",name:"comment[comment_id]",value:c});b.appendChild(i)}b.appendChild(h);var g=new Element("input",{type:"submit",value:"Reply",onclick:"showSubmit(this)"});b.appendChild(g);var e=new Element("div",{id:"alertreply_"+c,"class":"comment_reply_box",style:"display:none"});e.appendChild(b);f.up().insert({bottom:e});h.focus()}else{e=$("alertreply_"+c)}new Effect.toggle(e,"blind",{duration:0.3})},submitForm:function(a){trackAjaxPageView("/javascript/profile/reply");var b=a.select("input[type=text]").first();if(b.value===""){b.style.border="1px solid red";activateSubmit(a.select("input[type=submit]").first())}else{new Ajax.Request(a.action,{asynchronous:true,evalScripts:true,onComplete:function(c){a.update('<p>Thanks! Your comment was posted on <a href="'+a.up(1).select("a").first().href+'#comments">this profile</a>.</p>')},parameters:Form.serialize(a)})}return false}};var userFav=Class.create({initialize:function(){$$(".favorites_avatars li a").each(function(f){f.observe("click",function(h,g){window.userFavcycle=false;this.changeItem(g);Event.stop(h);return false}.bindAsEventListener(this,f))}.bind(this));var a=$$(".favorites_avatars li a")[0];if(a){var e=new Element("img",{src:"/images/indicator_grey.gif",id:"favoritetaglineimg",style:"display:none;position: absolute; right: 5px; top: 5px;"});var c='On <a class="url" href=""></a>: &ldquo;<em></em>&rdquo;';var b=new Element("div",{id:"favoritetagline"}).update(c);if(profile_owner){var d=new Element("a",{href:"#remove",title:"Remove this favorite"}).update(new Element("img",{alt:"delete",src:"/images/icon_delete.gif"}));d.observe("click",function(){userFav.remove();return false});b.insert(new Element("span",{"class":"remove"}).update(d));b.insert(e)}$("user_favorites").insert({bottom:b});this.changeItem(a);window.userFavcycle=true;setTimeout(this.binderFunction.bind(this,1),4000)}},favCycle:function(a){var c=a,b=$$(".favorites_avatars li a");this.changeItem(b[a]);c=(c<b.length-1)?c+1:0;setTimeout(this.binderFunction.bind(this,c),4000)},binderFunction:function(a){var b=$$(".favorites_avatars li a");if(window.userFavcycle&&b.length>1){this.favCycle(a)}},changeItem:function(d){$$(".favorites_avatars li a").each(function(f){$(f).removeClassName("active")});d.addClassName("active");var b=d.immediateDescendants(),a=d.readAttribute("href"),c=b[1].innerHTML,e=b[0].readAttribute("alt");c=(c=="Tell us why")?"No reason given":c;tagline=$("favoritetagline").immediateDescendants();tagline[0].innerHTML=e;tagline[0].writeAttribute("href",a);tagline[1].innerHTML=c},remove:function(c){var a=$$(".favorites_avatars li a.active").first().href+"/favorite";var b=this.changeItem;new Ajax.Request(a,{parameters:{_method:"delete"},evalJS:false,onLoading:function(){$("favoritetaglineimg").show()},onSuccess:function(){trackAjaxPageView("/javascript/favorites/remove");$("favoritetaglineimg").hide();$$(".favorites_avatars li a.active")[0].ancestors()[0].remove();var d=$$(".favorites_avatars li a")[0];if(d){b(d)}else{$("user_favorites").hide()}}})}});var userCur=Class.create({initialize:function(){var a=this.showLabel;var b=this.hideLabel;$$("#current_activity_bar div").each(function(d){var c=a.bind(d);var e=b.bind(d);$(d).observe("mouseover",c);$(d).observe("mouseout",e)})},showLabel:function(c){var a=this.immediateDescendants()[0];var b=this.ancestors()[1];b.setStyle({overflow:"visible"});a.addClassName("name-active")},hideLabel:function(b){var a=this.immediateDescendants()[0];a.removeClassName("name-active")}});var userReach=Class.create({graphs_path:"",period:"week",initialize:function(){["day","week","month"].each(function(a){$(a+"_url").observe("click",this.submit.bindAsEventListener(this,a))},this);$("graph_type").observe("change",this.submit_through_select.bindAsEventListener(this));this.set_graphs_path(window.location);this.set_active_link("week");this.set_active_type("category")},submit_through_select:function(a){this.submit(a,this.period)},submit:function(b,c){var a=$F("graph_type");this.set_active_link(c);this.set_active_type(a);new Ajax.Updater("stackgraph_container",this.graphs_path,{asynchronous:true,evalScripts:true,onSuccess:function(d){trackAjaxPageView("/javascript/profile/show-graph-"+a+"-"+c);$("stackgraph").setOpacity(1)},onLoading:function(d){$("stackgraph").setOpacity(0.4)},parameters:{type:a,period:c}});b.stop()},set_graphs_path:function(a){var b=a.toString();b=b.sub(/\/$/,"");b=b.sub(/\#$/,"");this.graphs_path=b+"/graphs"},set_active_link:function(a){["day","week","month"].each(function(b){if(a==b){this.period=a;$(b+"_url").addClassName("active")}else{$(b+"_url").removeClassName("active")}})},set_active_type:function(a){if(select_option=$(a)){select_option.selected=true}}});document.observe("dom:loaded",function(){userFav=new userFav();userCur=new userCur();userReach=new userReach()});