function taddToBucketForm(productId, formId, urlPrefix) {
    this.productId  = productId;
    this.formId     = formId;
    this.urlPrefix  = urlPrefix;
    this.init();
}


taddToBucketForm.prototype = {


    productId   : null,
    formId      : null,
    label       : null,
    form        : null,
    urlPrefix   : null,



    init: function() {
        this.label = $("#product-added-label-" + this.productId);
        this.form = $("#" + this.formId);
        this.bindForm();
    },



    bindForm: function() {
        var self = this;
            self.form[0].onsubmit = function() {
                var params = {};

                $("input", this).each(function () {
                    params[this.name] = this.value;
                });
                $("select", this).each(function () {
                    params[this.name] = this.value;
                });
                var form = $(this);
                    form.setLoading();

                $.post(this.action, params, function(data) {
                    form.setLoading(false);
                    
                    if (data && data.length)
                        alert(data);
                    else {
                        self.showLabel();
                        self.updateBucketStateForm();
                    }
                    
                });
                return false;
            };
    },



    showLabel: function() {
        var self = this;
        var hideLabel = function() {
            self.hideLabel();
        }
        setTimeout(hideLabel, 3000);
        self.label.css("display", "block");
    },
    


    hideLabel: function() {
        var self = this;
            self.label.css("display", "none");
    },


    updateBucketStateForm: function () {
        $.post(this.urlPrefix + "module/Catalog/Bucket/bucket-status", function(data) {
            $("#bucketStateBox").html(data);
        });
    }



}

