if (typeof(eAddButtonObject) == 'undefined') 
{
    eAddButtonObject = function(productId, attributes)
    {
    	this.productId      = productId;
    	this.attributes     = attributes;
    	this.cartManager    = new eCartManagerObject('__ajaxEventUID', ajaxEventUID);
    	this.quantityObject = '#quantity';  
    	this.submitObject   = '#addbutton';  
    }
}
eAddButtonObject.prototype.init = function()
{
	var currentObject = this;
	
	$(this.quantityObject).val('');		        
	$(this.submitObject).click(function() { currentObject.submit() } );
	$(this.quantityObject).setEnterHandler(function() { currentObject.submit() } );		        
}
eAddButtonObject.prototype.submit = function()
{
	var quantity = $(this.quantityObject).val();
	//$(this.quantityObject).val('');
	var reg = /^[0-9]*$/;
	if (!reg.test(quantity) || (quantity <= 0))
	{
	    alert('Please enter a valid quantity!');
	}
	else
	{
	   var attribute = {};
	   for (i in this.attributes)
	   {
	       attribute[this.attributes[i]] =  $('#attr' + this.attributes[i]).val();
	   }
	   this.cartManager.addItem(this.productId, quantity, attribute);
	}
}
eAddButtonObject.prototype.setInfoPanel = function(infoPanelObject)
{
	this.cartManager.setInfoPanel(infoPanelObject);
}
