(function($) {

    $.shoppingBag = function(options) {
        return $.shoppingBag.impl.init(options);
    };

    $.fn.shoppingBag = function(options) {
        return $.shoppingBag.impl.init(this, options);
    };

    /*
    * default options
    */
    $.shoppingBag.defaults = {
    
    
};

$.shoppingBag.impl = {

    /*
    * options
    */
    opts: null,

    /*
    * helper
    */
    helper: {},

    /*
    * product id
    */
    productId: null,

    /*
    * Initialize the page
    */
    init: function(options) {

        var self = this;

        this.opts = $.extend({}, $.shoppingBag.defaults, options);

        return self;
    },

    /*
    * Adds the product to the shopping bag
    */
    addProduct: function(productId, sizeCode, variantCode, quantity, folderCrumb, callback) {

        var self = this;
        
        CreateThe.Com.Web.CodeBase.WebServices.ShoppingBagService.AddProduct(productId, sizeCode, variantCode, quantity, self.opts.folderId, folderCrumb, self.opts.root, self.opts.lang, self.opts.region, self.opts.priceCode, self.opts.exceptionId, $.shoppingBag.impl.addProductSuccess, $.shoppingBag.impl.postFailure, callback);

        return;
    },

    /*
    * addProductSuccess 
    */
    addProductSuccess: function(data, callback) {

        var self = $.shoppingBag.impl;

        if (callback != null)
            callback(data);

        return;
    },

    /*
    * POST failure
    */
    postFailure: function() {

        alert('An error has occurred. Please try again.');

    }

};
})(jQuery);
