/**
 *  eXpand-Collapse control
 *
 *  @author      Viknesk Kumarr Muniandy
 *  @updated     24-01-2009
 *
 */

/**
 *  XC contructor
 *
 *  @param  string|elements items Collection of items to group as expandable
 *  @param  hash options Options:
 *
 *  @return object New XC object
 */
function XC (items, options)
{
	var $this = this;
	this.items = $(items);
}
XC.prototype.callbacks = [];
XC.prototype.items = null;
XC.prototype.collapsedClass = 'collapsed';
XC.prototype.expandedClass = 'expanded';
// Public methods
XC.prototype.toggle = function (items) { this.collapseAll(items, true); this._toggle(items); }
XC.prototype.expand = function (items) { this.collapseAll(items, true); this._expand(items); }
XC.prototype.collapse = function (items) { this._collapse(items); }
XC.prototype.expandAll = function (exception, supressCallback) { this._expand (this.items.not($(exception).get()), supressCallback); }
XC.prototype.collapseAll = function (exception, supressCallback) { this._collapse (this.items.not($(exception).get()), supressCallback); }
// Private methods
XC.prototype._callback = function () { for (i in this.callbacks) this.callbacks[i](); };
XC.prototype._toggle = function (items, supressCallback) { $(items).toggleClass(this.collapsedClass).toggleClass(this.expandedClass); if (!supressCallback) this._callback(); }
XC.prototype._expand = function (items, supressCallback) { $(items).removeClass(this.collapsedClass).addClass(this.expandedClass); if (!supressCallback) this._callback(); }
XC.prototype._collapse = function (items, supressCallback) { $(items).removeClass(this.expandedClass).addClass(this.collapsedClass); if (!supressCallback) this._callback(); }

