function showMenu(obj) {
	obj.parentNode.getElementsByTagName("a")[0].className = "hover";
	var divs = obj.parentNode.getElementsByTagName("div");
	if (divs.length > 0)
		divs[0].style.display = "block";
}

function hideMenu(obj) {
	//return;
	obj.parentNode.getElementsByTagName("a")[0].className = "";
	var divs = obj.parentNode.getElementsByTagName("div");
	if (divs.length > 0)
		divs[0].style.display = "none";
}

function adjustLines() {
	arrHr = document.getElementsByTagName("hr");
	
	for (var i = 0; i < arrHr.length ; i++) {
		if ((arrHr[i].parentNode.className != "line-gray") && (arrHr[i].parentNode.className != "line-blue"))
			jQuery(arrHr[i]).wrap('<div class="line-gray"></div>');
	}
}

function adjustMenuRight() {
	var submenu = document.getElementById("submenu");
	if (submenu != null) {
		height = getPageSize()["sizeContent"];
		submenu.getElementsByTagName("ul")[0].style.height = (height-300)+"px";
	}
}

function adjustMenuWidth() {
	var nLis = jQuery('#menu > li').length;
	var totalWidth = jQuery('#menu').width(); 
	totalWidth = 1000;
	var newWidth = parseInt(totalWidth / nLis) - 1;
	var dif = totalWidth % nLis;
	
	jQuery('#menu > li:not(:last)').width(newWidth);
	jQuery('#menu > li:not(:last)').each(function () {
		jQuery(this).find('div.submenu').each(function (i) {
			jQuery(this).width(newWidth - 1);
			
			jQuery(this).find('ul > li').width(newWidth - 1);
			jQuery(this).find('ul > li > a').width(newWidth - 8);
			if (i > 0) {
				jQuery(this).css('left', newWidth - 8);
			}
		});
	});
	
	jQuery('#menu > li:last').width(newWidth + dif);
	jQuery('#menu > li:last').each(function () {
		jQuery(this).find('div.submenu').each(function (i) {
			
			jQuery(this).width(newWidth - 1 + dif);
			jQuery(this).find('ul > li').width(newWidth - 1 + dif);
			jQuery(this).find('ul > li > a').width(newWidth - 8 + dif);
			
			if (i > 0) {
				jQuery(this).css('left', newWidth - 8 + dif);
			}
		});
	});
	
	jQuery('#menu > li:last').css('border', 'none');
}

jQuery(document).ready(function(){
	adjustLines();
	adjustMenuRight();
	adjustMenuWidth();
});