(function($) {

	$.accordion = {
		defaults: {
			maxWidth: "240",
			speed: 400
		
		}
	}
    $.fn.extend({
        accordion:function(config) {
            var config = $.extend({}, $.accordion.defaults, config);
			return this.each(function() {
			var ulId = $(this).attr("id");
			var theAccordion    = $(this), maxWidth = config.maxWidth, speed = config.speed;
			var total = $("ul#" + ulId).width();
			var children = $("ul#" + ulId).children().size();
			var midWidth = Math.floor(total / children);
			var minWidth = Math.floor(((total - maxWidth) / (children - 1))-1);
	
	
			$("ul#" + ulId + " li").css({"width" : midWidth});
		
			$("ul#" + ulId + " li").hover(function(){
				$(this).addClass("exp");
				$("ul#" + ulId + " li:not(.exp)").animate({width: minWidth + "px"}, {queue:false, duration:speed});
				$(this).animate({width: maxWidth + "px"}, {queue:false, duration:speed});
			}, function(){
				$(this).removeClass("exp");
			});

			$("ul#" + ulId).hover(function(){
				//
			}, function(){
				$("ul#" + ulId + " li").animate({width: midWidth + "px"}, speed)
			}); ;
				

			  
            })
        
        
        }
    
    })


})(jQuery);
