function showChildUl(obj, width) {
	obj.firstChild.firstChild.style.background = "right url('img/menu_li_background_hover.jpg?72338006a3ed642e2be9879d38dd6ea7') #FF7D00 repeat-y ";
	id_base = obj.id.slice(6);
	if (document.getElementById('menuUl' + id_base)) {
		document.getElementById('menuUl' + id_base).style.display = 'block';
		document.getElementById('menuUl' + id_base).style.visibility = 'visible';
		document.getElementById('menuUl' + id_base).style.left = width + 'px';
		document.getElementById('menuUl' + id_base).style.top = '0px';
	}
}
function hideChildUl() {
	this.firstChild.firstChild.style.background = "right #FF7D00 repeat-y url('img/menu_li_background.jpg?ad83962efcee144516e30f185441fd0c') ";
	id_base = this.id.slice(6);
	if (document.getElementById('menuUl'+ id_base)) {
		document.getElementById('menuUl'+ id_base).style.display = 'none';
	}
}
function scrollThis(obj) {
text = obj.innerHTML;
odn = obj;
interval = setInterval("if (j + max_length <= text.length) {k = j; odn.innerHTML = text.slice(j, j + max_length); j++; } else {clearInterval(interval);}", 100);
odn.onmouseout = stopScrolling;
}

function stopScrolling() {
clearInterval(interval);
j = 0;
this.innerHTML = text;
}

function makeMenu() {
	if (document.getElementById('menu')) {
		var menu = document.getElementById('menu');

		var width = menu.clientWidth; //Pomiar szerokości
		
		allLi = menu.getElementsByTagName('li');
		
		for (i=0; i<allLi.length; i++) {
			allLi[i].onmouseover = function() {showChildUl(this, width)};
			allLi[i].onmouseout = hideChildUl;
			id_base = allLi[i].id.slice(6);
			var anchor = document.getElementById("odnosnik" + id_base);
			
			if (i == 0) { //Pomiar ilości znaków
				anchor_text = anchor.innerHTML;
				test_text = "m ";
				anchor.innerHTML = test_text;
				anchor_height = anchor.offsetHeight;
				max_length = 0;
				while (max_length == 0) {
					test_text = test_text + "m ";
					anchor.innerHTML = test_text;
					if (anchor.offsetHeight != anchor_height) {
						max_length = anchor.innerHTML.length - 1; 
						anchor.innerHTML = anchor_text;
					}
				}
			}
			
			if (anchor.offsetHeight >= 1.5 * anchor_height) { //Pomiar wysokości odnośnika dla potrzeb przewijania jego tekstu
				j=0;
				anchor.onmouseover = function() {scrollThis(this)};
			}
		}
		
		allUl = menu.getElementsByTagName('ul');
		for (i=0; i<allUl.length; i++) { //Ukrywanie podrzędnych list (nie są ukrywane w pliku css ponieważ ukrytym nie da się zmierzyć wysokości)
			if (allUl[i].className == 'hiddenUl') {
				allUl[i].style.display = 'none';
			}
		}
	}
}
