/*
 *  (c) 2010 BuyBidChat.com
 */

$(function() {
  $('a#active-list-toggle').click(function() {
    $('#active-comp-controls ul').slideToggle('fast');
  });
  $('#login-username').focus();

  $('form.confirm').submit(function(e) {
    if (!confirm('Are you sure?')) {
        e.preventDefault();
    }
  });
});

function attachDeleteHandler() {
$('.dt .btn-delete').unbind();
$('.dt .btn-delete').click(function() {
  if (!confirm('Are you sure you would like to delete this item?')) {
    return false;
  }
  var path = $(this).attr('href').split('/');
  var post_url = '/' + path[1] + '/' + path[2];
  var item_id = path.pop();
  var parent_row = $(this).closest('tr');
  var pos = DataTable.fnGetPosition(parent_row.get(0));
  $.post(post_url, { action: "delete", id: item_id }, function() {
    parent_row.fadeOut("slow", function() {
      DataTable.fnDeleteRow(pos);
    } 
  )});
  return false;
  });
}

