var lPrev='';
var lParent='';
var lTimeout=false;

function menuOver(pEv) {
	if(pEv.srcElement) lEl=pEv.srcElement;
	else lEl=pEv.target;
	if(lTimeout) window.clearTimeout(lTimeout);
	lTimeout=setTimeout("menu(lEl)", 500);
}

function menu(pEl) {
	if(lEl=getEl(pEl, "menu_")) {
		var lBr=new Array();
		var lIndex=lEl.id.substr(5);
		if (lIndex.indexOf('_')==-1)
			lParent=document.getElementById('submenu_');
		else {
			lParent=document.getElementById('submenu_'+lIndex.substr(0, lIndex.lastIndexOf('_'))).rows[0].cells[0]; 
			if(lParent.childNodes[0].tagName=='TABLE')
				lParent=lParent.childNodes[0];
			else lParent=lParent.childNodes[1];
		}
		
		if (document.getElementById('submenu_'+lIndex) && document.getElementById('submenu_'+lIndex).style.display=='block')
			closeNode(lIndex, -1);
		openParentNode('_'+lIndex);
		
		if(lIndex.length==1 && lIndex!=lPrev && document.getElementById('submenu_'+lIndex))
			lPrev=lIndex;

		lCh=lParent.rows;
		for (var i=0;i<lCh.length;i++) {
			lC=lCh[i].cells;
			for (var j=0;j<lC.length;j++)
				if (lC[j].id.substr(0, 5)=='menu_' && lC[j].id!=lEl.id)
					lBr[lBr.length]=lC[j].id.substr(5);
		}
		for(var z=0;z<lBr.length;z++)
			if(document.getElementById('submenu_'+lBr[z]) && document.getElementById('submenu_'+lBr[z]).style.display=='block')
				closeNode(lBr[z], 1);
	}
	else if (lPrev!='') {
		closeNode(lPrev, 1);
		lPrev='';
	}
}

function closeNode(pIndex, pF) {
	if (pF==1) {
		document.getElementById('submenu_'+pIndex).style.display='none';
		document.getElementById('submenu_'+pIndex).style.visibility='hidden';	
	}
	for (var i=1; document.getElementById('menu_'+pIndex+'_'+i);i++)
		if(document.getElementById('submenu_'+pIndex+'_'+i) && document.getElementById('submenu_'+pIndex+'_'+i).style.display=='block')
			closeNode(pIndex+'_'+i, 1);
}

function openParentNode(pIndex){
	while(pIndex.indexOf('_')!=-1){
		if(e=document.getElementById('submenu'+pIndex)) {
			e.style.display='block';
			e.style.visibility='visible';
		}
		pIndex=pIndex.substr(0, pIndex.lastIndexOf('_'));
	}
}

function getEl(el, pId) {
	if(el && el.tagName) {
		while (el.tagName.toLowerCase() != "body") {
			if (el.id.substr(0, pId.length) == pId)	return el;
			if (el.id.substr(0, 8) == "submenu_" && el.id.length>8)
				el=document.getElementById(pId+el.id.substr(8));
			else	el = el.parentNode;
		}
	} return false;
}


var printwindow;
function printIt(contentId, lang) {
	var copyRightText = new Array();

	if (lang != 'en') lang='ru';
	copyRightText["ru"] = 'Библиотека Научно-исследовательского информационно-аналитического центра "ЛЕКС" <br>(www.lexltd.com.ua)';
	copyRightText["en"] = 'Library of the Scientific and Research Information Analytical Center "LEX" <br>(www.lexltd.com.ua)';

	contentTag = document.getElementById(contentId);
	printwindow = window.open("",null,"height=480,width=640,status=no,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,left=" + (screen.availWidth-640)/2 + ",top=" + (screen.availHeight-480)/2);
	printwindow.document.write('<html>');
	printwindow.document.write('<head>');
	printwindow.document.write('<title>');
	printwindow.document.write(copyRightText[lang]);
	printwindow.document.write('</title>');
	printwindow.document.write('<link rel="stylesheet" type="text/css" href="/img_0/print.css">');
	printwindow.document.write('</head>');
	printwindow.document.write('<body onLoad="window.opener.printMove();">');
	printwindow.document.write('<table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="top">');
	printwindow.document.write('<tr>');
	printwindow.document.write('<td class="title" height="31">');
	printwindow.document.write(copyRightText[lang]);
	printwindow.document.write('</td>');
	printwindow.document.write('</tr>');
	printwindow.document.write('</table>');
	printwindow.document.write('<div id="printDiv" class="printDiv">');
	printwindow.document.write('</div>');
	printwindow.document.write('</body>');
	printwindow.document.write('</html>');
	printwindow.document.close();
	return true;
}

function printMove() {
	printwindow.document.getElementById('printDiv').innerHTML = contentTag.innerHTML;
	printwindow.focus();
	printwindow.print();
}