$(document).ready(function(){
// Скрипт кнопки "Купить"
    $(".add2cart_handler").click(function(){ 
        product = $(this).parent('.buy').parent('.no-add-to-basket').parent('.collections-item-inf_operation').parent('.collections-item-inf')
        art = product.find('.collections-item-inf_article').html()
        how_many = Number(product.find('.product_qty').attr('value'))
        value = parseInt(product.find('.collections-item-inf_square').html())
        data = {'art':art,'how_many':how_many,'value':value}
        url = "/ajax/add_to_cart"
        if (how_many > 0) 
        { 
            $.get(url,data,function(data){ 
                $('#basket_inner').html(data)
                product.find('.add-to-basket').show()
                product.find('.no-add-to-basket').hide()
                product.find('.in-basket').hide()
            })
        }
        else alert("Колличество товаров должно быть больше 0")
        return false
    })
// Скрипты кнопок вверх вниз(добавление колличества товаров)
    $(".amouth-plus").click(function(){ 
        plus = $(this).parent('.amouth-input').find('.product_qty')
        how_many = Number(plus.attr('value'))
        plus.attr({'value':how_many+1})
    })
    $(".amouth-minus").click(function(){ 
        minus = $(this).parent('.amouth-input').find('.product_qty')
        how_many = Number(minus.attr('value'))
        minus.attr({'value':how_many-1})
    })


// Скрипты на странице корзина
    $('.row-del').click(function(){ 
        data = { 'number':$(this).attr('value') }
        url = '/ajax/delete_from_cart'
        $.get(url,data,function(data){ 
            $('#basket').html(data)
        })
    })
})

