(function(){function t(t){e[e.length]=t}function n(){for(var t=0;t0,n[n.length]={group:i,item:s,label:s.label,hasHanger:a};for(var f=0;f0,n[n.length]={group:i,item:s,label:s.label,list:i.lists[f],hasHanger:a}}t(n)}}});var g=m.data("autocomplete");g._renderItem=function(e,t){var n=$("
  • ").data("item.autocomplete",t);if(t.is_item)$("#autocomplete-item-tmpl").tmpl({item_name:t.label}).appendTo(n);else if(t.list){var r=t.list.label;t.hasHanger?$("#autocomplete-already-in-collection-tmpl").tmpl({collection_name:r}).appendTo(n):$("#autocomplete-add-to-list-tmpl").tmpl({list_name:r}).appendTo(n),n.addClass("closet-list-autocomplete-item")}else{var i=t.group.label;t.hasHanger?$("#autocomplete-already-in-collection-tmpl").tmpl({collection_name:i}).appendTo(n):$("#autocomplete-add-to-group-tmpl").tmpl({group_name:i.replace(/\s+$/,"")}).appendTo(n),n.addClass("closet-hangers-group-autocomplete-item")}return n.appendTo(e)};var y=$("#closet-hangers-contact"),b=$(".edit-contact-link"),w=y.children("form"),E=$("#cancel-contact-link"),S=w.children("input[type=text]"),x=$("#contact-link-has-value span");b.click(function(){y.addClass("editing"),S.focus()}),E.click(T),w.submit(function(e){var t=w.serialize();w.disableForms(),$.ajax({url:w.attr("action")+".json",type:"post",data:t,dataType:"json",complete:function(){w.enableForms()},success:function(){var e=S.val();e.length>0?(b.addClass("has-value"),x.text(e)):b.removeClass("has-value"),T()},error:function(e){u(e,"saving Neopets username")}}),e.preventDefault()}),$("input[type=submit][data-confirm]").live("click",function(e){confirm(this.getAttribute("data-confirm"))||e.preventDefault()}),t(function(){$("div.closet-list").droppable({accept:"div.object",activate:function(){$(this).find(".closet-list-content").animate({opacity:0,height:100},250)},activeClass:"droppable-active",deactivate:function(){$(this).find(".closet-list-content").css("height","auto").animate({opacity:1},250)},drop:function(e,t){var n=t.draggable.find("form.closet-hanger-update");n.find("input[name=closet_hanger[list_id]]").val(this.getAttribute("data-id")),n.find("input[name=closet_hanger[owned]]").val($(this).closest(".closet-hangers-group").attr("data-owned")),p(n)}})}),C().live("change",N),t(function(){C().each(N)}),$("#toggle-help").click(function(){$("#closet-hangers-help").toggleClass("hidden")}),$("#closet-hangers-share-box").mouseover(function(){$(this).focus()}).mouseout(function(){$(this).blur()}),n()})();