
kff.widgets.ExpandBox = function(options)
{
	this.options = $.extend({
		selector: '',
		intialState: false,
		collapsedClass: 'collapsed'
	}, options); 
};

kff.widgets.ExpandBox.prototype.init = function()
{	
	$(document).delegate(this.options.selector, 'mousedown', $.proxy(this.mouseDown, this));
	$(document).delegate(this.options.selector, 'click', function(){ return false; });
	
	this.switchBox($(this.options.selector), this.options.intialState);
	
	return this;
}

kff.widgets.ExpandBox.prototype.mouseDown = function(event)
{
	$a = $(event.currentTarget);
	
	var state = $a.hasClass(this.options.collapsedClass);
	
	this.switchBox($a, state);
	
	return false;	
}

kff.widgets.ExpandBox.prototype.switchBox = function($a, state)
{
	$targetBox = $($a.attr('href'));
	if(state)
	{
		$a.removeClass(this.options.collapsedClass);
		$targetBox.show();
	}
	else
	{
		$a.addClass(this.options.collapsedClass);
		$targetBox.hide();
	}
}

