function mainMenu_top_arr(a) {
	var arr = null;
	switch (a) {
		case 0:

			arr = $.makeArray();
			//arr = $.makeArray(["Prodotti & Listini|/macrocategory.asp"]);
			var productList = productListArray.split(", ");
			for (var i=0; i<productList.length; i++) {
				var macrocategory = "";
				var product = productList[i].split("|")
				macrocategory += product[0] + "|/series.asp?m=" + product[1];
				arr.push(macrocategory);
			}
			//$.unique(arr);
			arr = $.merge(["Prodotti & Listini|/macrocategory.asp"], arr);
			break;
		case 1:
			//arr = $.makeArray(["Special", "ASUS Slogan|/slogan.asp", "Assicurazione Kasko|/kasko.asp", "ASUS Business|/asusBusiness.asp", "Republic of Gamers|/rog.asp", "Catalogo ASUS focus|/flyer.asp?f=focus", "Tech in School|/techinschool/techinschool.asp", "Zero Bright Dot (ZBD)|/special/zeroBrightDot.asp"]);
			arr = $.makeArray(["Special", "ASUS Slogan|/slogan.asp", "Assicurazione Kasko|/kasko.asp", "ASUS Business|/asusBusiness.asp", "Eventi ASUS|/eventsPage/", "Republic of Gamers|/rog.asp", "Catalogo ASUS focus|/flyer.asp?f=focus", "Zero Bright Dot (ZBD)|/special/zeroBrightDot.asp"]);
			break;
		case 2:
			arr = $.makeArray(["Dove comprare|/wtb.asp"]);
			break;
		case 3:
			arr = $.makeArray(["Rivenditori|/partner.asp?riv=1", "Registrati come rivenditore|/subscription_DL.asp", "Accedi all'area rivenditori|javascript:createLogin();"]);
			break;
		case 4:
			arr = $.makeArray(["Supporto|/service.asp", "Contatti assistenza|/service.asp", "Centri di riparazione|/laboratories.asp", "Download|http://support.asus.com/download/download.aspx", "Zero Bright Dot (ZBD)|/special/zeroBrightDot.asp"]);
			break;
		case 5:
			if (loginSession != "") {
				arr = $.makeArray(["Logout|/logout.asp"]);
			} else {}
			break;
		case 6:
			arr = $.makeArray(["Registrati|/subscription.asp"]);
			break;
	}
	return arr;
}




