var CartPopup = {
	init: function() {
		this.elem = {};
		this.elem.overlay = $("#cartpopup");
		this.elem.container = this.elem.overlay.find('.runner');
	},
	show: function(data) {
		this.elem.container.html(data);

        var self = this;
        $.each([$('.close', this.elem.overlay), this.elem.overlay], function(index, value) {
            value.bind('click', {obj: self}, function(e) { e.data.obj.hide(e); });
        });

        this.elem.overlay.css('display', 'block');
	},
	hide: function(e) {
        if ($(e.target).hasClass('close')) {
			e.preventDefault();
            this.elem.overlay.css('display', 'none');
            MiniCart.refresh();
        }
        return false;
	}
};

$(document).ready(function() {
	CartPopup.init();
});
