  $(document).ready(function(){
      $(".itemTableLeft a,.smallPreviews a,.itemImgSmall a").fancybox({
        'overlayShow': true,
      	'hideOnContentClick': true
      });
      
      $(".ico-buy").click(function() {
        var art = $(this).attr('art');
        
  			$.get("/addtocart.php", { art_id: art, n: "1" },
         function(data){
           $('#sumInCart').html(data);
         });
         
        $(this).parent().addClass("added");
        return false;
		});

      $("[id^=itemAdder]").change(function() {
        var art = $(this).attr('art');
        var kolvo = $(this).attr('value');
        
        if(kolvo == "0") {
          $("#artTR"+art).hide("slow");
        }
        
  			$.get("/addtocart.php", { art_id: art, n: kolvo },
         function(data){
           $('#sumInCart').html(data);
           $('#sumInCart2').html(data);
         });
     
		});

      $("[id^=itemDel]").click(function() {
        var art = $(this).attr('art');
        var kolvo = '0';
        
        if(kolvo == "0") {
          $("#artTR"+art).fadeOut("slow");
        }
        
  			$.get("/addtocart.php", { art_id: art, n: kolvo },
         function(data){
           $('#sumInCart').html(data);
         });
     
		});
		
      $("#orderBut").click(function() {
      $("#result").html('');
      var str = $("#orderForm").serialize();       
      $.post("/includes/order.php", str,
         function(json){
            if(json.status == 'ok') { 
              document.orderForm.reset();
              $("#result").html('').append(json.message); //выводим сообщение об успехе
              $.get("/addtocart.php", {action: "reset"},
               function(data){
                 $('#cart').html(data);
               });              
              $(".itemsInCart").html('').fadeTo(6000,0,
              function() {
                  document.location = "/";
              });
            }else{
              $("#result").html('').append(json.message);            
            }  
         }, "json");
         return false;       
		});

  $(".menu a").click(function() {
    var show = $(this).attr('show');
    $(".menu a").removeClass("active");
    $(this).addClass("active");
    
    $("#short, #full").hide();
    $("#"+show).show();
  });

});
