var magicTxtHelp_activated=true;function fillText_f(opt){var text_find_=$("#quick_f").val();switch(opt){case 1:if(text_find_==""){$("#quick_f").val(fSearchText);$("#quick_f").addClass("grey-text")}break;case 2:magicTxtHelp_activated=false;if(text_find_==fSearchText){$("#quick_f").val("");$("#quick_f").removeClass("grey-text")}break}return true}function friendsformatItem(row,i,prevQ){if(typeof(prevQ)=="undefined"){prevQ=""}var new_html=row;var words=prevQ.split(" ");var torep={a:"á",e:"é",i:"í",o:"ó",u:"ú",n:"ñ",A:"Á",E:"É",I:"Í",O:"Ó",U:"Ú",N:"Ñ"};var toign=["#",",","\\.","'","_","-"];var regexes=new Array();var out="";for(var j in words){var w=words[j].replace(/\s+/,"");if(!w){continue}var w2=w.replace(/\(/g,"\\(").replace(/\)/g,"\\)");for(var k in torep){w2=w2.replace(new RegExp("("+torep[k]+")","g"),k);w2=w2.replace(new RegExp("("+k+")","g"),"[$1"+torep[k]+"]")}for(var k in toign){w2=w2.replace(new RegExp("("+toign[k]+")","g"),"$1?")}regexes.push("("+w2+")")}if(regexes.length){new_html=new_html.replace(new RegExp("("+regexes.join("|")+")","ig"),'<span class="added">$1</span>')}if(typeof(sonico_friends_photos)=="undefined"){out='<a href="javascript:void();" class="f-wrap dark-link">'+new_html+"</a>"}else{out='<a href="javascript:void();" class="f-wrap dark-link"><span class="thumb">'+sonico_friends_photos[i]+"</span>"+new_html+"</a>"}return out}function launch_autocomplete_f(){if(isLogged){if(friendType=="work"){$("#quick_f").autocomplete(sonico_laboral_contacts,{onItemSelect:function(li){window.location=sonico_url+"friends.php?t=work&fid="+li.selectValue},maxItemsToShow:10,width:205,resultsID:"quicksearch-autocomplete",delay:10,formatItem:friendsformatItem})}else{$("#quick_f").autocomplete(sonico_friends,{onItemSelect:function(li){window.location=sonico_url+"friends.php?fid="+li.selectValue},maxItemsToShow:10,width:205,resultsID:"quicksearch-autocomplete",delay:10,formatItem:friendsformatItem})}}}function delay(){$("#status-last").html("");$("#sd").val(status_ini).attr("style","color:#999999");$("#sd").val(status_ini)}function removeFriendsList(lname,id){if(!confirm(sonico.translate._("¿Estas seguro que desea eliminar la lista?"))){return}$("#list"+id+"view").hide();var ajaxOpts={friendAction:"rmListName",listName:lname};$.getJSON("/ajax_people.php",ajaxOpts,function(res){if(res.error){$("#list"+id+"view").show();alert(res.msgError)}})}function addFriendToList(userListName,friendId){var ajaxOpts={friendAction:"addFriendToList",listName:userListName,userId:friendId};$.getJSON("/ajax_people.php",ajaxOpts,function(res){if(!res.error){$("#belongList-"+friendId).html(res.response.listHtml)}else{alert(res.msgError)}})}function rmFriendFromList(userListName,friendId){var ajaxOpts={friendAction:"rmFriendFromList",listName:userListName,userId:friendId};$.getJSON("/ajax_people.php",ajaxOpts,function(res){if(!res.error){$("#belongList-"+friendId).html(res.response.listHtml)}else{alert(res.msgError)}})}function deleteFriend(friendId,blockUser){var bckUp=$("#userId"+friendId).html();$("#userId"+friendId).fadeOut();var ajaxOpts={friendAction:"deleteFriend",userId:friendId,block:blockUser};$.getJSON("/ajax_people.php",ajaxOpts,function(res){if(res.error){alert(res.msgError);$("#userId"+friendId).html(bckUp).show()}})}function deleteLaboralFriend(friendId,blockUser){var bckUp=$("#userId"+friendId).html();$("#userId"+friendId).fadeOut();var ajaxOpts={friendAction:"deleteLaboralFriend",userId:friendId,block:blockUser};$.getJSON("/ajax_people.php",ajaxOpts,function(res){if(res.error){alert(res.msgError);$("#userId"+friendId).html(bckUp).show()}})}function blockFan(friendId){var bckUp=$("#userId"+friendId).html();$("#userId"+friendId).fadeOut();var ajaxOpts={friendAction:"blockFan",userId:friendId};$.getJSON("/ajax_people.php",ajaxOpts,function(res){if(res.error){alert(res.msgError);$("#userId"+friendId).html(bckUp).show()}})}function deleteMeAsFan(friendId,obj){$("#ownerIsFan"+friendId).find("b").removeClass("i-yesblue").addClass("i-none");$(obj).parent().hide();closeAllDropDown();if($("#userId"+friendId+" div.actionsWrap .actionsWrap-list").find("b.i-yesblue").length<1){$("#userId"+friendId).fadeOut()}var ajaxOpts={friendAction:"deleteMeAsFan",userId:friendId};$.getJSON("/ajax_people.php",ajaxOpts,function(res){if(res.error){alert(res.msgError);$("#ownerIsFan"+friendId).find("b").removeClass("i-none").addClass("i-yesblue")}})}function setMeAsFan(friendId,obj){$(obj).find("b").removeClass("i-add").addClass("i-yesblue").attr("title","");obj.onclick=function(){return false};var ajaxOpts={friendAction:"setMeAsFan",userId:friendId};$.getJSON("/ajax_people.php",ajaxOpts,function(res){if(res.error){alert(res.msgError);$(obj).html('<b class="icon i-none"></b>')}})}function checkBoxListActions(obj){if(!obj.value||!$(obj).attr("friendId")){return}if(obj.checked){$(obj).parent().parent().addClass("bold");addFriendToList(obj.value,$(obj).attr("friendId"))}else{$(obj).parent().parent().removeClass("bold");rmFriendFromList(obj.value,$(obj).attr("friendId"))}closeAllDropDown()}function removeFriendSuggestion(id){$("#sug_fr_"+id).fadeOut();if(total_suggestions>max_sug_friends&&sugg_idx<max_idx_sug_friends){var content='<li id="sug_fr_'+sugg[sugg_idx][0]+'"><dl class="f-wrap"><dt><a  href="javascript:void(0)" onclick="ignoreFriendSuggestion('+sugg[sugg_idx][0]+'); return false;" class="link-close"><span class="icon i-close"></span></a><a class="thumb" href="/profile.php?u='+sugg[sugg_idx][0]+'">'+sugg[sugg_idx][2]+"</a>"+sugg[sugg_idx][1]+'</dt><dd><a class="openwin" src="layers/add_friend_welcome.php?u='+sugg[sugg_idx][0]+'" href="javascript:void(0)">'+msg_add+"</a></dd>";"</dl></li>";$("#ssg").append(content);$("#sug_fr_"+sugg[sugg_idx][0]).fadeIn();sugg_idx++;total_suggestions--;$("#ex2").jqmAddTrigger("a.openwin")}else{total_suggestions--;if(total_suggestions==0){$("#fr-0").hide()}}}function ignoreFriendSuggestion(id){$.getJSON("friend_suggestions.php",{rfid:id,"continue":1},function(data){if(data){removeFriendSuggestion(id)}});return true}function listseditShow(){$(".edit, .buttons",$("#form-listsedit")).show();$(".view",$("#form-listsedit")).hide()}function listseditHide(){$(".edit, .buttons",$("#form-listsedit")).hide();$(".view",$("#form-listsedit")).show()}function dropdown(){var a=$(this);if(a.hasClass("dropdown-open")){closeAllDropDown();return false}closeAllDropDown();var aWidth=a.width();aWidth+=parseInt(a.css("padding-left"),10)+parseInt(a.css("padding-right"),10);aWidth+=parseInt(a.css("borderLeftWidth"),10)+parseInt(a.css("borderRightWidth"),10);var aHeight=a.height();aHeight+=parseInt(a.css("padding-top"),10)+parseInt(a.css("padding-bottom"),10);aHeight+=parseInt(a.css("borderTopWidth"),10)+parseInt(a.css("borderBottomWidth"),10);var target=a.attr("href");var targetWidth=$(target).width();targetWidth+=parseInt($(target).css("padding-left"),10)+parseInt($(target).css("padding-right"),10);targetWidth+=parseInt($(target).css("borderLeftWidth"),10)+parseInt($(target).css("borderRightWidth"),10);var aPos=a.offset();$(target).css({left:aPos.left+aWidth-targetWidth+"px",top:aPos.top+aHeight+"px"}).toggle();a.toggleClass("dropdown-open");return false}function closeAllDropDown(){$(".dropdown-trigger",$("#content-wrap")).removeClass("dropdown-open");$(".dropdown-content",$("#content-wrap")).hide()}$(function(){$("#editLists").click(function(){if($("#newNewList").attr("title")==$("#newNewList").val()){$("#newNewList").val("")}var newListBack=$("#newNewList").val();trigger=this;$(trigger).attr("disabled","disabled");$("#form-listsedit").ajaxSubmit({url:"/ajax_people.php",type:"POST",dataType:"json",error:function(){alert("Error!")},success:function(res){if(!res.error){$("#newNewList").val("");if(res.response.changed){$.each(res.response.changed,function(i,n){$(i).html(n)})}if(res.response.newNewList){$("#friendNoListLI").prepend(res.response.newNewList);window.location.reload()}listseditHide()}else{$("#newNewList").val(newListBack);alert(res.msgError)}}});$(trigger).attr("disabled","");return false});$(".dropdown-trigger",$("#content-wrap")).click(dropdown);$(".txtinput[title], .txtarea[title]").TextTip()});