/** Accordion menu
 * @author danyastuff
 * @version 1.1 (since 24 aug 2009)
 */
 
var Accordion = function (set) {
	var self = this,
		def  = {menu: '#menu', up: 'fast', down: 'fast'}
	this.set = $.extend(def, set)
	this.menu = $(set.menu) // UL > LI > SPAN, UL > LI
	
	this.title = this.menu.find('SPAN')
	this.branches = this.menu.find('UL')
		
	this.title.click(function (e) {
		if (this == self.prev) {
			self.branches.slideUp(self.set.up)
			self.prev = null
		} else {
			self.branches.slideUp(self.set.up)
			$(this.parentNode).find('UL').slideDown(self.set.down)
			self.prev = this
		}
	})
}

Accordion.prototype = {
	expandBy : function (selector) {
		this.branches.slideUp(this.set.up)
		this.menu.find('LI:has('+ selector +') > UL').slideDown(this.set.down)
	}
}