function initMenu() {
	var menu = document.getElementById('menu');
	var items = menu.getElementsByTagName('TD');
	var section = location.href.split(location.host)[1].replace('index.html', '').replace('/eng','');				
	var submenuImg = document.images['submenu'];
	var prev = null;
	var prevChild = null;
	
	document.body.onmousemove = checkTarget;
	
	preload();
	
	for(var i=0; i<items.length - 1; i++) {								
		var link = items[i].getElementsByTagName('A')[0].href.split(location.host)[1];		
		var img = items[i].getElementsByTagName('IMG')[0];
		
		var part1 = link.substring(1).split('/')[0];				
		if(part1 == 'eng') part1 = link.substring(5).split('/')[0];
		var children = document.getElementById(part1);
		if(children) {
			if(section.indexOf(part1) != -1) {				
				hover(items[i]);
				hover2level(children, section, img);
			}
			items[i].getElementsByTagName('A')[0].onmouseover = show;
		} else if(section.indexOf(part1) != -1) {				
			img.src = img.src.replace('.gif', '-a.gif');
			items[i].getElementsByTagName('A')[0].onmouseover = hide;
		} else items[i].getElementsByTagName('A')[0].onmouseover = hide;
	}			
	
	function preload() {
		var images = new Object();
		for(var i=0; i<items.length - 1; i++) {			
			images[i] = new Image();
			images[i].src = items[i].getElementsByTagName('IMG')[0].src.replace('.gif', '-h.gif');;
		}
	}
	
	function show() {						
		var sectionName = this.href.split(location.host)[1].substring(1).split('/')[0];		
		if(sectionName == 'eng') sectionName = this.href.split(location.host)[1].substring(5).split('/')[0];
		var children = document.getElementById(sectionName);
			 
		if(children) {
			if(prev && prev.href != this.href) {hide(prev,prevChild);}
			
			hover(this.parentNode);			
			children.style.display = 'block';
			this.getElementsByTagName('IMG')[0].style.backgroundColor = '#FF8A00';
			/*if(sectionName == 'about') {
				submenuImg.parentNode.style.visibility = 'hidden';
			} else*/ 
			
//			if(submenuImg.src.indexOf('-y.gif') == -1) {
//				submenuImg.parentNode.style.visibility = 'visible';
//				submenuImg.src = submenuImg.src.replace('.gif', '-y.gif');
//			}
			
			prev = this;
			prevChild = children;
		}							
	}
	
	function hide() {
		if(prev) {
			if(prevChild) {prevChild.style.display = 'none';}
			var part1 = section.substring(1).split('/')[0];			
			(part1 == '') ? part1 = 'null' : part1;
			var img = prev.getElementsByTagName('IMG')[0];
			img.style.background = 'transparent';
			//submenuImg.parentNode.style.visibility = 'visible';
			//submenuImg.src = submenuImg.src.replace('-y.gif', '.gif');						
			if(prev.href.replace(location.host).indexOf(part1) == -1) {
				img.src = img.src.replace('-h.gif', '.gif');
				//img.height = 29;
				//prev.parentNode.style.verticalAlign = '';				
			}			
		}				
		if(this.tagName == 'A') {hover(this.parentNode); prev = this;}
	}
	
	function hover(node) {
		var img = node.getElementsByTagName('IMG')[0];				
		if(img.src.indexOf('-h.gif') == -1 && img.src.indexOf('-a.gif') == -1) {
			//partnode.style.verticalAlign = 'bottom';		
			img.src = img.src.replace('.gif', '-h.gif');
			//img.height = 34;
		}
	}
	
	function hover2level(children, section) {
		var items = children.getElementsByTagName('A');		
		for(var i=0; i<items.length; i++) {
			if(section.indexOf(items[i].href.split(location.host)[1].replace('/eng','')) != -1 && section.split('/').length > 3) {
				items[i].firstChild.src = items[i].firstChild.src.replace('.gif', '-a.gif');
			}
		}
	}
	
	var mousePos = {x:0, y:0};
	var t = null;	
	var rect = {x1:parseInt((document.body.offsetWidth-948)*.5), y1:22, x2:0, y2:87};
	rect.x2 = 948 + rect.x1;
	
	function checkTarget(e) {	
		e = (e) ? e : window.event;
		
		mousePos.x = e.clientX;
		mousePos.y = e.clientY;
			
		if(!inRect()) {
			if(!t)	t = setTimeout(tryHide, 1000);
		}
	}
	
	function tryHide() {	
		clearTimeout(t);
		t=null;		
		if(!inRect()) {
			hide();		
		}	
	}
	
	function inRect() {	
		return ((mousePos.x > rect.x1 && mousePos.x < rect.x2) && (mousePos.y > rect.y1 && mousePos.y < rect.y2))
	}
}