(function () {
    var c = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
    var d = window.Crypto = {};
    var a = d.util = {
        rotl: function (h, g) {
            return (h << g) | (h >>> (32 - g));
        },
        rotr: function (h, g) {
            return (h << (32 - g)) | (h >>> g);
        },
        endian: function (h) {
            if (h.constructor == Number) {
                return a.rotl(h, 8) & 16711935 | a.rotl(h, 24) & 4278255360;
            }
            for (var g = 0; g < h.length; g++) {
                h[g] = a.endian(h[g]);
            }
            return h;
        },
        randomBytes: function (h) {
            for (var g = []; h > 0; h--) {
                g.push(Math.floor(Math.random() * 256));
            }
            return g;
        },
        bytesToWords: function (h) {
            for (var k = [], j = 0, g = 0; j < h.length; j++, g += 8) {
                k[g >>> 5] |= h[j] << (24 - g % 32);
            }
            return k;
        },
        wordsToBytes: function (i) {
            for (var h = [], g = 0; g < i.length * 32; g += 8) {
                h.push((i[g >>> 5] >>> (24 - g % 32)) & 255);
            }
            return h;
        },
        bytesToHex: function (g) {
            for (var j = [], h = 0; h < g.length; h++) {
                j.push((g[h] >>> 4).toString(16));
                j.push((g[h] & 15).toString(16));
            }
            return j.join("");
        },
        hexToBytes: function (h) {
            for (var g = [], i = 0; i < h.length; i += 2) {
                g.push(parseInt(h.substr(i, 2), 16));
            }
            return g;
        },
        bytesToBase64: function (h) {
            if (typeof btoa == "function") {
                return btoa(e.bytesToString(h));
            }
            for (var g = [], l = 0; l < h.length; l += 3) {
                var m = (h[l] << 16) | (h[l + 1] << 8) | h[l + 2];
                for (var k = 0; k < 4; k++) {
                    if (l * 8 + k * 6 <= h.length * 8) {
                        g.push(c.charAt((m >>> 6 * (3 - k)) & 63));
                    } else {
                        g.push("=");
                    }
                }
            }
            return g.join("");
        },
        base64ToBytes: function (h) {
            if (typeof atob == "function") {
                return e.stringToBytes(atob(h));
            }
            h = h.replace(/[^A-Z0-9+\/]/ig, "");
            for (var g = [], j = 0, k = 0; j < h.length; k = ++j % 4) {
                if (k == 0) {
                    continue;
                }
                g.push(((c.indexOf(h.charAt(j - 1)) & (Math.pow(2, -2 * k + 8) - 1)) << (k * 2)) | (c.indexOf(h.charAt(j)) >>> (6 - k * 2)));
            }
            return g;
        }
    };
    d.mode = {};
    var b = d.charenc = {};
    var f = b.UTF8 = {
        stringToBytes: function (g) {
            return e.stringToBytes(unescape(encodeURIComponent(g)));
        },
        bytesToString: function (g) {
            return decodeURIComponent(escape(e.bytesToString(g)));
        }
    };
    var e = b.Binary = {
        stringToBytes: function (j) {
            for (var g = [], h = 0; h < j.length; h++) {
                g.push(j.charCodeAt(h));
            }
            return g;
        },
        bytesToString: function (g) {
            for (var j = [], h = 0; h < g.length; h++) {
                j.push(String.fromCharCode(g[h]));
            }
            return j.join("");
        }
    };
})();
(function () {
    var f = Crypto,
        a = f.util,
        b = f.charenc,
        e = b.UTF8,
        d = b.Binary;
    var c = f.MD5 = function (i, g) {
            var h = a.wordsToBytes(c._md5(i));
            return g && g.asBytes ? h : g && g.asString ? d.bytesToString(h) : a.bytesToHex(h);
        };
    c._md5 = function (y) {
        if (y.constructor == String) {
            y = e.stringToBytes(y);
        }
        var k = a.bytesToWords(y),
            n = y.length * 8,
            v = 1732584193,
            u = -271733879,
            t = -1732584194,
            s = 271733878;
        for (var p = 0; p < k.length; p++) {
            k[p] = ((k[p] << 8) | (k[p] >>> 24)) & 16711935 | ((k[p] << 24) | (k[p] >>> 8)) & 4278255360;
        }
        k[n >>> 5] |= 128 << (n % 32);
        k[(((n + 64) >>> 9) << 4) + 14] = n;
        var q = c._ff,
            h = c._gg,
            w = c._hh,
            o = c._ii;
        for (var p = 0; p < k.length; p += 16) {
            var g = v,
                r = u,
                j = t,
                x = s;
            v = q(v, u, t, s, k[p + 0], 7, -680876936);
            s = q(s, v, u, t, k[p + 1], 12, -389564586);
            t = q(t, s, v, u, k[p + 2], 17, 606105819);
            u = q(u, t, s, v, k[p + 3], 22, -1044525330);
            v = q(v, u, t, s, k[p + 4], 7, -176418897);
            s = q(s, v, u, t, k[p + 5], 12, 1200080426);
            t = q(t, s, v, u, k[p + 6], 17, -1473231341);
            u = q(u, t, s, v, k[p + 7], 22, -45705983);
            v = q(v, u, t, s, k[p + 8], 7, 1770035416);
            s = q(s, v, u, t, k[p + 9], 12, -1958414417);
            t = q(t, s, v, u, k[p + 10], 17, -42063);
            u = q(u, t, s, v, k[p + 11], 22, -1990404162);
            v = q(v, u, t, s, k[p + 12], 7, 1804603682);
            s = q(s, v, u, t, k[p + 13], 12, -40341101);
            t = q(t, s, v, u, k[p + 14], 17, -1502002290);
            u = q(u, t, s, v, k[p + 15], 22, 1236535329);
            v = h(v, u, t, s, k[p + 1], 5, -165796510);
            s = h(s, v, u, t, k[p + 6], 9, -1069501632);
            t = h(t, s, v, u, k[p + 11], 14, 643717713);
            u = h(u, t, s, v, k[p + 0], 20, -373897302);
            v = h(v, u, t, s, k[p + 5], 5, -701558691);
            s = h(s, v, u, t, k[p + 10], 9, 38016083);
            t = h(t, s, v, u, k[p + 15], 14, -660478335);
            u = h(u, t, s, v, k[p + 4], 20, -405537848);
            v = h(v, u, t, s, k[p + 9], 5, 568446438);
            s = h(s, v, u, t, k[p + 14], 9, -1019803690);
            t = h(t, s, v, u, k[p + 3], 14, -187363961);
            u = h(u, t, s, v, k[p + 8], 20, 1163531501);
            v = h(v, u, t, s, k[p + 13], 5, -1444681467);
            s = h(s, v, u, t, k[p + 2], 9, -51403784);
            t = h(t, s, v, u, k[p + 7], 14, 1735328473);
            u = h(u, t, s, v, k[p + 12], 20, -1926607734);
            v = w(v, u, t, s, k[p + 5], 4, -378558);
            s = w(s, v, u, t, k[p + 8], 11, -2022574463);
            t = w(t, s, v, u, k[p + 11], 16, 1839030562);
            u = w(u, t, s, v, k[p + 14], 23, -35309556);
            v = w(v, u, t, s, k[p + 1], 4, -1530992060);
            s = w(s, v, u, t, k[p + 4], 11, 1272893353);
            t = w(t, s, v, u, k[p + 7], 16, -155497632);
            u = w(u, t, s, v, k[p + 10], 23, -1094730640);
            v = w(v, u, t, s, k[p + 13], 4, 681279174);
            s = w(s, v, u, t, k[p + 0], 11, -358537222);
            t = w(t, s, v, u, k[p + 3], 16, -722521979);
            u = w(u, t, s, v, k[p + 6], 23, 76029189);
            v = w(v, u, t, s, k[p + 9], 4, -640364487);
            s = w(s, v, u, t, k[p + 12], 11, -421815835);
            t = w(t, s, v, u, k[p + 15], 16, 530742520);
            u = w(u, t, s, v, k[p + 2], 23, -995338651);
            v = o(v, u, t, s, k[p + 0], 6, -198630844);
            s = o(s, v, u, t, k[p + 7], 10, 1126891415);
            t = o(t, s, v, u, k[p + 14], 15, -1416354905);
            u = o(u, t, s, v, k[p + 5], 21, -57434055);
            v = o(v, u, t, s, k[p + 12], 6, 1700485571);
            s = o(s, v, u, t, k[p + 3], 10, -1894986606);
            t = o(t, s, v, u, k[p + 10], 15, -1051523);
            u = o(u, t, s, v, k[p + 1], 21, -2054922799);
            v = o(v, u, t, s, k[p + 8], 6, 1873313359);
            s = o(s, v, u, t, k[p + 15], 10, -30611744);
            t = o(t, s, v, u, k[p + 6], 15, -1560198380);
            u = o(u, t, s, v, k[p + 13], 21, 1309151649);
            v = o(v, u, t, s, k[p + 4], 6, -145523070);
            s = o(s, v, u, t, k[p + 11], 10, -1120210379);
            t = o(t, s, v, u, k[p + 2], 15, 718787259);
            u = o(u, t, s, v, k[p + 9], 21, -343485551);
            v = (v + g) >>> 0;
            u = (u + r) >>> 0;
            t = (t + j) >>> 0;
            s = (s + x) >>> 0;
        }
        return a.endian([v, u, t, s]);
    };
    c._ff = function (i, h, o, l, g, k, j) {
        var m = i + (h & o | ~h & l) + (g >>> 0) + j;
        return ((m << k) | (m >>> (32 - k))) + h;
    };
    c._gg = function (i, h, o, l, g, k, j) {
        var m = i + (h & l | o & ~l) + (g >>> 0) + j;
        return ((m << k) | (m >>> (32 - k))) + h;
    };
    c._hh = function (i, h, o, l, g, k, j) {
        var m = i + (h ^ o ^ l) + (g >>> 0) + j;
        return ((m << k) | (m >>> (32 - k))) + h;
    };
    c._ii = function (i, h, o, l, g, k, j) {
        var m = i + (o ^ (h | ~l)) + (g >>> 0) + j;
        return ((m << k) | (m >>> (32 - k))) + h;
    };
    c._blocksize = 16;
})();
(function (window) {
    DC.Currency = {
        DOLLAR: "$",
        USD: "US$",
        GBP: "&pound;",
        EUR: "&euro;",
        UAH: "грн.",
        getCurrencySymbol: function (currency) {
            switch (currency) {
            case "GBP":
                return "&pound;";
            case "EUR":
                return "&euro;";
            default:
                return "$";
            }
        }
    };
}(window));
(function (window) {
    DC.DeliveryComboBox = {
        onChange: function(el, data) {
            var self = this,
                select = $("#payment_method > select");
            var payment_list = '';
            $.each(DC.cart.lang_ru.DeliveryMethods, function() {
                if (this[self.dataKey] == data.id) {
                    payment_list = this.payment_list;
                }
            });
            var block = $('.float.hidden');
            if (data.id == 1) {
                if (block.is(':visible')) {
                    block.hide();
                }
                $('select[name=city]').removeAttr('disabled');
            } else {
                if (!block.is(':visible')) {
                    block.show();
                }
                if (data.id == 2) {
                    $("select[name=city] [value=1]").attr("selected", "selected");
                    $('select[name=city]').attr("disabled", "disabled");
                } else {
                    $('select[name=city]').removeAttr('disabled');
                }
            }
            payment_list = payment_list.replace(/^\s+/g, '').split(',');
            var options = select.prop ? select.prop('options') : select.attr('options');
            $('option', select).remove();
            $.each(DC.cart.lang_ru.PaymentMethods, function() {
                if ($.inArray(''+this[self.dataKey], payment_list) > -1) {
                    var key = ($.isPlainObject(this) && this[self.dataKey]) ? this[self.dataKey] : this,
                        value = ($.isPlainObject(this) && this[self.labelKey]) ? this[self.labelKey] : this;
                    options[options.length] = new Option(value, key);
                }
            });
            var controller = cart.cart._cartController;
            controller.deliveryMethod = data.id;
            controller._updateCount();
            var items = controller.getAllItems();
            for (var idx in items) {
                items[idx].price = items[idx].price_nal;
            }
            cart.cart._orderView._ds.load(items);
            cart.cart._orderView.update(controller);
            this._super();
        }
    };
    window.DC.DeliveryComboBox = DC.ComboBox.extend(DC.DeliveryComboBox);
    DC.PaymentComboBox = {
        onChange: function(el, data) {
            var controller = cart.cart._cartController;
            controller.paymentMethod = data.id;
            var items = controller.getAllItems();
            for (var idx in items) {
                if (data.id > 1) {
                    items[idx].price = items[idx].price_bn;
                } else {
                    items[idx].price = items[idx].price_nal;
                }
            }
            cart.cart._orderView._ds.load(items);
            cart.cart._orderView.update(controller);
            this._super();
        }
    }
    window.DC.PaymentComboBox = DC.ComboBox.extend(DC.PaymentComboBox);
    DC.TextBox = {
        createComplete: function () {
            var self = this;
            self._super();
            self.ui.find('A').click(function() {
                var block = $('.float.hidden');
                if (block.is(':visible')) {
                    block.hide();
                } else {
                    block.show();
                }
                return false;
            });
        }
    };
    window.DC.TextBox = DC.Text.extend(DC.TextBox);
}(window));
(function (window) {
    window.DC.cart = DC.cart || {};
    DC.cart.Cart = {
        width: 700,
        height: 500,
        widget: null,
        autoOpenWhenAdd: false,
        autoCleanCart: true,
        openNewCheckOutWindow: false,
        language: "en",
        currency: "USD",
        header: "",
        footer: "",
        shipping: 0,
        maxShippingValue: 0,
        paypalOptions: {},
        themeColor: undefined,
        themeDarkColor: undefined,
        cartOpened: false,
        onItemAdd: DC.NOOP,
        onItemupRemove: DC.NOOP,
        onCartUpdate: DC.NOOP,
        onCheckOut: DC.NOOP,
        onSubmit: DC.NOOP,
        _currentSection: "cart",
        _widget: null,
        _cartController: null,
        _container: null,
        _cartView: null,
        _orderView: null,
        _paymentView: null,
        init: function (options) {
            var self = this;
            $.extend(this, options);
            $('body').append('<div id="popupbg" style="height:'+$(document).height()+'px;width:'+$(document).width()+'"></div>');
            $('#popupbg').click(function() {
                if (self.cartOpened) {
                    self.closeCart();
                }
            });
            if (this.language) {
                DC.cart.lang = DC.cart["lang_" + this.language];
            } else {
                DC.cart.lang = DC.cart.lang_en;
            }
            if (this.widget) {
                this._widget = this.widget;
                this._widget.addClass('cartWidget');
                this._widget.click(function() {
                    if (self.cartOpened) {
                        self.closeCart();
                    } else {
                        self._changeSection('cart');
                        self.openCart();
                    }
                });
            }
            this._container = new DC.cart.ContainerView({
                styles: "cart",
                width: this.width,
                height: this.height,
                onLeftButtonClick: function () {
                    if (self._currentSection == 'cart') {
                        self.closeCart();
                    } else if (self._currentSection == 'order') {
                        self._changeSection('cart');
                    } else if (self._currentSection == 'payment') {
                        self.closeCart();
                    }
                },
                onRightButtonClick: function () {
                    if (self._currentSection == 'cart') {
                        self._changeSection('order');
                    } else if (self._currentSection == 'order') {
                        self._cartController.onCheckout(self);
                    }
                }
            });
            this._cartView = new DC.cart.CartView({
                width: 280,
                onUpdate: DC.NOOP,
                onItemUpdate: function (ids, qtys) {
                    self._cartController.updateItemQty(ids, qtys);
                },
                onItemRemove: function (item) {
                    self._cartController.removeItem(item.id);
                }
            });
            this._paymentView = new DC.cart.PaymentView();
            this._container.setHeader(DC.cart.lang["step1"]);
            this._container.setFooter(this.footer);
            this._cartController = new DC.cart.CartController({
                currency: this.currency,
                shipping: this.shipping,
                maxShippingValue: this.maxShippingValue,
                paymentOptions: this.paymentOptions,
                paypalOptions: this.paypalOptions,
                openNewCheckOutWindow: this.openNewCheckOutWindow,
                onUpdate: function() {
                    self._updateCartView(this);
                    self._updateOrderView(this);
                    self.onCartUpdate(this);
                },
                onUpdateWidget: function() {
                    self._updateCartWidget(this);
                },
                onItemAdd: function(item) {
                    self.onItemAdd(item);
                },
                onItemupRemove: function(item) {
                    self.onItemRemove(item);
                },
                onCheckout: function(cart) {
                    self.onSubmit(this);
                }
            });
            this._orderView = new DC.cart.OrderView({
                cartController: this._cartController
            });
            this._container.attachTo("body");
            this._container.setSize(this.width, this.height);
            this._container.ui.css({
                top: 0,
                left: ($(window).width() - this.width) / 2
            });
            this._container.setVisible(false);
            $(window).resize(function () {
                self._container.ui.css({
                    left: ($(window).width() - self.width) / 2
                });
                $('#popupbg').css({
                    width: $(document).width(),
                    heigth: $(document).width()
                });
            });
        },
        _updateCartView: function (controller) {
            if (!controller) return;
            if (this._currentSection == 'cart') {
                if (controller.count <= 0) {
                    this._container.rightButton.setEnabled(false);
                } else {
                    this._container.rightButton.setEnabled(true);
                }
                this._cartView.update(controller);
            }
            this._updateCartWidget(controller);
            this._updateStyles();
        },
        _updateCartWidget: function(controller) {
            if (!this._widget) return;
            var html = '<div class="amount">';
            if (controller.subTotal > 0) {
                html += DC.cart.lang['cartwidget'].replace("%S", '<b>' + controller.count + '</b>') +
                    '<b>' + controller.subTotal.toFixed(2) + '</b> ' + DC.Currency[controller.currency];
            } else {
                html += DC.cart.lang['cartwidget_empty'];
            }
            html += '</div>';
            var content = $(html);
            content.hide();
            this._widget.empty();
            this._widget.append(content);
            content.fadeIn();
        },
        _updateOrderView: function(controller) {
            if (this._orderView) {
                this._orderView.update(controller);
            }
        },
        _changeSection: function(section) {
            if (section == 'cart') {
                this._container.setHeader(DC.cart.lang["step1"]);
                this._container._titleContainer.setVisible(true);
                this._container.setContent(this._cartView);
                this._container.rightButton.setVisible(true);
                this._container.setSection(1);
            } else if (section == 'order') {
                this._container._titleContainer.setVisible(false);
                this._container.setHeader(DC.cart.lang["step2"]);
                if (this._orderView._ds) {
                    this._orderView._ds.load(this._cartController.getAllItems());
                }
                this._container.setContent(this._orderView);
                this._container.rightButton.setVisible(true);
                this._container.setSection(2);
            } else if (section == 'payment') {
                this._paymentView.updatePayment(this._cartController);
                this._container._titleContainer.setVisible(false);
                this._container.setHeader(DC.cart.lang["step3"]);
                this._container.setContent(this._paymentView);
                this._container.rightButton.setVisible(false);
                this._container.setSection(3);
            }
            this._currentSection = section;
            this._updateContainerButton();
        },
        _updateContainerButton: function() {
            if (this._cartController) {
                if (this._currentSection == 'cart') {
                    this._container.leftButton.setText(DC.cart.lang["button_cancel"]);
                    this._container.rightButton.setText(DC.cart.lang["button_order"]);
                    this._container.rightButton.setVisible(true);
                } else if (this._currentSection == 'order') {
                    this._container.leftButton.setText(DC.cart.lang["button_cart"]);
                    this._container.rightButton.setText(DC.cart.lang["button_payment"]);
                    this._container.rightButton.setVisible(true);
                } else if (this._currentSection == 'payment') {
                    this._container.leftButton.setText(DC.cart.lang["button_cancel"]);
                    this._container.rightButton.setVisible(false);
                }
            }
        },
        _updateStyles: function () {
            if (this.themeColor) {
                $(".dc_ui.cart .button").css("background-color", this.themeColor);
                $(".dc_ui.cart .button.disabled").css("background-color", "");
                $(".dc_ui.cart .step").css("background-color", "");
                $(".dc_ui.cart .step.selected").css("background-color", this.themeColor);
                $(".cartWidget").css("background-color", this.themeColor);
            }
            if (this.themeDarkColor) {
                $(".dc_ui.cart .step .tag").css("background-color", "");
                $(".dc_ui.cart .step.selected .tag").css("background-color", this.themeDarkColor);
                $(".dc_ui.cart .total_label .amount").css("color", this.themeDarkColor);
            }
        },
        openCart: function() {
            this._updateCartView(this._cartController);
            this._updateOrderView(this._cartController);
            this._openCart();
        },
        _openCart: function() {
            this.cartOpened = true;
            this._container.setXY(0, -this.height-60, 0, true);
            $('#popupbg').css({display: 'block'});
            this._container.setVisible(true);
            this._container.setSize();
            this._container.setXY(0, 0, 0.8, true);
        },
        closeCart: function() {
            this.cartOpened = false;
            this._container.setXY(0, -this.height-60, 0.8, true, 0, function() {
                $('#popupbg').css({display: 'none'});
            });
        },
        add: function (data) {
            this._cartController.addItem(data);
            this._changeSection('cart');
            if (this.autoOpenWhenAdd) {
                this._openCart();
            }
        },
        remove: function (id) {
            this._cartController.removeItem(id);
        },
        clean: function () {
            this._cartController.clean();
        },
        updateQty: function (id, qty) {
            this._cartController.updateItemQty([id], [qty]);
        },
        onSubmit: function(controller) {
            var self = this,
                data = this._orderView._form.getValues();
            if (!data) return false;
            data.total = controller.total;
            data.subTotal = controller.subTotal;
            data.count = controller.count;
            data.shipping = (controller.deliveryMethod == 2) && (controller.subTotal < controller.maxShippingValue) ? controller.shipping : 0;
            data.items = [];
            var ui = this._orderView._form.ui,
                url = ui.attr('action'),
                type = ui.attr('method'),
                items = controller.getAllItems();
            for (var i=0; i<items.length; i++) {
                var item = {
                    id: items[i].id,
                    price: items[i].price,
                    qty: items[i].qty,
                    total: items[i].total
                };
                data.items.push(item);
            }
            $.ajax({
                url: url,
                type: type,
                dataType: 'json',
                data: data,
                success: function(data) {
                    controller.paymentOrderId = data.orderId;
                    controller.paymentSubTotal = data.subTotal;
                    controller.paymentTotal = data.total;
                    controller.paymentTotalUSD = data.totalUSD;
                    controller.paymentShipping = data.shipping;
                    controller.paymentShippingUSD = data.shippingUSD;
                    controller.paymentRate = data.rate;
                    controller.paymentCount = data.count;
                    self._changeSection('payment');
                    if (self.autoCleanCart) {
                        controller.clean();
                    }
                }
            });
            return true;
        }
    };
    DC.cart.Cart = Class.extend(DC.cart.Cart);
}(window));
(function (window) {
    DC.cart.Item = {
        id: undefined,
        name: "",
        thumbnail: null,
        description: "",
        type: "DUMMY",
        currency_symbol: "$",
        currency: "",
        price: 0,
        qty: 0,
        total: 0,
        weight: 0,
        allowMultiple: true,
        init: function (data) {
            if (data.id == "undefined" || data.id == undefined) {
                data.id = Crypto.MD5(data.name);
            }
            if (data.price != undefined) {
                data.price = parseFloat(data.price);
            }
            if (typeof data.allowMultiple == "string" && (data.allowMultiple.toLowerCase() == "false" || data.allowMultiple.toLowerCase() == "no")) {
                data.allowMultiple = false;
            }
            if (data.allowMultiple == false || data.allowMultiple == 0) {
                data.allowMultiple = false;
            }
            $.extend(this, data);
        }
    };
    window.DC.cart.Item = Class.extend(DC.cart.Item);
    DC.cart.CartEvent = {
        items: null,
        init: function (type, items) {
            this._super(type);
            this.items = items;
        }
    };
    window.DC.cart.CartEvent = DC.Event.extend(DC.cart.CartEvent);
    $.extend(DC.cart.CartEvent, {
        ADD: "cart_add",
        REMOVE: "cart_remove",
        UPDATE: "cart_update"
    });
    DC.cart.CartController = {
        id: 'PORTAMIX_CART',
        version: '0.1',
        items: null,
        currency: 'UAH',
        shipping: 0,
        maxShippingValue: 0,
        order: null,
        count: 0,
        paypalOptions: null,
        paymentOptions: null,
        total: 0,
        subTotal: 0,
        deliveryMethod: 1,
        paymentMethod: 1,
        openNewCheckOutWindow: false,
        _storage: null,
        onUpdate: DC.NOOP,
        onItemAdd: DC.NOOP,
        onItemRemove: DC.NOOP,
        onCheckout: DC.NOOP,
        init: function (options) {
            if (options) {
                $.extend(this, options);
            }
            this._storage = new DC.CookieStorage({
                id: this.id,
                version: this.version + "_" + this.currency
            });
            this.items = {};
            var tempItems = this._storage.get("cart");
            if (tempItems) {
                for (var i in tempItems) {
                    var item = tempItems[i];
                    this.items[item.id] = new DC.cart.Item(item);
                }
            }
            this._updateCount();
            this.onUpdateWidget();
        },
        _update: function () {
            this._updateCount();
            this._storage.set("cart", this.items);
            this.onUpdate();
        },
        _updateCount: function () {
            var count = 0;
            this.total = 0;
            this.subTotal = 0;
            for (var idx in this.items) {
                if (this.items[idx]) {
                    var price = this.items[idx].price,
                        tt = this.items[idx].qty * price;
                    if (tt > 0) {
                        this.subTotal = this.subTotal + tt;
                    }
                    count++;
                }
            }
            var shipping = (this.deliveryMethod == 2) && (this.subTotal < this.maxShippingValue) ? this.shipping : 0;
            this.total = this.subTotal + shipping;
            this.count = count;
        },
        addItem: function (item) {
            if (item.id == "undefined" || item.id == undefined) {
                item.id = Crypto.MD5(item.name);
            }
            var tempitem;
            if (this.items[item.id]) {
                tempitem = this.items[item.id];
            } else {
                tempitem = new DC.cart.Item(item);
                this.items[item.id] = tempitem;
            }
            tempitem.currency = this.currency;
            if (tempitem.allowMultiple) {
                if (item.qtys == undefined) {
                    if (item.qtyInput) {
                        if ($("#" + item.qtyInput)) {
                            tempitem.qty += Number($("#" + item.qtyInput).val());
                        }
                    } else {
                        tempitem.qty = tempitem.qty + 1;
                    }
                } else {
                    tempitem.qty = tempitem.qty + item.qtys;
                }
            } else {
                tempitem.qty = 1;
            }
            tempitem.total = tempitem.qty * item.price;
            if (tempitem.qty > 0) {
                this.onItemAdd(tempitem);
                this._update();
            } else {
                this.items[item.id] = null;
            }
        },
        removeItem: function (id) {
            if (id != undefined) {
                this.updateItemQty([id], [0]);
            }
        },
        updateItemQty: function (ids, qtys) {
            if (ids && qtys) {
                for (var i in ids) {
                    var id = ids[i];
                    var qty = qtys[i];
                    if (this.items[id] && qty != undefined) {
                        var tempitem = this.items[id];
                        if (qty > 0) {
                            tempitem.qty = qty;
                        } else {
                            this.onItemRemove(tempitem);
                            delete this.items[id];
                        }
                    }
                }
            }
            this._update();
        },
        getAllItems: function() {
            var a = [];
            for (var idx in this.items) {
                if (this.items[idx]) {
                    a.push(this.items[idx]);
                }
            }
            return a;
        },
        getItemsForPurchase: function () {
            var a = [];
            for (var idx in this.items) {
                if (this.items[idx]) {
                    a.push({
                        "qty": this.items[idx].qty,
                        "id": this.items[idx].id,
                        "class": this.items[idx]["class"]
                    });
                }
            }
            return a;
        },
        clean: function () {
            this.items = {};
            this._update();
        },
        getfreeItems: function () {
            var f = true;
            for (var idx in this.items) {
                if (this.items[idx].price != 0) {
                    f = false;
                    break;
                }
            }
            if (f) {
                f = (this.total() <= 0);
            }
            return f;
        }
    };
    DC.cart.CartController = Class.extend(DC.cart.CartController);
}(window));
(function (window) {
    DC.cart.ContainerView = {
        leftButton: null,
        rightButton: null,
        _header: null,
        _footer: null,
        _content: null,
        _stepContainer: null,
        _title: null,
        _titleContainer: null,
        _step1: null,
        _step2: null,
        _step3: null,
        _contentContainer: null,
        _controlContainer: null,
        _stepWidth: 100,
        onRightButtonClick: DC.NOOP,
        onLeftButtonClick: DC.NOOP,
        createChildren: function () {
            this._super();
            var self = this;
            this._header = new DC.Container({
                styles: 'header',
                width: this.width,
                height: 0
            });
            this._footer = new DC.Container({
                styles: 'footer',
                width: this.width,
                height: 0
            });
            this._step1 = new DC.Text({
                styles: 'step selected',
                text: '<div class="step1"></div><div class="text">' + DC.cart.lang['step1'] + '</div>'
            });
            this._step1._container.addClass('wrapper');
            this._step2 = new DC.Text({
                styles: 'step',
                text: '<div class="step2"></div><div class="text">' + DC.cart.lang['step2'] + '</div>'
            });
            this._step2._container.addClass('wrapper');
            this._step3 = new DC.Text({
                styles: 'step',
                text: '<div class="step3"></div><div class="text">' + DC.cart.lang['step3'] + '</div>'
            });
            this._step3._container.addClass('wrapper');
            this._stepContainer = new DC.HBox({
                gap: 0,
                styles: 'header_container',
                width: this.width
            });
            this._stepContainer.addChild(this._step1);
            this._stepContainer.addChild(this._step2);
            this._stepContainer.addChild(this._step3);
            this._title = new DC.Text({
                styles: 'title',
                text: '<div style="padding-left:130px;">Товар</div><div style="padding-left:316px;">Кол-во</div><div style="padding-left:63px;">Сумма</div>'
            });
            this._titleContainer = new DC.Container({
                styles: "title_container",
                width: this.width
            });
            this._titleContainer.addChild(this._title);
            this._contentContainer = new DC.Container({
                styles: 'content_container',
                width: this.width
            });
            this._contentContainer.setClipping(true);

            this._controlContainer = new DC.Container({
                styles: 'control_container',
                width: this.width
            });
            this.leftButton = new DC.Button({
                styles: 'left_button',
                text: "Left",
                onClick: function () {
                    self.onLeftButtonClick();
                }
            });
            this.rightButton = new DC.Button({
                styles: 'right_button',
                text: "Right",
                onClick: function () {
                    self.onRightButtonClick();
                }
            });
            this._controlContainer.addChild(this.leftButton);
            this._controlContainer.addChild(this.rightButton);
            this.addClass('cartcontainer');
        },
        createComplete: function () {
            this._super();
            this.addChild(this._header);
            this.addChild(this._stepContainer);
            this.addChild(this._titleContainer);
            this.addChild(this._contentContainer);
            this.addChild(this._controlContainer);
            this.addChild(this._footer);
        },
        setSize: function (w, h) {
            var height = $(".cartcontainer > .header").height() + $(".cartcontainer > .footer").height() +
                $(".cartcontainer > .control_container").height() + $(".cartcontainer > .header_container").height();
            if ($(".cartcontainer > .title_container").is(':visible')) {
                height += $(".cartcontainer > .title_container").height();
            }
            var height = this.defaultHeight - height;
            if (height > 0) {
                this._contentContainer.setSize(this.width, height);
            }
            this._super(w, h);
            this._header.setSize();
            this._footer.setSize();
            this._stepWidth = this.innerWidth / 3;
            this._step1.setSize(this._stepWidth);
            this._step2.setSize(this._stepWidth);
            this._step3.setSize(this._stepWidth);
            this._stepContainer.setSize(this.innerWidth);
            if (this._content) {
                this._content.setSize(this._contentContainer.width, this._contentContainer.height);
            }
        },
        setContent: function (content) {
            if (this._contentContainer) {
                if (this._content) {
                    this._contentContainer.removeChild(this._content);
                }
                this._content = content;
                this._contentContainer.addChild(content);
            }
        },
        setSection: function (value) {
            this._step1.removeClass("selected");
            this._step2.removeClass("selected");
            this._step3.removeClass("selected");
            if (value == 1) {
                this._step1.addClass("selected");
            } else {
                if (value == 2) {
                    this._step2.addClass("selected");
                } else {
                    if (value == 3) {
                        this._step3.addClass("selected");
                    }
                }
            }
        },
        setTitle: function (value) {
            this._title.setText(value);
        },
        setHeader: function (value) {
            if (value && value != "") {
                this._header.ui.html(value);
            } else {
                this._header.setVisible(false);
            }
        },
        setFooter: function (value) {
            if (value && value != "") {
                this._footer.ui.append(value);
            } else {
                this._footer.setVisible(false);
            }
        }
    };
    window.DC.cart.ContainerView = DC.VBox.extend(DC.cart.ContainerView);
}(window));
(function (window) {
    DC.cart.CartItemRenderer = {
        thumbnail: null,
        title: null,
        itemid: null,
        price: null,
        qty: null,
        leftContainer: null,
        delete_button: null,
        count_text: null,
        onItemRemove: DC.NOOP,
        onItemUpdate: DC.NOOP,
        createChildren: function () {
            this._super();
            var self = this;
            this.leftContainer = new DC.Container({
                styles: 'container'
            });
            this.delete_button = new DC.Button({
                text: DC.cart.lang['button_delete'],
                styles: 'delete_button tooltip ztip',
                onClick: function () {
                    self.dispatchEvent(new DC.cart.CartEvent(DC.cart.CartEvent.REMOVE, self.data));
                }
            });
            this.thumbnail = new DC.Image({
                styles: 'thumbnail',
                width: 80,
                height: 80
            });
            this.itemid = new DC.Text({
                styles: 'itemid'
            });
            this.title = new DC.Text({
                styles: 'title'
            });
            this.leftContainer.addChild(this.delete_button);
            this.leftContainer.addChild(this.thumbnail);
            this.leftContainer.addChild(this.itemid);
            this.leftContainer.addChild(this.title);
            this.price = new DC.Text({
                styles: 'price'
            });
            this.qty = new DC.TextInput({
                styles: 'qty',
                onChange: function (d) {
                    self.data.qty = DC.num(self.qty.value());
                    self.dispatchEvent(new DC.cart.CartEvent(DC.cart.CartEvent.CHANGE, self.data));
                }
            });
            this.count_text = new DC.Text({
                styles: 'count_text',
                text: "шт."
            });
            this.qty.setVisible(false);
            this.count_text.setVisible(false);
        },
        createComplete: function () {
            this._super();
            this.addChild(this.leftContainer);
            this.addChild(this.price);
            this.addChild(this.qty);
            this.addChild(this.count_text);
        },
        commitSize: function () {
            this._super();
            this.qty.setSize(35);
            if (this.data.thumbnail) {
                this.thumbnail.setVisible(true);
                this.title.ui.css({
                    left: this.thumbnail.width + 45
                });
                this.itemid.ui.css({
                    left: this.thumbnail.width + 45
                });
            } else {
                this.thumbnail.setVisible(false);
                this.title.ui.css({
                    left: 35
                });
                this.itemid.ui.css({
                    left: 35
                });
            }
        },
        commitProperties: function (prop, value) {
            if (prop == 'data') {
                this.title.setText(this.data.name);
                this.itemid.setText("<b>Код товара:</b> "+this.data.id);
                this.thumbnail.setSource(this.data.thumbnail);
                this.price.setText(this.data.price == 0 ? "" : (this.data.price * this.data.qty).toFixed(2) + ' ' + DC.Currency[this.data.currency]);
                if (this.data.allowMultiple) {
                    this.qty.setVisible(true);
                    this.count_text.setVisible(true);
                    this.qty.setValue(this.data.qty);
                } else {
                    this.qty.setVisible(false);
                    this.count_text.setVisible(false);
                }
            }
        }
    };
    DC.cart.CartItemRenderer = DC.DataRenderer.extend(DC.cart.CartItemRenderer);
    DC.cart.CartView = {
        _list: null,
        infoContainer: null,
        totalLabel: null,
        updateButton: null,
        empty_text: null,
        _ds: null,
        _updateItemsLaterList: null,
        onItemRemove: DC.NOOP,
        onItemUpdate: DC.NOOP,
        createChildren: function () {
            this._super();
            var self = this;
            this._updateItemsLaterList = {};
            this._list = new DC.Table({
                styles: 'item_table',
                width: this.width,
                itemRenderer: DC.cart.CartItemRenderer
            });
            this._ds = new DC.DataSource();
            this._list.setDataSource(this._ds);
            this._list.addEventListener(DC.cart.CartEvent.REMOVE, function (e) {
                self.onItemRemove(e.items);
            });
            this._list.addEventListener(DC.cart.CartEvent.CHANGE, function (e) {
                self._saveUpdateItems(e.items.id, e.items.qty);
            });
            this.empty_text = new DC.Text({
                styles: 'empty_text',
                text: DC.cart.lang["label_noitem"]
            });
            this.infoContainer = new DC.Container({
                styles: 'info_container',
                width: this.width
            });
            this.totalLabel = new DC.Text({
                styles: 'total_label',
                text: DC.cart.lang["label_total"]
            });
            this.updateButton = new DC.Button({
                styles: 'update_button tooltip',
                text: DC.cart.lang['button_update'],
                onClick: function () {
                    self._updateItems();
                }
            });
            this.addClass('cartview');
        },
        createComplete: function () {
            this._super();
            this.infoContainer.addChild(this.totalLabel);
            this.infoContainer.addChild(this.updateButton);
            this.addChild(this.empty_text);
            this.addChild(this._list);
            this.addChild(this.infoContainer);
        },
        commitSize: function () {
            this._super();
            this.infoContainer.setSize(this.width);
            this._list.setSize(this.width, this.height - this.infoContainer.height);
            this._list.setXY(0, 0);
            this.infoContainer.setXY(0, this.height - this.infoContainer.height);
        },
        _saveUpdateItems: function (id, qty) {
            if (id != undefined) {
                this._updateItemsLaterList[id] = qty;
            }
        },
        _updateItems: function () {
            var ids = [];
            var qtys = [];
            for (var i in this._updateItemsLaterList) {
                ids.push(i);
                qtys.push(this._updateItemsLaterList[i]);
            }
            this.onItemUpdate(ids, qtys);
        },
        update: function (controller) {
            var self = this;
            self._updateItemsLaterList = {};
            if (controller.count > 0) {
                self._list.setVisible(true);
                self.infoContainer.setVisible(true);
                self.totalLabel.setText(DC.cart.lang['label_total'] + ' <div class="amount">' +
                    controller.subTotal.toFixed(2) + '</div> <div class="currency">' +
                    DC.Currency[controller.currency] + '</div>');
                self.totalLabel.ui.css({ width: "", height: "" });
                var ids = [];
                for (var idx in controller.items) {
                    ids.push(idx);
                }
                $.ajax({
                    url: '/ajax/getprices/',
                    type: 'POST',
                    dataType: 'json',
                    data: {'ids': ids.join(',')},
                    success: function(data) {
                        for (var idx in data) {
                            controller.items[idx].price = data[idx].price;
                            controller.items[idx].price_nal = data[idx].price;
                            controller.items[idx].price_bn = data[idx].price_bn;
                        }
                        items = controller.getAllItems();
                        self._ds.load(items);
                    }
                });
            } else {
                self._list.setVisible(false);
                self.infoContainer.setVisible(false);
            }
        }
    };
    window.DC.cart.CartView = DC.Container.extend(DC.cart.CartView);
}(window));
(function (window) {
    DC.cart.OrderItemRenderer = {
        _thumbnail: null,
        _title: null,
        _qty: null,
        _price: null,
        rowContainer: null,
        createChildren: function() {
            this._super();
            var self = this;
            this.rowContainer = new DC.Container({
                styles: 'container'
            });
            this._thumbnail = new DC.Image({
                styles: 'thumbnail',
                width: 40,
                height: 40
            });
            this._title = new DC.Text({
                styles: 'title',
                width: 120
            });
            this._qty = new DC.Text({
                styles: 'qty',
                width: 32
            });
            this._price = new DC.Text({
                styles: 'price'
            });
            
            this.rowContainer.addChild(this._thumbnail);
            this.rowContainer.addChild(this._title);
            this.rowContainer.addChild(this._qty);
            this.rowContainer.addChild(this._price);

            this._qty.setVisible(false);
        },
        createComplete: function() {
            this._super();
            this.addChild(this.rowContainer);
        },
        commitSize: function() {
            this._super();
            var left = 0;
            if (this.data.thumbnail) {
                this._thumbnail.setVisible(true);
                left = this._thumbnail.width + 5;
            } else {
                this._thumbnail.setVisible(false);
            }
            this._title.ui.css({ 'left': left });
            this._qty.ui.css({ 'left': left + this._title.width + 3 });
            this._price.ui.css({ 'left': left + this._title.width + this._qty.width + 6 });
        },
        commitProperties: function(prop, value) {
            if (prop == 'data') {
                this._thumbnail.setSource(this.data.thumbnail);
                this._title.setText(this.data.name);
                if (this.data.allowMultiple) {
                    this._qty.setVisible(true);
                    this._qty.setText(this.data.qty+' x');
                } else {
                    this._qty.setVisible(false);
                }
                this._price.setText(parseFloat(this.data.price).toFixed(2) + ' ' + DC.Currency[this.data.currency]);
                this._price.setText(parseFloat(this.data.price).toFixed(2) + ' ' + DC.Currency[this.data.currency]);
            }
        }
    };
    DC.cart.OrderItemRenderer = DC.DataRenderer.extend(DC.cart.OrderItemRenderer);

    DC.cart.OrderView = {
        cartController: null,
        _form: null,
        _summary: null,
        _list: null,
        _ds: null,
        _listContainer: null,
        _delivery: null,
        _total: null,
        _updateItemsLaterList: null,
        createChildren: function () {
            var self = this;
            this._super();
            this._updateItemsLaterList = {};
            this._form = new DC.Form({
                id: 'order',
                tag: '<form id="order_form" class="float" method="POST" action="/checkout/"></form>',
                width: 400,
                labelWidth: 141,
                data: DC.cart.lang.orderform
            });
            this._summary = new DC.VBox({
                styles: 'summary'
            });
            var header = new DC.Text({
                styles: 'header',
                text: '<span class="cell detail">Товар</span><span class="cell cost">Цена</span>'
            });
            this._summary.addChild(header);
            this._list = new DC.Table({
                styles: 'table',
                itemRenderer: DC.cart.OrderItemRenderer
            });
            this._ds = new DC.DataSource();
            this._list.setDataSource(this._ds);
            this._list.addEventListener(DC.cart.CartEvent.CHANGE, function(e) {
                self._saveUpdateItems(e.items.id, e.items.qty);
            });
            this._listContainer = new DC.Container({
                styles: 'container'
            });
            this._listContainer.setClipping(true);
            this._listContainer.addChild(this._list);
            this._summary.addChild(this._listContainer);
            this._delivery = new DC.Text({
                styles: 'delivery',
                text: ''
            });
            this._summary.addChild(this._delivery);
            this._total = new DC.Text({
                styles: 'total',
                text: DC.cart.lang['label_total']+' <span class="amount">' + this.cartController.total.toFixed(2) + ' ' + DC.Currency[this.cartController.currency] + '</span>'
            });
            this._summary.addChild(this._total);
            this.addClass('orderview');
        },
        createComplete: function () {
            this._super();
            this.addChild(this._form);
            this.addChild(this._summary);
        },
        commitSize: function () {
            this._super();
            this._list.setSize(this.width, this.height);
            this._list.setXY(0, 0);
        },
        _saveUpdateItems: function (id, qty) {
            if (id != undefined) {
                this._updateItemsLaterList[id] = qty;
            }
        },
        update: function (controller) {
            var txt = '&nbsp;';
            this._updateItemsLaterList = {};
            if (controller.count > 0) {
                this._list.setVisible(true);
                if (controller.deliveryMethod == 2) {
                    var free = controller.subTotal >= controller.maxShippingValue;
                    txt = '<table><tbody><tr>' +
                        '<td class="title"><h4>' + DC.cart.lang['label_delivery'] + '</h4><div class="text"></div></td>' +
                        '<td class="cost"><div class="price">' + (free ? '<div class="uah free-uah">' : '<div class="uah">') +
                        parseFloat(controller.shipping).toFixed(2) + ' <span>' + DC.Currency[controller.currency] + '</span></div>' +
                        (free ? '<div class="free">бесплатно</div>' : '') + '</div></td></tr></tbody></table>';
                } else if (controller.deliveryMethod == 3) {
                    txt = '<p style="text-align:center;padding-top:5px;font-weight:bold;color:#333;">' + DC.cart.lang['label_service'] +'</p>';
                }
                var total = 0,
                    items = controller.getAllItems();
                for (var idx in items) {
                    var price = items[idx].qty * items[idx].price;
                    if (price > 0) {
                        total += price;
                    }
                }
                var shipping = (controller.deliveryMethod == 2) && (total < controller.maxShippingValue) ? controller.shipping : 0;
                total += shipping;
                this._total.setText(DC.cart.lang['label_total']+' <span class="amount">' + total.toFixed(2) + ' ' + DC.Currency[controller.currency] + '</span>');
            } else {
                this._list.setVisible(false);
            }
            this._delivery.setText(txt);
        }
    };
    window.DC.cart.OrderView = DC.HBox.extend(DC.cart.OrderView);
}(window));
(function (window) {
    DC.cart.PaymentView = {
        payButtonContainer: null,
        detailContainer: null,
        createChildren: function () {
            this._super();
            this.addClass('paymentview');
            this.payButtonContainer = new DC.Container({
                styles: 'pay_button_container',
                width: this.width
            });
            this.detailContainer = new DC.Text({
                styles: 'detail_container'
            });
        },
        createComplete: function () {
            this._super();
            this.addChild(this.detailContainer);
            this.addChild(this.payButtonContainer);
        },
        setSize: function (w, h) {
            this._super(w, h);
        },
        getGAScript: function (controller) {
            var result =
                'try {' +
                    'var pageTracker = _gat._getTracker("UA-390887-3"); ' +
                    'pageTracker._trackPageview(); ' +
                    'pageTracker._addTrans("' + controller.paymentOrderId + '", "portamix.com.ua", "' + controller.paymentTotalUSD + '", "0.00", "' +
                        controller.paymentShippingUSD + '", "Киев", "", "Украина"); ';
            var items = controller.getAllItems();
            for (var i=0; i<items.length; i++) {
                result += 'pageTracker._addItem("' + controller.paymentOrderId + '", "' + items[i].id + '", "' + items[i].name + '", "' +
                    items[i].cat_name + '", "' + (items[i].price / controller.paymentRate).toFixed(2) + '", "' + items[i].qty + '"); ';
            }
            result += 'pageTracker._trackTrans(); } catch(err){ console.log(err);};';
            return result;
        },
        getAdWords: function (controller) {
            var result =
                'var google_conversion_id = 1019279849;'+
                'var google_conversion_language = "en";'+
                'var google_conversion_format = "3";'+
                'var google_conversion_color = "ffffff";'+
                'var google_conversion_label = "7dzYCKep6QIQ6fOD5gM";'+
                'var google_conversion_value = 0;';
        },
        updatePayment: function (controller) {
            var currency = ' '+DC.Currency[controller.currency];
                detail = '<b>'+DC.cart.lang['label_item_thanks']+'</b><br /><br />';
            detail += DC.cart.lang['label_item_cost'].replace("%S", controller.paymentCount).replace("%A", '<b>'+controller.paymentSubTotal+'</b>'+currency)+'<br />';
            detail += DC.cart.lang['label_shipping_cost'].replace("%S", '<b>'+controller.paymentShipping+'</b>'+currency)+'<br />';
            detail += DC.cart.lang['label_total_cost'].replace("%S", '<b>'+controller.paymentTotal+'</b>'+currency)+'<br />';
            detail += '<script>'+this.getGAScript(controller)+'</script>';
            detail += '<script>'+this.getAdWords(controller)+'</script>';
            detail += '<script type="text/javascript" src="http://www.googleadservices.com/pagead/conversion.js">'+'</script>';
            detail += '<noscript>'+
                '<div style="display:inline;">'+
                '<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1019279849/?label=7dzYCKep6QIQ6fOD5gM&amp;guid=ON&amp;script=0"/>'+
                '</div>'+
                '</noscript>';
            this.detailContainer.setText(detail);
            this.payButtonContainer.ui.empty();
        }
    };
    window.DC.cart.PaymentView = DC.Container.extend(DC.cart.PaymentView);
}(window));
(function (window) {
    $.fn.extend({
        PortamixCart: function (options) {
            var defaults = { width: 700, height: 500 };
            var options = $.extend(defaults, options);
            var self = this;
            return this.each(function () {
                options.widget = self;
                self.cart = new DC.cart.Cart(options);
                for (var fn in self.cart) {
                    if (typeof self.cart[fn] == "function") {
                        var f = function () {
                            self.cart[arguments.callee.FUNCTION_NAME].apply(self.cart, arguments);
                        };
                        f["FUNCTION_NAME"] = fn;
                        self[fn] = f;
                    }
                }
                self.addBuyButton = function (target, data) {
                    $(target).click(function () {
                        self.cart.add(data);
                    });
                };
            });
        }
    });
}(window));
