var ToggleBlind = Class.create({
	initialize: function(header, body) {
		
		// Get options
		this.options = Object.extend({
			startOpen:		false
		}, arguments[2] || {} );
		
		// Set member variables
		this.header  = $(header);
		this.body    = $(body);
		this.height  = this.body.getHeight();
		
		// Setup header
		this.header.setStyle({cursor: 'pointer'});
		
		// Set the body to zero height and show
		if(this.options.startOpen === false)
		{
			this.state = ToggleBlind.STATE_CLOSED;
			this.body.setStyle({height: '0px', overflow: 'hidden'});
			this.body.show();
		}
		else
		{
			this.state = ToggleBlind.STATE_OPEN;
			this.body.setStyle({overflow: 'hidden'});
			this.body.show();
		}
		
		// Bind events
		this.bonClick = this.toggle.bindAsEventListener(this);
		
		// Create events
		this.header.observe('click', this.bonClick);
	},
	
	toggle: function(event) {
		
		event.stop();
		switch(this.state)
		{
		case ToggleBlind.STATE_CLOSED:
			this.open();
			break;
		case ToggleBlind.STATE_OPEN:
			this.close();
			break;
		case ToggleBlind.STATE_ACTIVE:
			
			break;
		}
	},
	
	open: function() {
		this.state = ToggleBlind.STATE_OPEN;
		this.body.setStyle({height: this.height+'px'});
	},
	
	close: function() {
		this.state = ToggleBlind.STATE_CLOSED;
		this.body.setStyle({height: '0px'});
	}
});

// Create state constants
ToggleBlind.STATE_CLOSED = 0;
ToggleBlind.STATE_OPEN   = 1;
ToggleBlind.STATE_ACTIVE = 2;
