var profileIcons=new Class({initialize:function(a){if($type(a)!==false){this.maCallbacks=$H({});a.getElements("li").each(function(b){b.addEvent("click",this.handleClick.bind(this));b.getElements("a").each(function(e){e.addEvent("click",this.handleClick.bind(this))},this)},this)}},register:function(a,b){this.maCallbacks.include(a,b)},handleClick:function(a){a.stop();a=$(a.target);if(a.get("tag")!="li")a=a.getParent("li");if(!a.hasClass("blurred")){var b=a.get("id");this.maCallbacks.has(b)&&this.maCallbacks[b].bind(a).call()}}}),
ShoutBox=new Class({Implements:Options,options:{userID:null},initialize:function(a,b){this.moContainer=$(a);this.setOptions(b);this.initLinks();this.build()},initLinks:function(){if($type(this.moContainer)!==false){$$("a.deleteShout").each(function(a){a.removeEvents();a.addEvent("click",this.deleteShout)},this);$$("a.approveShout").each(function(a){a.removeEvents();a.addEvent("click",this.approveShout)},this)}},build:function(){var a=this.moContainer.getElement("input#b-add-shout");a&&a.addEvent("click",
this.addShout.bind(this));this.moContainer.getElements(".shoutimage").each(function(b){b.addEvent("click",function(){top.location="/"+this.get("text")},b);b.setStyle("cursor","pointer")})},deleteShout:function(a){a.stop();var b;try{b=parseInt($(a.target).get("id").replace(/shout\-delete\-(\d+)/,"$1"),10)}catch(e){return}a=this.getParents("div[id^=shout-]");if(a.length!==0){var c=$("shout-delete-text").get("text");if(!confirm(c))return false;var d=a[0];d.set("tween",{duration:"fast"});(new Request({url:"/ajax/delete_shout/",
method:"post",data:$H({shoutid:b}).toQueryString(),onComplete:function(){d.slide("out")}})).send()}},approveShout:function(a){a.stop();var b;try{b=parseInt($(a.target).get("id").replace(/shout\-approve\-(\d+)/,"$1"),10)}catch(e){return}var c=this.getParents("div[id^=shout-]");if(c.length!==0){var d=c[0];(new Request({url:"/ajax/approve_shout",method:"post",data:$H({shoutid:b}).toQueryString(),onComplete:function(){d.removeClass("unapproved");$(a.target).getParent().destroy()}.bind(this)})).send()}},
addShout:function(){var a,b=this.moContainer.getElement("textarea").get("value").trim();if(b.length!==0){this.moContainer.getElement("textarea").set("value","");a=this.moContainer.getElement("div#shoutList");(new Request({url:"/ajax/shout/",data:$H({message:b,userid:this.options.userID}).toQueryString(),onComplete:function(e){(new Element("div")).set("html",e).inject(a,"top");(new Fx.Scroll(window)).toElement("shoutboxContainer");this.initLinks()}.bind(this)})).send()}}}),i_profile_id,s_profile_name,
o_photo_slider,toggleExtraStats=function(){$("addBuddyLayer")&&$("addBuddyLayer").addClass("hidden");if(this.hasClass("profileMoreInfoOff")){this.removeClass("profileMoreInfoOff").addClass("profileMoreInfoOn");$("profileStats").slide("in")}else{this.removeClass("profileMoreInfoOn").addClass("profileMoreInfoOff");$("profileStats").slide("out")}},enableBirthdayAlert=function(){(new Request({url:"/ajax/add_birthdayalert/",data:$H({userid:i_profile_id}).toQueryString(),onComplete:function(){location=
"/my/friends/alerts/"}})).send()},sendMessage=function(){if($type(o_messenger)===false)location="/accessdenied/";else o_messenger.sendMessage(s_profile_name)},addBuddy=function(){if(typeof o_messenger!="object")location="/accessdenied/";else if($("addBuddyLayer")){$("addBuddyLayer").setStyles({left:this.getPosition().x+this.getScrollSize().x,top:this.getPosition().y-7});$("addBuddyLayerSubmit").addEvent("click",function(){$("addBuddyLayerSubmit").addClass("hidden");$("addBuddyLayerLoading").removeClass("hidden");
var a=$H({});$$("div#addBuddyLayer input").each(function(b){if(b.checked===true)a[b.name]=true});a.buddyid=i_profile_id;(new Request({url:"/ajax/add_request",method:"post",data:a.toQueryString(),onComplete:function(){$("addBuddyLayerLoading").addClass("hidden");$("addBuddyLayerContent").addClass("hidden");$("addBuddyLayerDone").removeClass("hidden");(function(){$("addBuddyLayer").addClass("hidden");this.addClass("blurred")}).bind(this).delay(1E3)}.bind(this)})).send()}.bind(this)).setStyle("cursor",
"pointer");$("addBuddyLayerCancel").addEvent("click",function(){$("addBuddyLayer").addClass("hidden")});$("addBuddyLayer").removeClass("hidden")}},addFavorite=function(){if(typeof o_messenger!="object")location="/accessdenied/";else{this.addClass("loading");(new Request({url:"/ajax/add_favorite/",method:"post",data:$H({userid:i_profile_id}).toQueryString(),onComplete:function(a){if(a==="x")location="/my/friends/favorites/full/";else this.removeClass("loading").addClass("blurred")}.bind(this)})).send()}},
removeTraces=function(){if(typeof o_messenger!="object")location="/accessdenied/";else if(this.hasClass("goldmember"))location="/goldmember/";else{this.addClass("loading");(new Request({url:"/ajax/remove_traces/",data:$H({userid:i_profile_id}).toQueryString(),onComplete:function(){this.removeClass("loading").addClass("blurred")}.bind(this)})).send()}},addAlert=function(){if(typeof o_messenger!="object")location="/accessdenied/";else(new Request({url:"/ajax/add_onlinealert/",data:$H({userid:i_profile_id}).toQueryString(),
onComplete:function(){location="/my/friends/alerts/"}})).send()},reportProfile=function(){var a=290;if(Browser&&navigator.userAgent.match(/chrome/i))a+=Browser.Platform.mac===true?60:8;window.open("/report_profile.html?userid="+i_profile_id,"report_profile_"+i_profile_id,"width=548,height="+a+",location=false,status=false,menubar=false,directories=false,toolbar=false,resizable=false,scrollbars=false")};
window.addEvent("domready",function(){i_profile_id=parseInt($("profile-userid").get("text"),10);s_profile_name=$("profile-username").get("text").trim();if($("profileStats")){$("profileStats").slide("hide");$("profileStats").set("slide",{duration:"normal",transition:Fx.Transitions.Expo.easeOut});$("profileMoreInfo").addEvent("click",toggleExtraStats)}$A(["photo","video","friends"]).each(function(c){if($(c+"Container")){var d=new SlideShow(c+"Container",{url:"/json/profile/"+i_profile_id+"/"+c+".json",
hideTypeAndCaption:c!="friends"});if(c=="photo")o_photo_slider=d}});$("profilePhotoBox")&&$("profilePhotoBox").addEvent("click",function(c){var d=[];if($type(o_photo_slider))d=o_photo_slider.getContent();try{var f=$(c.target).getStyle("background-image").match(/http:\/\/(.+)\.jpg/),g;if(f!==null&&f.length>1){g=f[0].replace(/fullsize\.jpg$/,"original.jpg");d=$A([[g,s_profile_name]]).combine(d)}}catch(h){}(new QuickBox(d)).open(0)}.bind(this));$A(["general","body","sex"]).each(function(c){$("details-"+
c)&&$("details-"+c).getElements("dd").length<2&&$("details-"+c).destroy()});$("profileBirthdayAlert")&&$("profileBirthdayAlert").addEvent("click",enableBirthdayAlert);try{var a=new profileIcons($$("div.profileIcons ul")[0]);a.register("sendMessage",sendMessage);a.register("addBuddy",addBuddy);a.register("addFavorite",addFavorite);a.register("removeTraces",removeTraces);a.register("addAlert",addAlert);a.register("reportProfile",reportProfile)}catch(b){}$("shoutboxContainer")&&new ShoutBox("shoutboxContainer",
{userID:i_profile_id});$("profileComment")&&$("commentMessage").addEvent("blur",function(c){c=$(c.target).get("value").trim();var d=parseInt($("profile-userid").get("text").trim(),10);(new Request({url:"/ajax/save_comment/",method:"post",data:$H({userid:d,comment:c}).toQueryString(),onComplete:function(){$("commentMeta").set("text",$("commentSaved-text").get("text"));$("commentMeta").addClass("commentSaved")}})).send()});if($$("div.weblogBody").length>0)try{new Weblog(i_profile_id)}catch(e){}});

