(function($) {
	$.fn.tsaccordion_menu = function(o) {
        return this.each(function() {
        	new $.tsaccordion_menu(this, o);
        });
    };
    var defaults = {
		header: ".head"
    };
	$.tsaccordion_menu = function(e, o) {
		this.options    = $.extend({}, defaults, o || {});
		this.header=this.options.header
		this.me=$(e)
		this.height=$(e).height()
		this.max_height=0
		this.total=$('ul',this.me).size();
		var tempUL=$("ul:first",this.me)
		var tempLI=$(this.options.header+":first",this.me)
		for(var i=0; i<this.total;i++)
		{	if(this.max_height<tempUL.height())
			{	this.max_height=tempUL.height()
			}
			if(tempLI.hasClass('sel'))
			{	this.selected=tempLI
			}
			tempUL=tempUL.next()
			tempLI=tempLI.next()
		}
		$('ul',this.selected).height(this.max_height)
		$(this.me).css('height',$(this.me).height()+'px')
		var self = this;
		$(this.header,this.me).hover(function(){
			if($('ul',this).is(':visible'))
				return false
			$('ul:visible',self.me).stop().animate({height:0},'easing',function (){$(this).hide()})
			$('ul',this).height(0)
			$(self.header,self.me).removeClass('sel')
			$(this).addClass('sel')
			$('ul',this).stop().animate({height:self.max_height},'easing')
			
		},function(){
			
		})
		
	};
	
})(jQuery);

