

var ShoppingCartItemFeatures = Class.create(
{
	expanded: false,
	
	features: [],
	
	animating: false,
	
	initialize: function( cart_item, element )
	{
		this.cart_item = cart_item;
		this.element = $( element );
		this.initDOM();
		this.initOther();
		this.initEvents();
	},
	
	initDOM: function()
	{
		this.dom = {};
		this.dom.listWrapper = this.element.down( "div" );
	},
	
	initOther: function()
	{
		// create Feature objects
	},
	
	initEvents: function()
	{
		// events
	},
	
	expand: function()
	{
		if( this.animating ) return; // ignore commands during animation
		
		this.element.addClassName( "features-active" );
		this.element.setStyle( { display: "" } );
		
		Effect.BlindDown( this.dom.listWrapper,
		{
			beforeStart: function()
			{
				this.animating = true;
			}.bind( this ),
			
			afterFinish: function()
			{
				this.animating = false;
			}.bind( this )
		});
		
		this.expanded = true;
	},
	
	collapse: function( afterCollapse, duration )
	{
		if( this.animating ) return; // ignore commands during animation
		
		this.expanded = false;
		Effect.BlindUp( this.dom.listWrapper,
		{
			duration: duration || 1.0,
			beforeStart: function()
			{
				this.animating = true;
			}.bind( this ),
			
			afterFinish: function()
			{
				this.element.removeClassName( "features-active" );
				this.element.setStyle( { display: "none" } );
				
				if( typeof afterCollapse == "function" )
					afterCollapse.call( this.cart_item );
				
				this.animating = false;
				
			}.bind( this )
		});
	},
	
	isAnimating: function()
	{
		return this.animating;
	},
	
	isExpanded: function()
	{
		return this.expanded;
	},
	
	getElement: function()
	{
		return this.element;
	},
	
	getCartItem: function()
	{
		return this.cart_item;
	}
});
