$(".cmalink").click(function (e) {
   e.stopPropagation();
});
$(".sublink").click(function(e) {
   e.stopPropagation();
});
$("tr.selector").click(function() {
   if ($(this).is(".take")) {
      return;
   }
   var cat = $(this).attr('id');
   $(".product_group").hide();
   $(".sublink").hide();
   $("." + cat).show();
   $("tr.selector img").attr('src', '/public/images/catalog/arrow_bullet_right.png');
   $("img." + cat).attr('src', '/public/images/catalog/arrow_bullet_down.png');
   return false;
});

$("a.selector").click(function () {
   var hash = this.rel;
   hash = hash.replace(/^.*#/, '');
   $.history.load(hash);
});

$("tr.loader").click(function() {
   if (!$(this).is(".loader")) {
      return;
   }
   var cat = $(this).attr('id');
   $.ajax({
      type: "post"
      , url: "/" + $(".div_code").text() + "/async_product_loader.php"
      , data: "cat=" + cat
      , beforeSend: function() {
         $(".throbber").show();
      }
      , success: function(html) {
         $("#products_container").append(html);
         $(".throbber").hide();
      }
      , complete: function () {
         $(".product_group").hide();
         $("." + cat).show();
      }
   });
   $(this).removeClass('loader');
});

