jQuery(document).ready(function($){

  $("#list_item_list_id").change(function() {
    var select = $(this);
    var settings = $(".list_box_setting");
    var input = $("#list_name");
    if(select.val()) {
    } else {
      settings.show();
    }
  });

  $('a#cancel_new_comp_list').livequery('click', function(e) {
    $('#authdrop').hide('slow');
  });

  $('.show_existing_lists').click(function(){
    $('#select_existing_list').removeAttr('disabled')
    $('.new_list_area').hide()
    $('.existing_list_area').fadeIn();
  });

  $('.show_new_list').click(function(){
    $('#select_existing_list').disable();
    $('.existing_list_area').hide();
    $('.new_list_area').fadeIn()
  });

  $(".pod.comparable").draggable({
    start: function() {$(".bundle-wrapper").remove();},
    helper: "clone",
    handle: ".pod-footer"
  });

  $("a[title=Compare]").click(function(e) {
    e.preventDefault();
    $.post($(this).attr('href'), {_method: 'put'}, function(data, textStatus) {
      $('#compare').html(data);
      if ($('.compare-items li').size() == 4) {
        $('.pod').removeClass('comparable');
        $('.pod .pod-footer .compare').remove();
        $(".pod").draggable("disable");
      }
    });
  });
});

$("#compare-items-bin").livequery(function() {
    $(this).droppable({
    accept: ".pod",
    tolerance: "pointer",
    hoverClass: "droppable",
    drop: function(ev, ui) {
      ui.draggable.find('a[title=Compare]').click();
    }
  });
});