function mainMenu_top(j, id) {
	var menu_checkSlide = false;
	var arr = mainMenu_top_arr(j);
	if (arr == null) {return false;}
	var inMenuHeight = 23;
	var newMenu = null;
	var menu_DIV = null;
	var menu_UL = null;
	var menu_LI = null;
	var menu_A = null;
	var menu_DIV_A = null;
	var divId = id+"_"+j;


	$.each(arr, function(i, v) {
		var timeout = null;
		menu_LI_width = "150px";
		menu_A_width = "125px";
		newMenu = this.split("|");
		if (i == 0) {
			menu_DIV = $("<div rel='"+$("#"+id+" div").size()+"' id='"+divId+"'>");
			$(menu_DIV).css("float", "left");
			$(menu_DIV).css("syleFloat", "left");
			$(menu_DIV).css("cssFloat", "left");
			$(menu_DIV).css("position", "relative");
			$(menu_DIV).css("top", "0px");
			$(menu_DIV).css("display", "block");
			$(menu_DIV).css("height", "40px");
			$(menu_DIV).css("margin", "1px 0px 0px 0px");
			$(menu_DIV).css("padding", "0px 0px 0px 0px");
			$(menu_DIV).css("z-index", "1");

			$(menu_DIV).hover(
				function(){
					if (menu_checkSlide) {return false;}
					timeout = setTimeout(function() {

						$(menu_DIV).children(0).css("color", "#81b2e9");
						if ((arr.length > 1) && (!menu_checkSlide)) {
							$(menu_DIV).children("a").css("background", "url(/images/template/topMenuToOpen_ON.png) no-repeat 0px 0px");
							menu_checkSlide = true;
							if (j > 0) {
								var fixLeftUL = 0
								var fixLeftDIV = $("#"+id+" div");
								if (fixLeftDIV.size() > 1) {
									$.each(fixLeftDIV, function(i){
										if (i < Math.round($("#"+divId).attr("rel"))) {
											fixLeftUL += $(this).width();
										}
									});
								}
								$(menu_DIV).children("ul").css("left", "-"+fixLeftUL.toString()+"px");
							}
							$(menu_DIV).children("ul").animate({height:Math.round(Math.round((arr.length)/4)*25)+10}, 200, function(){
								//menu_checkSlide = false;
							});
						}
					}, 0);

				},
				function() {
					clearTimeout(timeout);
					timeout = setTimeout(function() {

						$(menu_DIV).children(0).css("color", "#cccccc");
						if (arr.length > 1) {
							$(menu_DIV).children("a").css("background", "url(/images/template/topMenuToOpen.png) no-repeat 0px 0px");
							menu_checkSlide = true;
							$(menu_DIV).children("ul").animate({height:0}, 200, function(){
								menu_checkSlide = false;
							});
						}

					}, 0);

				}
			);
			$(menu_DIV).appendTo($("#"+id));

			menu_DIV_A = $("<a>");
			$(menu_DIV_A).css("float", "left");
			$(menu_DIV_A).css("syleFloat", "left");
			$(menu_DIV_A).css("cssFloat", "left");
			$(menu_DIV_A).css("text-align", "left");
			$(menu_DIV_A).css("height", "40px");
			$(menu_DIV_A).css("line-height", "40px");
			$(menu_DIV_A).css("font-weight", "bold");
			$(menu_DIV_A).css("font-size", "11px");
			$(menu_DIV_A).css("color", "#cccccc");
			$(menu_DIV_A).css("margin", "0px 5px 0px 5px");
			$(menu_DIV_A).css("padding", "0px 5px 0px 5px");
			$(menu_DIV_A).css("text-decoration", "none");
			$(menu_DIV_A).css("cursor", "pointer");

			if (newMenu[1] != null) {
				if (newMenu[1].substring(0, 7) == "http://") {
					$(menu_DIV_A).attr("target", "_blank");
				} else {
					$(menu_DIV_A).attr("href", "_top");
					$(menu_DIV_A).bind("click", function(){
						createLoadingPage();
						$(this).next().animate({height:0}, 200, function(){});
					});
				}
				$(menu_DIV_A).attr("href", newMenu[1]);
			}

			$(menu_DIV_A).text(newMenu[0]);
			$(menu_DIV_A).appendTo(menu_DIV);
			if (arr.length > 1) {
				$(menu_DIV_A).css("background", "url(/images/template/topMenuToOpen.png) no-repeat 0px 0px");
				//$(menu_DIV_A).css("background", "url(/images/template/topMenuToOpen.png) no-repeat "+Math.round((($(menu_DIV_A).width()+10)/2)-20).toString()+"px 0px");
			}
			menu_UL = $("<ul>");
			$(menu_UL).css("position", "absolute");
			$(menu_UL).css("top", "40px");
			$(menu_UL).css("left", "0px");
			$(menu_UL).css("float", "left");
			$(menu_UL).css("syleFloat", "left");
			$(menu_UL).css("cssFloat", "left");
			$(menu_UL).css("text-align", "left");
			$(menu_UL).css("list-style-type", "none");
			$(menu_UL).css("margin", "0px 0px 0px 0px");
			$(menu_UL).css("padding", "0px 0px 0px 0px");
			$(menu_UL).css("background", "url(/images/template/bgAlpha_000000_90_des.png) no-repeat 0% 100%");
			$(menu_UL).css("overflow", "hidden");
			$(menu_UL).css("height", "0px");
			$(menu_UL).css("width", "600px");
			$(menu_UL).css("z-index", "0");
			$(menu_UL).appendTo(menu_DIV);




		} else {

			menu_LI = $("<li>");
			if (i < 5) {
				$(menu_LI).css("margin", "4px 0px 0px 0px");
			} else {
				$(menu_LI).css("margin", "0px 0px 0px 0px");
			}
			$(menu_LI).css("padding", "0px 0px 0px 0px");
			switch (arr.length) {
				case 1:
				case 2:
				case 3:
					menu_LI_width = "auto";
					menu_A_width = "auto";
					break;
			}
			$(menu_LI).css("max-width", "600px");
			$(menu_LI).css("width", menu_LI_width);
			$(menu_LI).css("height", "25px");
			$(menu_LI).css("float", "left");

		}

		menu_A = $("<a>");
		$(menu_A).css("float", "left");
		$(menu_A).css("syleFloat", "left");
		$(menu_A).css("cssFloat", "left");
		$(menu_A).css("text-align", "left");
		$(menu_A).css("max-width", "180px");
		$(menu_A).css("width", menu_A_width);
		$(menu_A).css("height", inMenuHeight.toString()+"px");
		$(menu_A).css("font-weight", "bold");
		$(menu_A).css("margin", "0px 0px 0px 0px");
		$(menu_A).css("padding", "0px 10px 0px 10px");
		$(menu_A).css("white-space", "nowrap");
		$(menu_A).css("line-height", inMenuHeight.toString()+"px");
		$(menu_A).css("background", "url(/images/template/topMenuBgA.png) no-repeat 100% 0%");
		$(menu_A).css("color", "#eeeeee");
		$(menu_A).css("cursor", "pointer");

		if (newMenu[1] != null) {
			if (newMenu[1].substring(0, 7) == "http://") {
				$(menu_A).attr("target", "_blank");
			} else {
				$(menu_A).attr("href", "_top");
				$(menu_A).bind("click", function(){
					createLoadingPage();
					$(this).parent().parent().animate({height:0}, 200, function(){});
				});
			}
			$(menu_A).attr("href", newMenu[1]);
		}

		$(menu_A).hover(
			function(){
				$(this).css("color", "#ffffff");
				$(this).css("background", "url(/images/template/topMenuBgA_ON.png) no-repeat 100% 0%");
			},
			function(){
				$(this).css("background", "url(/images/template/topMenuBgA.png) no-repeat 100% 0%");
				$(this).css("color", "#eeeeee");
			}
		);

		$(menu_A).html(newMenu[0]);
		$(menu_A).appendTo($(menu_LI));
		$(menu_LI).appendTo($(menu_UL));
	});

}


function mainMenu_top_go(id) {
	mainMenu_top(0, id);
	mainMenu_top(1, id);
	mainMenu_top(4, id);
	if (loginSession == "") {
		mainMenu_top(3, id);
	}
	mainMenu_top(2, id);
	if (loginSession == "") {
		mainMenu_top(6, id);
	} else {
		mainMenu_top(5, id);
	}
}
