var Search = { pics: [], showSpinner: function() { $('#search-container input').attr('disabled', 'disabled').blur(); $('#search-container img').show(); $('.autocomplete-container').hide(); Search.hideSuggestions(); }, hideSpinner: function() { $('#search-container input').removeAttr('disabled'); $('#search_field').focus(); $('#search-container img').hide(); }, showSuggestions: function(values) { for (var i = 0; i < values.length; i++) { $('.suggestions ul').append('\
  • \ '+ values[i].name +'\ '+ (values[i].desc ? '('+ values[i].desc +')' : '') +'\
  • \ '); } $('.suggestions').css('margin-left', $('#search_field').offset().left +'px').show(); }, hideSuggestions: function() { $('.suggestions ul li').remove(); $('.suggestions').hide(); }, showArtistPics: function(pics) { $('.artist_loading, .artist_pics').show(); for (var i = 0; i < pics.length; i++) { if (Search.pics.indexOf(pics[i]) === -1) { Search.pics.push(pics[i]); $('.artist_pics').append('\
    \ \
    \ '); } } } } $(function(){ $('.search').live('click', function(){ Ajax.loadSearchPage(); return false; }); $('#search_form').live('submit', function(){ $('.autocomplete-container').remove(); Ajax.loadArtistData($('#search_field').val()); return false; }); $('.suggestions a').live('click', function(){ $('#search_field').val($(this).text()); return false; }); });