Phx.namespace("Phx.Application.Modules.AddDone",new function(){var a=this;this.init=function(){if($(".Snipplet-Friendslists-FriendshipInvitationSnipplet").length==0){return}var f=$("#userId").val();var g=$("#userName").val();var d=($("#showDialog").length)?parseInt($("#showDialog").val(),10):0;var b=$("#Friendslists_invitationMode").val();
var h=$("#Friendslists_showDialogCheckbox").val();var e=$("#showDialogAuto").val();if(g.trim()===""||f.trim()===""){return}var c=new Phx.Application.ManageFriendslists();if(d===0&&!e){a.toggleAd()}$("#showAddFriendToListsDialog").bind("click.AddDone",function(){a.toggleAd()});$(c).bind("closeDialog cancelDialog",function(){a.toggleAd()
})};this.toggleAd=function(){if($("#Mod-Friends-Confirm-Invite ul li").length==0){$("#Mod-Friends-Kdk").removeClass("hidden");$("#Mod-Friends-Confirm-Invite").addClass("AllInvitationsDone")}var b=$("#FriendsAd");if(b.length===0){return}if(b.css("visibility")==="visible"||b.css("visibility")==="inherit"){var c=b.height();
b.css("visibility","hidden");b.css("height",c);return}b.css("visibility","visible")}}());Phx.namespace("Phx.Application.Modules.AllFriends",new function(){var b=this;var a="manageLists_";this.getAddFriendToListsDialog=function(){var d=$(this).attr("id").substr(a.length);var e=$("a",$("dd.name",$(this).parents("tr"))).text();
if(e.trim()===""||d.trim()===""){return}var c=new Phx.Application.ManageFriendslists();c.getAddFriendToListsDialog(d,e,0,0);$(c).bind("closeDialog",function(){window.location.reload()})};this.init=function(){$("a[id*="+a+"]").unbind("click.AllFriends").bind("click.AllFriends",b.getAddFriendToListsDialog);
$("a.show-more").bind("click.AllFriends",function(){$(this).next("span").toggleClass("hidden");$(this).remove()});var c=$("#Friendslists-Form-Friends");$("#onlineOnly",c).bind("change",function(){c.submit()});var d=$("#Friendslists-Form-Network");$("#onlineOnly",d).bind("change",function(){d.submit()
})}}());Phx.namespace("Phx.Application.Modules.Common",new function(){this.init=function(){var a=$("#Friendslists-Form-Common");if(a.length==0){return}$("#onlineOnly",a).bind("change",function(){a.submit()})}}());Phx.namespace("Phx.Application.Modules.ConfirmInvite",new function(){this.init=function(){a();
if($(".confirmInvite").length==0){return}var e=($("#userId").length)?$("#userId").val():"";var f=($("#userName").length)?$("#userName").val():"";var d=($("#showDialog").length)?parseInt($("#showDialog").val(),10):0;var b=$("#Friendslists_invitationMode").val();var g=$("#Friendslists_showDialogCheckbox").val();
if(f.trim()===""||e.trim()===""){return}var c=new Phx.Application.ManageFriendslists();if(d!==0&&$("#lastAcceptedInvitation").length){c.getAddFriendToListsDialog(e,f,b,g)}$("#showAddFriendToListsDialog").bind("click.ConfirmInvite",function(){c.getAddFriendToListsDialog(e,f,b,g)})};var a=function(){if($("#Mod-Friends-NetworkNewsConfirmInvite.networknews-box").length==0){return
}$(".friendinvite-confirm").unbind("click").bind("click",function(){$().trigger("OmnitureTracking",{name:"acceptFriendship"});$(this).parent("li").parent("ul").siblings(".action").attr("value","confirm");$(this).parent("li").parent("ul").parent("form.networknews-invite-confirm").submit()});$(".friendinvite-decline").unbind("click").bind("click",function(){$(this).parent("li").parent("ul").siblings(".action").attr("value","decline");
$(this).parent("li").parent("ul").parent("form.networknews-invite-confirm").submit()});$(".friendinvite-sendMessage").unbind("click").bind("click",function(){$(this).parent("li").parent("ul").siblings(".action").attr("value","sendMessage");$(this).parent("li").parent("ul").parent("form.networknews-invite-confirm").submit()
})}}());Phx.Application.Modules.FriendsAutocomplete=new function(){var friendsData=null;var $resultbox=null;var $searchfield=null;var selectedValue=null;var $suggestbox=null;var groupId=null;var _currentSelectedResultValue=-1;var _lastResultLength=0;var $groupsObject=null;this.init=function(){var $friends=$("#friends");
eval("this.friendsData    = "+$friends.val()+";");this.$resultbox=$("#resultbox");this.$searchfield=$("#username");this.$suggestbox=$("#suggestbox");this.groupId=$("#groupId").val();this.$groupsObject=Phx.Application.Modules.Groups;this.$searchfield.attr("autocomplete","off");this.$searchfield.unbind("keyup.autocomplete").bind("keyup.autocomplete",Phx.Util.createDelegate(this.keyListener,this)).unbind("keydown.autocomplete").bind("keydown.autocomplete",Phx.Util.createDelegate(this.keydownListener,this));
this.bindInviteForm()};this.bindInviteForm=function(){var groupId=$("#invitingGroupId").val();var moduleName=$("#invitingModulName").val();var _this=this;var $okButton=$("#btnOk");$okButton.attr("href","javascript:;");$okButton.unbind("click.inviteForm").bind("click.inviteForm",Phx.Util.createDelegate(function(){if(_this.selectedValue){this.$groupsObject.doRequest(_this.selectedValue,groupId,moduleName)
}},this));var $cancelButton=$("#btnCancel");$cancelButton.attr("href","javascript:;");$cancelButton.unbind("click.closeForm").bind("click.closeForm",Phx.Util.createDelegate(function(){this._hideResultbox()},this))};this.keyListener=function(event){var kc=Phx.Util.KeyCodes;var keyCode=event.keyCode||window.event.keyCode;
var writedLetters=$("#username").val();if(!writedLetters){return}if(!this.friendsData){return}var matches=this.getMatches(writedLetters);if(!matches){this._hideResultbox();return}this.$resultbox.html(matches);var $resultValues=this.$resultbox.children("div");this.bindMouseoverEvent($resultValues);this.bindMouseclickEvent($resultValues);
this.bindMousedoubleclickEvent($resultValues);this.bindMouseoutEvent($resultValues);this.$suggestbox.show();if(keyCode!=kc.ARROW_UP&&keyCode!=kc.ARROW_DOWN){this._currentSelectedResultValue=-1}if(this.selectNextResultValue(keyCode)||this.selectPreviousResultValue(keyCode)){return}};this.keydownListener=function(event){var kc=Phx.Util.KeyCodes;
var keyCode=event.keyCode||window.event.keyCode;if(keyCode==kc.RETURN&&this._currentSelectedResultValue!=-1){Phx.Event.stop(event);var selected=this.$resultbox.get(0).childNodes[0];var groupId=$("#invitingGroupId").val();var moduleName=$("#invitingModulName").val();if(selected){this.$groupsObject.doRequest(this.selectedValue,groupId,moduleName);
this.$searchfield.blur();this._hideResultbox()}return}};this.getMatches=function(writedLetters){var matches="";var counter=0;$.each(this.friendsData,function(key,value){var cutPosition=value.indexOf(" ");var firstname=value.substr(0,cutPosition).toLowerCase();var lastname=value.substr((++cutPosition),value.length).toLowerCase();
writedLetters=writedLetters.toLowerCase();if(0==firstname.indexOf(writedLetters)||0==lastname.indexOf(writedLetters)){matches+='<div class="unselected" id="'+key+'">'+value+"</div>";++counter}});this._lastResultLength=counter;return matches};this.bindMouseoverEvent=function($resultValues){var _this=this;
$resultValues.mouseover(function(){$resultValues.each(function(){var id=$(this).attr("id");if(id!=_this.selectedValue){this.className="unselected"}});this.className="selected"})};this.bindMouseclickEvent=function($resultValues){var _this=this;$resultValues.click(function(){$resultValues.each(function(){this.className="unselected"
});this.className="selected";_this.selectedValue=$(this).attr("id")})};this.bindMousedoubleclickEvent=function($resultValues){var _this=this;$resultValues.dblclick(function(){_this.$searchfield.val($(this).html());_this._hideResultbox()})};this.bindMouseoutEvent=function($resultValues){var _this=this;
$resultValues.mouseout(function(){$resultValues.each(function(){var id=$(this).attr("id");if(id!=_this.selectedValue){this.className="unselected"}})})};this._hideResultbox=function(){this.$suggestbox.hide()};this.selectNextResultValue=function(keyCode){if(keyCode!=Phx.Util.KeyCodes.ARROW_DOWN){return
}if(this._currentSelectedResultValue==(this._lastResultLength-1)){this._currentSelectedResultValue=0}else{++this._currentSelectedResultValue}var _this=this;this.$resultbox.children().each(function(i){if(i==_this._currentSelectedResultValue){this.className="selected";_this.selectedValue=$(this).attr("id")
}else{this.className="unselected"}});return true};this.selectPreviousResultValue=function(keyCode){if(keyCode!=Phx.Util.KeyCodes.ARROW_UP){return}if(this._currentSelectedResultValue==0||this._currentSelectedResultValue==-1){this._currentSelectedResultValue=(this._lastResultLength-1)}else{--this._currentSelectedResultValue
}var _this=this;this.$resultbox.children().each(function(i){if(i==_this._currentSelectedResultValue){this.className="selected";_this.selectedValue=$(this).attr("id")}else{this.className="unselected"}});return true}};Phx.namespace("Phx.Application.ManageFriendslists",function(){});Phx.Application.ManageFriendslists.prototype={__displayAddFriendToListsDialog:function(i,c){var f=this;
var h=Phx.UI.Dialog.HTML(i18n.getText("friendslists_addFriendToLists_title",i),{message:c.module.data.html});h.show();$("#Mod-Friendslists-Form-AddFriendToLists-Save").focus();$("#Mod-Friendslists-Form-AddFriendToLists-Cancel").unbind("click.friendslistsFriends").bind("click.friendslistsFriends",function(j){if($.browser.safari==true){Phx.Event.stop(j)
}h.close();$(f).trigger("cancelDialog")});var g=$("#Friendslists_newList");if(0<g.length){g.attr("autocomplete","off");var e=g.val();var d=$("#checkbox-friendToListsNew");g.bind("focus.friendslistsFriends",function(){d.attr("checked",true);if($(this).attr("class").indexOf("preset")!=-1){$(this).removeClass("preset");
$(this).val("")}});var b=function(){if(""===g.val()){d.attr("checked",false);g.val(e);g.addClass("preset")}};g.bind("blur.friendslistsFriends",function(){window.setTimeout(b,500)});d.bind("click.friendslistsFriends",function(){if(true===$(this).attr("checked")){g.focus()}else{g.val(e);g.addClass("preset")
}})}var a=$("#Mod-Friendslists-Form-AddFriendToLists");a.submit(Phx.Util.createDelegate(this.__submitAddFriendToListsDialog,this,h));$("#Mod-Friendslists-Form-AddFriendToLists-Save").unbind("click.friendslistsFriends").bind("click.friendslistsFriends",Phx.Util.createDelegate(this.__submitAddFriendToListsDialog,this,h))
},__submitAddFriendToListsDialog:function(a){var b=this;$("#Mod-Friendslists-Form-AddFriendToLists").submit(Phx.Application.Modules.Forms.bindAjaxForms).bind("formSuccess",function(c,d){if(d.module.data.error){$("#errorContent").html(d.module.data.error);return}a.close();$(b).trigger("closeDialog")})
},getAddFriendToListsDialog:function(c,d,b,e){if(!c||!d){return}var a="Friends_addFriendToListDialog";if($("meta[name=Chat_addFriendToListDialog]").length){a="Chat_addFriendToListDialog"}Phx.Application.RequestRegistry.append({1:a,2:Phx.Util.createDelegate(this.__displayAddFriendToListsDialog,this,d.escapeHtml()),3:this,4:"&friendId="+c+"&invitationMode="+b+"&showDialogCheckbox="+e})
}};Phx.namespace("Phx.Application.Modules.Friendslists",new function(){var h=this;this.block=false;var e="friendlist_";var g=function(j,i,k,l){Phx.Application.RequestRegistry.append({1:j,2:function(m){if(m.module.data.error){Phx.UI.Dialog.Alert(i18n.getText("error_head"),m.module.data.error).show();return
}if(!l){i(m)}else{i(m,l)}},3:h,4:k})};var a=function(j,o){var n=$("#"+e+o.friendlistId).children();var i=$("tr[id*="+e+"]",$("#Mod-Friendslists-Overview-Table")).length;n.fadeOut(1000,function(){var q=$(this);var p=q.parent("tr");p.remove();q.remove();if(i==1){$("#Mod-Friendslists-Overview-Table").remove()
}});var l=$("#mod-friendlist-remainingfriendlists");var m='<a id="Mod-Friendslists-Button-CreateList" class="obj-linkalike">';var k="</a>";if(j.module.data.html==1){$("#info").html(i18n.getText("friendslists_one_remaining_list",m,k))}else{$("#info").html(i18n.getText("friendslists_two_remaining_lists",j.module.data.html,m,k))
}$("#Mod-Friendslists-Button-CreateList").bind("click.friendslists",h.createFriendlistDialog)};var c=function(j,l){var k=Phx.UI.Dialog.HTML(i18n.getText("friendslists_rename_title"),{message:j.module.data.html});k.show();$("#Mod-Friendslists-RenameSniplet-Button-Rename").focus();$("#friendlistId").val(l.friendlistId);
var i=$("#Friendslists_friendlistName");i.attr("autocomplete","off");i.val(h.xssSecure(l.friendlistName)).select();$("#Mod-Friendslists-RenameSniplet-Button-Escape").bind("click.friendslists",function(n){Phx.Event.stop(n);k.close()});var m=$("#Mod-Friendslists-RenameSniplet-Form");h.breakSubmitOnPressingEnter(m);
m.submit(Phx.Util.createDelegate(h.renameFriendlist,h,k));$("#Mod-Friendslists-RenameSniplet-Button-Rename").bind("click.friendslists",Phx.Util.createDelegate(h.renameFriendlist,h,k))};var d=function(j){var k=Phx.UI.Dialog.HTML(i18n.getText("friendslists_create_title"),{message:j.module.data.html});k.show();
$("#Mod-Friendslists-CreateSnipplet-Create").focus();var i=$("#Friendslists_friendlistName");i.attr("autocomplete","off");$("#Mod-Friendslists-CreateSnipplet-Close").bind("click.friendslists",function(m){Phx.Event.stop(m);k.close()});i.bind("focus.friendslists",h.removePresetIfSet);var l=$("#Mod-Friendslists-Form-CreateList");
h.breakSubmitOnPressingEnter(l);l.submit(Phx.Util.createDelegate(h.createFriendlist,h,k));$("#Mod-Friendslists-CreateSnipplet-Create").bind("click.friendslists",Phx.Util.createDelegate(h.createFriendlist,h,k))};var f=function(i,k){var j=Phx.UI.Dialog.HTML(i18n.getText("friendslists_manage_title",h.xssSecure(k.friendlistName)),{message:i.module.data.html});
j.show();$("#Mod-Friendslists-ManageFriends-Save").focus();$("#Mod-Friendslists-ManageFriends-Cancel").bind("click.friendslists",function(n){Phx.Event.stop(n);j.close();h.block=false});var m=$("#Mod-Friendslists-ManageSniplet-Form");h.breakSubmitOnPressingEnter(m);m.submit(Phx.Util.createDelegate(h.saveManageFriendsSettings,h,j));
$("#searchfield").attr("autocomplete","off");$("#searchfield").bind("focus.friendslists",h.removePresetIfSet);var l=new Phx.Application.ManageFriends();$("#Mod-Friendslists-ManageFriends-Save").bind("click.friendslists",Phx.Util.createDelegate(h.saveManageFriendsSettings,h,j))};this.breakSubmitOnPressingEnter=function(i){i.bind("keydown.friendslists keyup.friendslists",function(k){var l=k.keyCode||window.event.keyCode;
var j=Phx.Util.KeyCodes;if(l==j.RETURN){Phx.Event.stop(k)}})};var b=function(i,j){j.close();h.block=false;$("#mod-friendlist-overview").fadeOut(500,function(){$(this).replace(i.module.data.html);$(this).fadeIn(500);h.init()})};this.saveManageFriendsSettings=function(l){var m=$("#Mod-Friendslists-ManageSniplet-Form");
var k=$("input[name=friendlistId]",m).val();var n=[];for(var j=0;j<$friendsInList.length;j++){n.push("&friendIds[]="+$friendsInList[j].id)}g("Friendslists_saveManageFriendsSettings",b,"&friendlistId="+k+n.join(""),l)};this.removePresetIfSet=function(){if($(this).attr("class").indexOf("preset")!=-1){$(this).removeClass("preset");
$(this).val("")}};this.renameFriendlistDialog=function(){var j=$(this).parents("tr");var k=j.attr("id").substr(e.length);var i=h.xssSecure($("h3 a",j).text());var l={friendlistId:k,friendlistName:i};g("Friendslists_renameDialog",c,"",l)};this.renameFriendlist=function(i){$("#Mod-Friendslists-RenameSniplet-Form").submit(Phx.Application.Modules.Forms.bindAjaxForms).bind("formSuccess",function(j,k){i.close();
$("#mod-friendlist-overview").fadeOut(500,function(){$(this).replace(k.module.data.html);$(this).fadeIn(500);h.init()})})};this.manageFriends=function(l){if(h.block===true){return}h.block=true;var j=$(this).parents("tr");var k=j.attr("id").substr(e.length);var i=h.xssSecure($("h3 a",j).text());var m={friendlistName:i};
g("Friendslists_manageDialog",f,"&friendslistId="+k,m)};this.createFriendlistDialog=function(){g("Friendslists_createDialog",d,"")};this.createFriendlist=function(i){$("#Mod-Friendslists-Form-CreateList").submit(Phx.Application.Modules.Forms.bindAjaxForms).bind("formSuccess",function(j,k){i.close();$("#mod-friendlist-overview").fadeOut(500,function(){$(this).replace(k.module.data.html);
$(this).fadeIn(500);h.init()})})};this.deleteFriendlistDialog=function(){var j=$(this).parents("tr");var l=j.attr("id").substr(e.length);var k=h.xssSecure($("h3",j).text());var i=$("meta[name=platformId]").attr("content").toLowerCase();var m={friendlistId:l};var n=Phx.UI.Dialog.Confirm(i18n.getText("friendslists_delete_title"),{message:i18n.getText("friendslists_delete_confirm_"+i,k),events:{onButtonClicked:Phx.Util.createDelegate(h.deleteFriendlist,h,m)}},i18n.getText("friendslists_deleteList"),i18n.getText("friendslists_cancel_"+i));
n.show();$("a[id*=PhxDialog0_]").get(0).focus()};this.deleteFriendlist=function(j,i){if("false"===i||false===i){return}g("Friendslists_delete",a,"&friendlistId="+j.friendlistId,j)};this.xssSecure=function(j){var i=new Array("[","<",">","{","}","\\","]","&");$.each(i,Phx.Util.createDelegate(function(k,l){j=j.split(l).join("")
},this));return j};this.init=function(){var q=$(".obj-linklist");for(var o=0,j=q.length;o<j;o++){var p=q[o];var m=$(".mod-friendlist-action-managefriends",p);m.bind("click.friendslists",h.manageFriends);var l=$(".mod-friendlist-action-deletefriendlist",p);l.bind("click.friendslists",h.deleteFriendlistDialog);
var k=$(".mod-friendlist-action-renamefriendlist",p);k.bind("click.friendslists",h.renameFriendlistDialog)}var n=$("#Mod-Friendslists-Button-CreateList");n.bind("click.friendslists",h.createFriendlistDialog)}}());Phx.namespace("Phx.Application.ManageFriends",function(){this.init();this.bindKeyListenerSearchfield()
});Phx.Application.ManageFriends.prototype={MAX_COUNT_OF_FRIENDS_IN_LIST:100,LI_BOX_HEIGHT:55,startCounterLeftbox:0,startCounterRightbox:0,lastScrollindexLeftbox:0,lastScrollindexRightbox:0,displayedFriendIdsLeftbox:[],displayedFriendIdsRightbox:[],selectedFriendsLeftbox:[],selectedFriendsRightbox:[],searchEntry:"",init:function(){this.initLeftbox();
this.initRightbox();this.bindClickAddFriendToFriendlist();this.bindClickRemoveFriendFromFriendlist();this.enableDisableArrowLinks()},initRightbox:function(){var d=$("#scrollDivFriendlist");var b=$("#hiddenDivFriendlist");this.resetSelectedValues();var a=this.startCounterRightbox;this.buildContent("right",a,$friendsInList);
var c=($friendsInList.length*this.LI_BOX_HEIGHT);b.height(c);var e=this;d.scroll(Phx.Util.createDelegate(e.doScrolling,e,"right",$friendsInList));$("#friendsInFriendlist, #friendsInFriendlist *").bind("mousewheel",function(g,h){var f=$("#scrollDivFriendlist")[0].scrollTop;h=($.browser.opera)?(h*(-1)):h;
if(h>0){$("#scrollDivFriendlist")[0].scrollTop=((f-16)>=0)?(f-16):0}if(h<0){$("#scrollDivFriendlist")[0].scrollTop=((f+16)>=0)?(f+16):0}Phx.Event.stop(g)})},initLeftbox:function(){var d=$("#scrollDiv");var b=$("#hiddenDiv");this.resetSelectedValues();var a=this.startCounterLeftbox;this.buildContent("left",a,$remaningFriends);
var c=($remaningFriends.length*this.LI_BOX_HEIGHT);b.height(c);var e=this;d.scroll(Phx.Util.createDelegate(e.doScrolling,e,"left",$remaningFriends));$("#friendsInRemaninglist, #friendsInRemaninglist *").bind("mousewheel",function(g,h){var f=$("#scrollDiv")[0].scrollTop;h=($.browser.opera)?(h*(-1)):h;
if(h>0){$("#scrollDiv")[0].scrollTop=((f-16)>=0)?(f-16):0}if(h<0){$("#scrollDiv")[0].scrollTop=((f+16)>=0)?(f+16):0}Phx.Event.stop(g)})},buildContent:function(k,l,p){var f=null;var b=[];var c=[];var m="";if((l+5)>p.length){l=((p.length-5)<=0)?0:(p.length-5)}endCount=(l+5);if(endCount>=p.length){endCount=(p.length-1)
}if(k==="left"){this.displayedFriendIdsLeftbox=[];this.startCounterLeftbox=l;f=$("#friendsInRemaninglist");b=this.displayedFriendIdsLeftbox;c=this.selectedFriendsLeftbox;m=this.searchEntry}else{if(k==="right"){this.displayedFriendIdsRightbox=[];this.startCounterRightbox=l;f=$("#friendsInFriendlist");
b=this.displayedFriendIdsRightbox;c=this.selectedFriendsRightbox;m=""}else{return}}var n=[];for(var e=l;e<=endCount;e++){var o=p[e];if(!p[e]){break}var a=o.id;b.push(a);var h="";var g=c.length;for(var d=0;d<g;d++){if(c[d]==a){h="selected";break}}n.push('<li id="'+a+'" class="'+h+'"><input type="hidden" name="friendIds[]" value="'+a+'" /><span class="pictureframe"><img src="'+o.imagePath+'" alt=""/></span><span class="name ellipsis">'+this.highlightMatches(m,o.name)+'</span><span class="uniName ellipsis">'+o.uniName+"</span></li>")
}f.html(n.join(" "));this.bindClickHandler(k)},doScrolling:function(e,h){var d=null;var f=0;var g=0;var a=[];var b=[];if(e==="left"){d=$("#scrollDiv")[0];f=this.startCounterLeftbox;g=this.lastScrollindexLeftbox;a=this.displayedFriendIdsLeftbox;b=this.selectedFriendsLeftbox}else{if(e==="right"){d=$("#scrollDivFriendlist")[0];
f=this.startCounterRightbox;g=this.lastScrollindexRightbox;a=this.displayedFriendIdsRightbox;b=this.selectedFriendsRightbox}else{return}}var i=Math.ceil(d.scrollTop/this.LI_BOX_HEIGHT);if(f==i&&g<d.scrollTop){i+=1;d.scrollTop=i*this.LI_BOX_HEIGHT}if(f==i&&g>d.scrollTop){i-=1;d.scrollTop=i*this.LI_BOX_HEIGHT
}if(f!==i){var c=h.length;if(e==="left"){this.startCounterLeftbox=i;this.lastScrollindexLeftbox=d.scrollTop}else{this.startCounterRightbox=i;this.lastScrollindexRightbox=d.scrollTop}this.buildContent(e,i,h)}},bindClickHandler:function(e){var b=[];if(e==="left"){b=this.displayedFriendIdsLeftbox}else{if(e==="right"){b=this.displayedFriendIdsRightbox
}else{return}}var d=b.length;var g=this;var a=false;if($.browser.msie){a=true}for(var c=0;c<d;c++){var f=$("li#"+b[c]);if(a===true){f.bind("mouseout",function(){$(this).removeClass("hover")});f.bind("mouseover",function(){$(this).addClass("hover")})}f.unbind("click").bind("click",function(){var i=$(this);
var o=i[0].id;i.toggleClass("selected");var l=(i.attr("class").indexOf("selected")!==-1)?true:false;var m=i.parents("#friendsInRemaninglist").length;var n=i.parents("#friendsInFriendlist").length;var h=[];if(m){h=g.selectedFriendsLeftbox}else{if(n){h=g.selectedFriendsRightbox}else{return}}if(l===true){if(m){g.selectedFriendsLeftbox.push(o)
}else{if(n){g.selectedFriendsRightbox.push(o)}else{return}}}else{for(var k=0;k<h.length;k++){if(h[k]!==o){continue}if(m){g.selectedFriendsLeftbox.splice(k,1);break}if(n){g.selectedFriendsRightbox.splice(k,1);break}}}g.checkClickPermission(i);g.enableDisableArrowLinks()});f.unbind("dblclick").bind("dblclick",function(){var h=$(this);
if(h.parents("#friendsInFriendlist").length){g.removeFriendFromFriendlist(h)}else{g.addFriendToFriendlist(h)}})}},enableDisableArrowLinks:function(){if(0===$remaningFriends.length||this.MAX_COUNT_OF_FRIENDS_IN_LIST===$friendsInList.length||!this.selectedFriendsLeftbox.length){this.disableSliderRight()
}else{this.enableSliderRight()}if(0===$friendsInList.length||!this.selectedFriendsRightbox.length){this.disableSliderLeft()}else{this.enableSliderLeft()}},addFriendToFriendlist:function(h){var g=[];if(h.length){g.push(h[0].id)}else{g=this.selectedFriendsLeftbox}if(0===g.length||this.MAX_COUNT_OF_FRIENDS_IN_LIST<=$friendsInList.length){return
}var b=0;var a=g.length;for(var e=0;e<a;e++){if(this.MAX_COUNT_OF_FRIENDS_IN_LIST===$friendsInList.length){break}var c=g[e];var k=$("li#"+c);var f=$remaningFriends.length;for(var d=0;d<f;d++){if($remaningFriends[d].id===c){$friendsInList.push($remaningFriends[d]);$remaningFriends.splice(d,1);break}}k.remove();
++b}this.refreshFriendlistCounter(-b);this.initLeftbox();this.initRightbox();this.enableDisableArrowLinks();$.each($(".name",$("#friendsInFriendlist")),function(){var i=$(this).text();$(this).text(i)});this.keyListenerSearchfield()},removeFriendFromFriendlist:function(h){var e=[];if(h.length){e.push(h[0].id)
}else{e=this.selectedFriendsRightbox}if(0===e.length){return}var b=0;var a=e.length;for(var f=0;f<a;f++){var c=e[f];var k=$("li#"+c);var g=$friendsInList.length;for(var d=0;d<g;d++){if($friendsInList[d].id===c){$remaningFriends.push($friendsInList[d]);$friendsInList.splice(d,1);break}}k.remove();++b}this.refreshFriendlistCounter(b);
$("#remaningFriendsInfo").removeClass("error-message");this.initLeftbox();this.initRightbox();this.enableDisableArrowLinks();this.keyListenerSearchfield()},checkClickPermission:function(b){var a=$("#remaningFriendsInfo");if(b.parents("#friendsInRemaninglist").length&&b.attr("class").indexOf("selected")!=-1&&this.MAX_COUNT_OF_FRIENDS_IN_LIST===$friendsInList.length){b.removeClass("selected");
a.addClass("error-message")}else{a.removeClass("error-message")}},enableSliderRight:function(){$("#addFriendToFriendlist").removeClass("inactive")},enableSliderLeft:function(){$("#removeFriendFromFriendlist").removeClass("inactive")},disableSliderRight:function(){$("#addFriendToFriendlist").addClass("inactive")
},disableSliderLeft:function(){$("#removeFriendFromFriendlist").addClass("inactive")},bindKeyListenerSearchfield:function(){$("#searchfield").bind("keyup.manageFriends",Phx.Util.createDelegate(this.keyListenerSearchfield,this))},bindClickAddFriendToFriendlist:function(){$("#addFriendToFriendlist").bind("click.manageFriends",Phx.Util.createDelegate(this.addFriendToFriendlist,this))
},bindClickRemoveFriendFromFriendlist:function(){$("#removeFriendFromFriendlist").bind("click.manageFriends",Phx.Util.createDelegate(this.removeFriendFromFriendlist,this))},resetSelectedValues:function(){$("li.selected",$("#friendsInFriendlist")).removeClass("selected");$("li.selected",$("#friendsInRemaninglist")).removeClass("selected");
this.selectedFriendsLeftbox=[];this.selectedFriendsRightbox=[]},keyListenerSearchfield:function(){var a=$("#searchfield");var f=a.val().toLowerCase();if(a.attr("class").indexOf("preset")!==-1||(this.searchEntry===""&&f==="")){return}this.resetSelectedValues();if(f===""){this.searchEntry="";$("#scrollDiv")[0].scrollTop=0;
this.startCounterLeftbox=0;this.initLeftbox();this.enableDisableArrowLinks();return}var h=[];for(var g=0;g<$remaningFriends.length;g++){var l=$remaningFriends[g];var c=l.id;var k="";for(var e=0;e<this.selectedFriendsLeftbox.length;e++){if(this.selectedFriendsLeftbox[e]!==c){continue}k="selected";break
}if(l.name.toLowerCase().indexOf(f)===-1){continue}this.searchEntry=f;h.push(l)}var d=(h.length*this.LI_BOX_HEIGHT);$("#hiddenDiv").height(d);this.buildContent("left",this.startCounterLeftbox,h);var b=$("#scrollDiv");b.unbind();b.scroll(Phx.Util.createDelegate(this.doScrolling,this,"left",h));this.enableDisableArrowLinks()
},highlightMatches:function(c,d){var e=c.length;var a=d.toLowerCase().indexOf(c.toLowerCase(),0);var b=d.substring(0,a)+'<span class="match">'+d.substring(a,a+e)+"</span>"+d.substring(a+e);return b},refreshFriendlistCounter:function(c){var b=$("#Mod-Friendslists-Data-RemainingFriends");var a=(b.length)?parseInt(b.html(),10):0;
var d=a+c;if(0===d){$("#remaningFriendsInfo").html(i18n.getText("friendslists_remaningFriendsInfo_zero"))}else{if(1===d){$("#remaningFriendsInfo").html(i18n.getText("friendslists_remaningFriendsInfo_single",d))}else{$("#remaningFriendsInfo").html(i18n.getText("friendslists_remaningFriendsInfo_multi",d))
}}}};Phx.namespace("Phx.Application.Modules.FriendslistsDetails",new function(){var e=this;var d="delete_";var b=null;var c=function(g,f,h,i){Phx.Application.RequestRegistry.append({1:g,2:function(j){if(j.module.data.error){Phx.UI.Dialog.Alert(i18n.getText("error_head"),j.module.data.error).show();return
}if(!i){f(j)}else{f(j,i)}},3:e,4:h})};var a=function(f,g){var h=$("#"+d+g.userId).parents("tr").children();window.location.reload()};this.deleteFriendFromList=function(g,f){if("false"===f||false===f){return}c("Friendslists_deleteFriend",a,"&friendlistId="+g.friendlistId+"&friendId="+g.userId,g)};this.deleteFriendFromListDialog=function(){var h=e.xssSecure($("#friendlistName").val());
var g=$("#friendlistId").val();var j=$(this).attr("id").substr(d.length);var f=$("meta[name=platformId]").attr("content").toLowerCase();var i={friendlistId:g,userId:j};var k=Phx.UI.Dialog.Confirm(i18n.getText("friendslists_details_delete_title"),{message:i18n.getText("friendslists_details_delete_confirm_"+f,$("#name_"+j).html(),h),events:{onButtonClicked:Phx.Util.createDelegate(e.deleteFriendFromList,e,i)}},i18n.getText("friendslists_deleteFriend"),i18n.getText("friendslists_cancel_"+f));
k.show();$("a[id*=PhxDialog0_]").get(0).focus()};this.initAutosuggest=function(){if($(this).attr("class").indexOf("preset")!=-1){$(this).removeClass("preset");$(this).val("")}var j=$("#isMyList");if(!j.length||j.val()==="0"){return}if(b){return}var g=$("#friendlistSearchFrom");var i=$("#Friends_name",g);
var f=$("#resultboxSearchAutosuggest",g);var h={metaForm:"Search_getFriendlist"};b=new Phx.Application.Autosuggest(i,f,h);b.getResultValueHook=Phx.Util.createDelegate(e.onClickResultValueHandler,e);b.returnKeyListenerHook=Phx.Util.createDelegate(e.handleNoMatches,e)};this.onClickResultValueHandler=function(f,g){window.location.href="/Profile/"+f
};this.handleNoMatches=function(){var h=this;if(b._currentSelectedValue===-1){window.setTimeout(Phx.Util.createDelegate(h.submitForm,h),500);return}var f=$("div.selected",b.$resultbox).attr("id");var g=$("dt",$("div.selected"),b.$resultbox).html();h.onClickResultValueHandler(f,g);b.closeResultbox()};
this.submitForm=function(){b.doSubmit()};this.xssSecure=function(g){var f=new Array("[","<",">","{","}","\\","]","&");$.each(f,Phx.Util.createDelegate(function(h,i){g=g.split(i).join("")},this));return g};this.init=function(){$("a[id*=delete_]").bind("click.friendlistDetails",e.deleteFriendFromListDialog);
var g=$("#friendlistSearchFrom");var h=$("#Friends_name",g);var f=h.next("input[type=submit]");f.bind("click.details",function(j){if(h.val()===""||h.attr("class").indexOf("preset")!=-1){Phx.Event.stop(j)}});h.bind("keyup.details",function(){$(this).removeClass("preset")});h.attr("autocomplete","off");
h.bind("focus.details",e.initAutosuggest);$("a.show-more").bind("click.friendslistsFriends",function(){$(this).next("span").toggleClass("hidden");$(this).remove()});var i=$("#Friendslists-Form-Details");$("#onlineOnly",i).bind("change",function(){i.submit()})}}());Phx.namespace("Phx.Application.Modules.FriendsConnection",new function(){var c=this;
var d=$("#friends-big-path-list");var a=$("#friends-big-path-notfound");var b=$("#friends-big-path-space");this.init=function(){if(d.length){c.callService()}};this.bigPath=function(e){if(e.length==0){c.notFound()}else{c.renderPath(e)}};this.renderPath=function(e){var f="&path="+e.join(":");Phx.Application.RequestRegistry.append({1:"Friends_bigPathRender",2:function(g){b.addClass("hidden");
d.html(g.module.data.html)},3:"",4:f})};this.callService=function(){var e="/graphservice/users/"+friends_bigpath_from+"/path_to/"+friends_bigpath_to;d.ajaxError(function(h,i,g,f){if(g.url==e){c.notFound()}});$.get(e,"",function(g,h,f){c.bigPath(g)})};this.notFound=function(){b.addClass("hidden");a.removeClass("hidden")
}}());
