$(function() { 
  $("#form_message_button").click(function () { 
      $("#form_message").slideUp(); 
  });
  
  $(".delete_car").click(function () { 
    var cur_id = this.id
    if(confirm('Are you sure you want to remove this car from your garage?'))
    {
      $.ajax({
        type: "POST",
        url: "http://"+window.location.hostname+"/customer/garage/remove_car",
        data: "garage_id=" + this.id,
        success: function() {
          $("#" + cur_id).parents('.garage_car').slideUp();
        }
      });
    }
  });
  
  $(".delete_dealer_car").click(function () { 
    var cur_id = this.id
    if(confirm('Are you sure you want to remove this car from your garage?'))
    {
      $.ajax({
        type: "POST",
        url: "http://"+window.location.hostname+"/dealer/garage/remove_car",
        data: "garage_id=" + this.id,
        success: function() {
          $("#" + cur_id).parents('.garage_car').slideUp();
        }
      });
    }
  });
  
  $(".show_hide").click(function () {
  	$(this).parents('.make_group').find(".garage_car").slideToggle("slow");
  });
  
  $("#check_all").toggle(function() {
  	$("input[checked!='checked']").attr("checked","checked");
  	$("#check_all").text("Un-select all");
  }, function() {
  	$("input").removeAttr("checked");
  	$("#check_all").text("Select all");
  });
  
  $("#specs_buttons .tab_button").click(function() {
    $(".specs_section_content").hide().filter("#pane-"+this.id).show();
    $("#specs_buttons").children().removeClass("SelectedTabItem");
    $("#"+this.id).addClass("SelectedTabItem");
  });
  $("#options_buttons .tab_button").click(function() {
    $(".options_section_content").hide().filter("#pane-"+this.id).show();
    $("#options_buttons").children().removeClass("SelectedTabItem");
    $("#"+this.id).addClass("SelectedTabItem");
  });
});
