﻿$.accordian = function(options) {
    
    options = jQuery.extend({
         titles:     '.category',
         contents:   '.list_menu',
         active:     'none',
         onClick:    function() {},
         onShow:     function() {},
         onHide:     function() {},
         showSpeed:  'slow',
         hideSpeed:  'fast'
    }, options);
    
    function activate(item){
		$(options.titles).each(function(i){
			if(item == i){
				$(this).next(options.contents).slideDown(options.showSpeed).each(options.onShow);
				//$(this).addClass('off');
			}else{
				$(this).next(options.contents).slideUp(options.hideSpeed).each(options.onHide);
				//$(this).removeClass('off');
			}
		});
	}
	
	function hidesParts(){
		$(options.contents).each(function(){
			$(this).hide();
		});
		$(options.titles).each(function(){
		    //$(this).removeClass('off');
		});
	}
	
	$(options.titles).each(function(i){
		$(this).click(function(){
		    activate(i);
		});
	});
	
	if(options.active == 'none'){
		hidesParts();
	}else{
		activate(options.active);
	}
};