(function() {
	function MenuAnim(el) {
		var that = this;
		var noKids = el.getElementsByTagName('li').length;
		var anim = Math.round((noKids) * (((parseInt(lib.getCStyle(document.body, 'fontSize'), 10)*1.2) * 2.2)) + (noKids));
		this.el = el;
		this.cH = 0;
		lib.addEvent(that.el, 'mouseover', function() {
			clearInterval(that.timer);
			that.doAnim(anim);
 		}, false);
		lib.addEvent(that.el, 'mouseout', function() {
 			clearInterval(that.timer);
 			that.doAnim(0);
 		}, false);
	}
	MenuAnim.prototype = {
		move : function(x) {
			this.cH += x;
			lib.$(this.el.id, 'ul')[0].style.height = Math.round(this.cH) + 'px';
		},
		doAnim : function(tgt) {
			var that = this;
			this.timer = setInterval(function() {
				if (Math.round(that.cH) !== tgt) {
					that.move((tgt-that.cH) * 0.15);
				} else {
					clearInterval(that.timer);
				}
			}, 10);
		}
	};
	function init() {
		var lis = lib.$('navMain', 'li');
		for(var i = 0; i < lis.length; i++) {
			if(lis[i].getElementsByTagName('ul').length > 0) {
				var menu = new MenuAnim(lib.$(lis[i].id));
			}
		}
	}
	if (document.getElementById) {
		lib.addEvent(window, 'load', init, false);
	}
})();
