$(document).ready(function(){

$(".cart_quantity").keydown(function () {
    $("img[g_id='"+$(this).attr("g_id")+"']").css('display','');
}
)

$(".cart_refr").click(function () {

    $.post('/cart_requantity/?',{cart: $(this).attr("g_id"), quantity:  $("input[g_id='"+$(this).attr("g_id")+"']").attr("value") },function() {
location.reload();
    });



}
)

$(".cart_del").click(function () {

    $.post('/cart_del/',{cart: $(this).attr("g_id")},function() {
location.reload();
    });
}
)


$("#cart_phone_ok").click(function () {
    in_phone = $("#cart_phone_input").attr("value");
    in_gid = $("#cart_phone_input").attr("gid");
    $("#cart_phone").html("<div class=\"loader\"></div>");

    $.getJSON('/order_submit/', {phone: in_phone, gid: in_gid }, function(json){
        if (json.result=='ok')
            {
                $("#cart_phone").html('Наш менеджер свяжется с Вами в ближайшее время для уточнения деталей заказа.');
            }
        else
            {
                location.reload();
            }
    });

}
)

}
);

function addToCart(g_id){
    $("#loader").css("display","block");
$.getJSON('/cart_add/', {gp: g_id}, function(json){
    $(".style_top_basket_count").html(json.count);
    $("#big_img_div").html("<img id=\"anim\" style=\"position: absolute; max-width: 200px;\" src=\""+$("#cart_big_img").attr("src")+"\">");
    $("#anim").css("top",$("#anim").offset().top);
    $("#anim").css("left",$("#anim").offset().left);
    $("#anim").animate({top:$(".style_top_basket").offset().top, left:$(".style_top_basket").offset().left+50, width:30, opacity:0}, 1000,
        function(){
                        $("#anim").css("display","none");
                        $("#loader").css("display","none");
                    }
);
});
    
}

