var Basket = new function() {
    this.fullpath = '';
    this.items = new Object();
    this.count_items = 0;
    this.price_items = 0;
    
    this.update = function() {
        JsHttpRequest.query(
            this.fullpath+'?action=ajaxGetBasket&cache='+Utils.getCacheValue(),
            { },
            function(result, error) {
                if (error) alert(error);
                if (result['error'].length) {
                    for(var i in result['error']) {
                        alert(result['error'][i]);
                    }
                } else {
                    $('#basket_info').html(result['body']);
                }
            }
        );
    }
    
    this.addItem = function(item_id) {
        JsHttpRequest.query(
            this.fullpath+'?action=ajaxAddItem&cache='+Utils.getCacheValue(),
            {'id': item_id},
            function(result, error) {
                if (error) alert(error);
                if (result['error'].length) {
                    for(var i in result['error']) {
                        alert(result['error'][i]);
                    }
                } else {
                     $('#for_basket_'+item_id).replaceWith('<a href="'+Basket.fullpath+'">заказано</a>');
                    Basket.update();
                }
            }
        );
    }
    
    return this;
}();
