if (KIOS == undefined ) {
	var KIOS = {};
}

/**
 * id - id of the container
 * options - heights of item {'small':xx, 'normal':yy, 'full':zz}
 */
KIOS.menuInitNew = function(id, options) {

	if (!$(id)) {
		return;
	}

	var szNormal = options.normal;
	var szSmall = options.small;
	var szFull = options.full;

	var active = false;

	if ($$('#' + id + ' .active').length != 0) {
		active = true;
	}

	var kwicks = $$('#' + id + ' .list');
	if (!kwicks) {
		return;
	}
	var fx = new Fx.Elements(kwicks, {wait: false, duration: 300, transition: Fx.Transitions.Back.easeOut});

	kwicks.each(function(kwick, i) {

		if (active) {
			if (kwick.hasClass('active')) {
				kwick.setStyle("height", szFull);
			} else {
				kwick.setStyle("height", szSmall);
			}
		} else {
			kwick.setStyle("height", szNormal);
		}


		kwick.addEvent("mouseenter", function(event) {
			var o = {};		
			o[i] = {height: [kwick.getStyle("height").toInt(), szFull]}
			kwicks.each(function(other, j) {
				if(i != j) {
					var w = other.getStyle("height").toInt();
					if(w != szSmall) o[j] = {height: [w, szSmall]};
				}
			});
			fx.start(o);
		});
	});



	$(id).addEvent("mouseleave", function(event) {
		var o = {};
		kwicks.each(function(kwick, i) {
			if (active) {
				if (kwick.hasClass('active')) {
					o[i] = {height: [kwick.getStyle("height").toInt(), szFull]};
				} else {
					o[i] = {height: [kwick.getStyle("height").toInt(), szSmall]};
				}
			} else {
				o[i] = {height: [kwick.getStyle("height").toInt(), szNormal]}
			}
		});
		fx.start(o);
	});
}

window.addEvent('domready', function() {	
	KIOS.menuInitNew('leftmenu', {'normal':148, 'small':148, 'full':310});
	KIOS.menuInitNew('rightmenu', {'normal':33, 'small':25, 'full':95});
	}
);