BA_ROLLOVER_AS_SETTINGS['gn-rollover'] = null;
/*
document.writeln('<style type="text/css">');
document.writeln('#info-area { visibility: hidden; }');
document.writeln('</style>');
*/
//if( /*@cc_on!@*/false){
	BAAddOnload(initGlobalNav);
//}else{
//	$(initGlobalNav);
//}
function initGlobalNav(){
	function changeStatus(node, status) {
		if (!node || !node.src) return;
		node.src = node.src.replace(/(_[a-z]+)?(\.[a-z]+)$/, function(){ return (status || "") + arguments[2] });
	}

	$("#global-nav>li")
		.find("em>img")
			.each(function(index, node){
				changeStatus(node, "_s");
			}).end()
		.find("a>img")
			.mouseover(function(e){
				changeStatus(this, "_o");
			})
			.mouseout(function(e){
				changeStatus(this, "");
			}).end()
		.find("ul")
			.mouseover(function(e){
				var target = e.relatedTarget;
				while (target) {
					if (target === this) {
						return true;
					}
					target = target.parentNode;
				}
				changeStatus($(this).parents("li:first").find("a:first>img")[0], "_a");
			})
			.mouseout(function(e){
				var target = e.relatedTarget;
				while (target) {
					if (target === this) {
						return true;
					}
					target = target.parentNode;
				}
				changeStatus($(this).parents("li:first").find("a:first>img")[0], "");
			}).end()
		.each(function(index, node){
			var ul = $(node).find("ul");
			if (!ul.length) return true;

			var defaultHeight = ul.height();
			ul.css("opacity", "0").css("overflow", "hidden").height(0).hide();
			$(node)
				.bind("mouseover", function(e){
					var target = e.relatedTarget;
					while (target) {
						if (target === this) {
							return true;
						}
						target = target.parentNode;
					}
					var ul = $(node).find("ul").css("visibility", "visible");
					ul.stop().animate({
						height: defaultHeight + "px",
						opacity: 1
					}, 200);
				})
				.bind("mouseout", function(e){
					var target = e.relatedTarget;
					while (target) {
						if (target === this) {
							return true;
						}
						target = target.parentNode;
					}
					var ul = $(node).find("ul");
					ul.stop().animate({
						height: "0px",
						opacity: 0
					}, 200, function(){
						ul.css("visibility", "hidden");
					});
				});
		});

	if (window.SB3C_HOME_BANNERS) {
		var infoArea = $("#info-area");
		var infoLists = infoArea.find("ul.info-list");
		var totalRemain = SB3C_HOME_BANNERS.limit;
		$.each(SB3C_HOME_BANNERS.groups, function(index, group){
			if (index >= infoLists.length) {
				return false;
			}

			var list = $(infoLists[index]);
			if (totalRemain <= 0) {
				list.remove();
				return true;
			}

			var listItems = list.find("li");
			if (!listItems.length) {
				list.remove();
				return true;
			}

			listItems = $.makeArray(listItems);

			var remain = group.limit;
			if (!group.limit && totalRemain < listItems.length) {
				listItems.sort(function(){
					return Math.ceil(Math.random() * 2) - 1;
				});
				$.each(listItems, function(index, node){
					list.append(node);
				});
			}

			$.each(listItems, function(index, node){
				if ((group.limit > 0 && remain <= 0) || totalRemain <= 0) {
					$(node).remove();
					return true;
				}
				remain--;
				totalRemain--;
			});
		});
		infoArea.css("visibility", "visible");
	}
}

