function to_shopping_cart(){
    var target = $('#target');
    var box = $('#to_shopping_cart_wrapper');
    var coord = box.offset();

    if (!isNaN(s_product) && s_product*1<=0 ){
        checkReasort();
    }else{
        target.css({
            'top': (coord.top)+"px",
            'left': (coord.left)+"px",
            'visibility' : 'visible',
            'opacity' : '1',
            'filter' :'alpha(opacity=100)',
            'height' : '295px',
            'width' : '295px',
            'z-index' : '100'
        });

        var img = $('#target_img');
        var zoom = $('#zoom');
        img.attr('src', zoom.attr('src'));

        box = $('#cart');
        coord = box.offset();

        target.animate(
        {
            'top': (coord.top+(box.height()/2))+"px",
            'left': (coord.left+(box.width()/2))+"px",
            'width':0+"px",
            'height':0+"px",
            'opacity' : '0',
            'filter' :'alpha(opacity=0)'
        },
        1000,
        'swing',
        function(){
            //close_cart();
            add_to_cart();
        });
    }
}

function add_to_cart(){
    var url = window.location.href.substring(0,window.location.href.lastIndexOf("/", 0)) + 'ajax_add_products.php';

    var qte = $('#qte').val();
    var products_id = $('#products_id').val();

       if (!isNaN(s_product) && qte*1 > s_product*1) {
        checkReasort();

    }
    
    $('#cart_wrapper').load(url,
    {
        'action' : 'add_product',
        'qte' : qte,
        'products_id' : products_id
    });


}

function checkReasort(){
    var url = window.location.href.substring(0,window.location.href.lastIndexOf("/", 0)) + 'checkReasort.php';

    $('#popups').load(url);
}

