function initPage() {
	var nav = document.getElementById("menu");
	if (nav) {
		var _ie6 = false;
		if (document.all && !window.opera) _ie6 = true;
		
		var _minWidth = 165;
		var _paddings = 25;
		
		// set width ***********************************************************
		var _elForWidth = document.createElement("span");
		document.body.appendChild(_elForWidth);
		_elForWidth.style.position = 'absolute';
		_elForWidth.style.top = '-9999px';
		_elForWidth.style.visibility = 'hidden';
		_elForWidth.style.whiteSpace = 'nowrap';
		_elForWidth.style.textTransform = 'uppercase';
		_elForWidth.style.fontSize = '10px'
		
		function setWidth() {
			var _links = nav.getElementsByTagName("a");
			for (var i=0; i<_links.length; i++) {
				if (_links[i].parentNode.parentNode == nav) continue;
				else {
					var _ul = _links[i].parentNode.parentNode;
					_elForWidth.innerHTML = _links[i].innerHTML;
					_links[i].rel = _elForWidth.offsetWidth;
					if (_elForWidth.offsetWidth > _minWidth) {
						_ul.style.width = _minWidth + 'px';
					}
				}
			}
			for (var i=0; i<_links.length; i++) {
				if (_links[i].parentNode.parentNode == nav) continue;
				else {
					var _ul = _links[i].parentNode.parentNode;
					_ul.w = parseInt(_ul.style.width.replace('px',''));
					_links[i].w = parseInt(_links[i].rel);
					if (_links[i].w > _ul.w) {
						_ul.style.width = _links[i].w+_paddings + 'px';
					}
					_ul.w = parseInt(_ul.style.width.replace('px',''));
					if (_links[i].parentNode) {
						var _subUl = _links[i].parentNode.getElementsByTagName("ul")[0];
						if (_subUl && _ul.w) {
							_subUl.style.left = _ul.w+'px';
						}
					}
				}
			}
		}
		setWidth();
		
		//**********************************************************************
		
		var nodes = nav.getElementsByTagName("li");
		for (var i=0; i<nodes.length; i++) {
			nodes[i].onmouseover=function() {
				if (_ie6) this.className+=" hover";
			}
			nodes[i].onmouseout=function() {
				if (_ie6) this.className=this.className.replace(new RegExp(" hover\\b"), "");
			}
		}

	}
	
}
if (window.addEventListener)
	window.addEventListener("load", initPage, false);
else if (window.attachEvent)
	window.attachEvent("onload", initPage);


