$(function() {
    $("#home-carousel").jCarouselLite({
        btnNext: ".next",
        btnPrev: ".prev"
    });
    
    $("a.gallery").fancybox();
    $("a.show-img").click(function(){
        $(this).parent().find("a.gallery").click();
        return false;
    });
   
   $("a.reload-cimage").click(function(){
        $(this).parent().find("img").attr('src', $(this).attr('link')+"?id="+Math.random());
       return false;
   });
   
    $("input.add-to-chart-button").click(function(){
            var item = $(this).attr('item_id');
            var count = $(this).parent().find("input[type='text']").val();
            var $this = $(this);
            
            $.ajax({
                url: homeURL+'ajax/add_to_chart/?item='+item+"&count="+count,
                dataType: 'html',
                beforeSend: function (XMLHttpRequest) {
                    $('.preload_icon', $this).show();
                    $('.bascet_icon', $this).hide();
                },
                success: function(resp){
                    window.location.reload();
                },
                error: function(){
                    alert('Произошла ошибка');
                },
                cashe: false
            });       
            
            
    });
    
    
}); 
