function getRelLeft(el) {
	var pos = el.offsetLeft
	while (el.offsetParent != null) { el = el.offsetParent; pos += el.offsetLeft; if (el.tagName == 'BODY') break; }
	return pos
}
function getRelTop(el) {
	var pos = el.offsetTop
	while (el.offsetParent != null) { el = el.offsetParent; pos += el.offsetTop; if (el.tagName == 'BODY') break; }
	return pos
}
function attachDecorations() {
	var sh, subEl, w, h, l, t, old, oldlength;
	var el = document.getElementById('menu').getElementsByTagName('UL').item(0).childNodes;
	for (var i = 0; i < el.length; i++) {
		if (el[i].tagName == 'LI') {
			old = el[i].getElementsByTagName('DIV');
			oldlength = old.length;
			subEl = el[i].getElementsByTagName('UL').item(0);
			if (subEl){ // если есть таки подменю
				sh = (oldlength > 0) ? old[0] : document.createElement('DIV');
				sh.className = 'shadowv';
				subEl.style.display = 'block';
				l = getRelLeft(subEl); t = getRelTop(subEl);
				w = subEl.offsetWidth; h = subEl.offsetHeight;
				subEl.style.display = '';
				sh.style.left = l + w + 'px';
				sh.style.top = t + 3 + 'px';
				sh.style.height = h + 'px';
				if (oldlength == 0) el[i].appendChild(sh);
	
				sh = (oldlength > 0) ? old[1] : document.createElement('DIV');
				sh.className = 'shadowh';
				sh.style.left = l + 3 + 'px'
				sh.style.top = t + h + 'px'
				sh.style.width = w - 3 + 'px'
				if (oldlength == 0) el[i].appendChild(sh);
			}
		}
	}
}
function hoverFix() {
	var el = document.getElementById('menu').getElementsByTagName('UL').item(0).childNodes;
	for (var i = 0; i < el.length; i++) {
		if (el[i].tagName == 'LI') {
			el[i].onmouseover = function() {
				if (window.attachEvent) this.className += " hoverfix";
				//alshur
				else {
					for (var j = 0; div_elem = document.getElementsByTagName("div").item(j); j++)
						if (div_elem.banner) div_elem.style.display = "none";
				}
			}
			el[i].onmouseout = function() {
				if (window.attachEvent) this.className = this.className.replace(new RegExp(" hoverfix\\b"), "");
				//alshur
				else {
					for (var j = 0; div_elem = document.getElementsByTagName("div").item(j); j++)
						if (div_elem.banner) div_elem.style.display = "block";
				}
			}
		}
	}
}
window.onresize = function(){
	if (document.all && document.all.item && !window.opera) location.reload(); // hey, you gotta reload if you're IE!
	else attachDecorations();
}
