$(document).ready(function(){
  // Highlight active tab
  $("#menu a[href $='" + location.pathname + "']").parents("li").addClass('selected');

  $("ul#us-states").wrapList({ columns: 5, cssClass: "us-state-group" });

  $('select#city-selector').change(function (){
    if($(this).val() == ""){
      $('.city').show();
    }else{
      $('.city').hide();
      $('#' + $(this).val()).show();
    }
  });

  $('a.delete').live('click', function(event) {
    link = $(this);
    if(confirm("Are you sure you want to delete this listing?"))
      $.ajax({
        url: this.href,
        type: 'post',
        data: { '_method': 'delete' },
        success: function() {
          link.parents('#storate-site').slideUp(500);
        }
      });
    return false;
  });

  $('a.approve').live('click', function(event) {
    link = $(this);
    $.ajax({
      url: this.href,
      type: 'post',
      success: function() {
        link.parents('#storate-site').slideUp(500);
      }
    });
    return false;
  });

});
