AddToCartMultipleRequest = Class.create();

AddToCartMultipleRequest.prototype = {

    initialize: function(url, errorMsgDiv) {
        this.url = url;
        this.errorMsgDiv = errorMsgDiv;
        this.onSuccess = this.processResponse.bindAsEventListener(this);        
    },
    submit : function(frmName)
    {
        this.myForm = frmName;
        var request = new Ajax.Request(
            this.url,
            {
                method: 'post',
                onSuccess: this.onSuccess,
                parameters: Form.serialize(frmName)
            }
        );
    },
    processResponse: function(transport)
    {
        if (transport && transport.responseText)
        {
            try
            {
                response = eval('(' + transport.responseText + ')');
                
                if (response.failed)
                {
                    $(this.errorMsgDiv).innerHTML = response.errorMessage;
                    Element.show(this.errorMsgDiv);
                }
                else if (response.pageRegions)
                {
                    var myhtml;
                    
                    myhtml = "<div id=\"popup_addtobasket_inner_mult\">";
                    myhtml += "<img src=\"/images/indicator.gif\" />Processing request...";
                    myhtml += "</div>";
                    Modalbox.show(myhtml, {width: 600}, {height: 300});
                }
            }
            catch (e)
            {
                response = {};
            }
        }
    }
}

