var bwIE60 = (navigator.appVersion.indexOf("MSIE 6.0") != -1) ? "True" : "False";
var bwIE70 = (navigator.appVersion.indexOf("MSIE 7.0") != -1) ? "True" : "False";

$(document).ready(function () {
	// top menu
	$(".hlbMenuMain li").each(function () {
		// menu SHOW
		$(this).mouseenter(function () {
			$("a:first", this).toggleClass("hlbMenuMainSelected");
			var menuWidth = $(this)[0].parentNode.offsetWidth;
			var aWidth = $("a:first", this)[0].offsetWidth;
			var offset = $("a:first", this)[0].offsetLeft;
			if (bwIE60 == "True" || bwIE70 == "True") {
				offset = this.offsetLeft;
				menuWidth = this.parentNode.offsetWidth;
			}
			var offsetRight = menuWidth - (offset + aWidth);
			$("div:first", this).css("right", offsetRight + "px");
			$("div:first", this).show();
		});
		// menu HIDE
		$(this).mouseleave(function () {
			$("div:first", this).hide();
			$("a:first", this).toggleClass("hlbMenuMainSelected");
		});
	});

	// model menu
	$(".mmMenuMain li", this).each(function () {
		// menu SHOW
		$(this).mouseenter(function () {
			$("a:first", this).toggleClass("mmMenuMainSelected");
			$("div:first", this).show();
			var aWidth = $("a:first", this)[0].offsetWidth;
			var offset = $("a:first", this)[0].offsetLeft;
			var width = $("div:first", this)[0].offsetWidth;
			if (bwIE60 == "True" || bwIE70 == "True") {
				offset = this.offsetLeft;
			}
			var offsetRight = 900 - (offset + aWidth);
			if ((offset + aWidth) - width < 0) {
				offsetRight = 900 - width;
			}
			$("div:first", this).css("right", offsetRight + "px");
		});
		// menu HIDE
		$(this).mouseleave(function () {
			$("div:first", this).hide();
			$("a:first", this).toggleClass("mmMenuMainSelected");
		});
	});
});

