var MicoLeftMenu = Class.create();
MicoLeftMenu.prototype = {
	initialize: function(config) {
		this.config = config;
		this.noneClass = 'moremenu';
		this.load();
	},
	load:function(){
		var countChild	=0;
		var countParent =0;
		var countMax = 5;
		$$('.col-left ul.nav-sidebox li.level0').each(function(parent){
			countParent++;
			countChild = 0;
			parent.select('li').each(function(child){
				//i++;
				countChild++;
				if (countChild > countMax)
					child.addClassName(this.noneClass);
				// element.addClassName("hidden");
			}.bind(this));	
			if (countChild > countMax){
				var title = parent.down('span').innerHTML;
				var classNames = parent.classNames().inspect();
				var className = '';
				parent.classNames().each(function(cls){
					if (cls.indexOf('nav-') > -1) className = cls;
				});
				//alert(className);
				new Insertion.Bottom(parent, '<li class="level1 browseAll"><a href="#" onclick="return micoLeftMenu.openMicoLeft(\'' + className + '\');";>Browse all ' + title + '</a></li>');
			}
			//alert("countChild=" + countChild);
		}.bind(this));
		//alert("countParent=" + countParent);
	},
	openMicoLeft : function(cls){
		$$('.col-left ul.nav-sidebox li.' + cls + ' .' + this.noneClass).each(function(child){
			child.removeClassName(this.noneClass);
		}.bind(this));	
		$$('.col-left ul.nav-sidebox li.' + cls + ' li.browseAll').each(function(child){
			child.remove();
		}.bind(this));
		return false;
	}
}
