	
	function menu_node(parent, container) {
		this.parent = parent;
		this.container = container;
		this.sub_menu = null;
		this.sub_height = 0;
		this.bef_sub_current = 0;
		this.sub_current = 0;
		this.sub_ratio = 0;
		
		this.locked = false;
		
		this.opened = false;
		this.moving = false;
		this.bef_opacity = 0;
		this.opacity = 0;
		
		this.href = null;
		this.div = null;
		this.span = null;
	}
	
	menu_node.prototype.construct = function() {
		if (this.container.className == "menu_main") {
			var f, current, stack = new Array();
			stack[0] = this.container;
			
			while (stack.length > 0) {
				current = stack.pop();
				
				switch (current.tagName.toUpperCase()) {
					case "DIV" :
						if (current.className == "active") this.div = current;
						break;
						
					case "A" :
						this.href = current;
						break;
						
					case "SPAN" :
						if (current.className == "arrow") this.span = current;
						break;
				}
				
				if (current.childNodes.length > 0) {
					for (f = 0; f < current.childNodes.length; f++)
						if (current.childNodes[f].nodeType == 1) stack[stack.length] = current.childNodes[f];
				}
			}
			
			var self = this;
			this.container.onmouseover = function() {
				self.evt_open();
			}
			this.container.onmouseout = function(trgEvent) {
				var evt = trgEvent == null ? event : trgEvent;
				var target = evt.toElement == null ? evt.relatedTarget : evt.toElement;
				
				while (target != null && target != self.container) target = target.parentNode;
				
				if (target == null) self.evt_close();
			}
			
		} else {
			this.locked = true;
		}
	}
	
	menu_node.prototype.evt_open = function() {
		this.container.className = "menu_main menu_main_active";
		this.opened = true;
		if (!this.moving) this.sub_ratio = 0;
		this.moving = true;
		
	}
	
	menu_node.prototype.evt_close = function() {
		this.container.className = "menu_main";
		this.opened = false;
		if (!this.moving) this.sub_ratio = 0;
		this.moving = true;
	}
	
	menu_node.prototype.set_sub = function(container) {
		if (!this.locked) {
			this.sub_menu = container;
			this.sub_height = this.sub_menu.offsetHeight;
			
			if (this.parent.simple) this.sub_menu.style.display = "block";
			else this.sub_menu.style.height = "0";
			
			this.sub_current = 0;
			this.sub_ratio = 0;
			
			var self = this;
			this.sub_menu.onmouseover = this.container.onmouseover;
			this.sub_menu.onmouseout = this.container.onmouseout;
		}
	}
	
	menu_node.prototype.loop = function() {
		if (!this.locked) {
		
			this.bef_sub_current = this.sub_current;
		
			if (this.moving && this.sub_menu != null) {
				this.sub_ratio += this.opened ? 1.5 : -1.5;
				if (this.sub_ratio < -15.0) this.sub_ratio = -15.0;
				else if (this.sub_ratio > 15.0) this.sub_ratio = 15.0;
				
				this.sub_current += this.sub_ratio * (this.parent.simple ? 10000 : 1);
				if (this.sub_current < 0) {
					this.sub_current = 0;
					if (!this.opened) this.moving = false;
					
				} else if (this.sub_current > this.sub_height) {
					this.sub_current = this.sub_height;
					if (this.opened) this.moving = false;
				}
			}
			
			this.bef_opacity = this.opacity;
			this.opacity += this.opened ? 15 : -15;
			if (this.opacity < 0) this.opacity = 0;
			else if (this.opacity > 100) this.opacity = 100;
		}
	}
	
	menu_node.prototype.update = function() {
		if (!this.locked && this.sub_current != null && this.div != null && (this.opacity != this.bef_opacity || this.sub_current != this.bef_sub_current)) {
			if (this.sub_menu != null) {
				if (this.parent.simple) this.sub_menu.style.display = this.opened ? "block" : "block";
				else this.sub_menu.style.height = this.sub_current + "px";
			}
			
			if (!this.parent.simple) {
				this.div.style.display = "block";
				this.div.style.opacity = this.opacity / 100.0;
				this.div.style.filter = "Alpha(opacity=" + this.opacity + ")";
			}
		}
	}
	
	
	function menu_collector(container) {
		this.container = container;
		this.items = new Array();
		this.update_flag = false;
		this.simple = (/MSIE 6/i.test(navigator.userAgent)) || (/MSIE 7/i.test(navigator.userAgent));
	}
	
	menu_collector.prototype.construct = function() {
		var f, current, stack = new Array();
		stack[0] = this.container;
		
		var last_main = null;
		
		while (stack.length > 0) {
			current = stack.pop();
			
			if (current.tagName.toUpperCase() == "DIV") {
				switch (current.className) {
					case "menu_main menu_main_active" :
					case "menu_main" :
						last_main = new menu_node(this, current);
						last_main.construct();
						
						this.items[this.items.length] = last_main;
						break;
						
					case "menu_sub" :
						if (last_main != null) {
							last_main.set_sub(current);
							last_main = null;
						}
						break;
				}
			}
			
			if (current.childNodes.length > 0) {
				for (f = current.childNodes.length - 1; f >= 0; f--)
					if (current.childNodes[f].nodeType == 1) stack[stack.length] = current.childNodes[f];
			}
		}
	}
	
	menu_collector.prototype.loop = function() {
		var f;
		for (f = 0; f < this.items.length; f++)
			this.items[f].loop();
	}
	
	menu_collector.prototype.update = function() {
		if (!this.update_flag) {
			this.update_flag = true;
			
			var f;
			for (f = 0; f < this.items.length; f++)
				this.items[f].update();
			
			this.update_flag = false;
			
			return true;
		}
		
		return false;
	}
	