﻿/*
function showMenu(divID, status) {
	var divObj = document.getElementById(divID);
	var parentObj = divObj.parentNode;
	var frameObj = divObj+"_shimeFrame";
	try {
		var shimframe = document.getElementById(frameObj);
		shimframe.src="";
	} catch (err) {
		var shimframe = document.createElement('iframe');
		shimframe.id = frameObj;
		parentObj.appendChild(shimframe);
	}
	shimframe.frameborder = 0;
	shimframe.border = 0;
	shimframe.scrolling = 'no';
	shimframe.style.position = 'absolute';
	shimframe.style.top = 0;
	shimframe.style.left = 0;
	shimframe.style.visibility = 'hidden';
	shimframe.style.zIndex = -1;
	if (status) {
		divObj.style.visibility = 'visible';
		divObj.style.zIndex = 10;
		shimframe.style.top = divObj.style.top;
		shimframe.style.left = divObj.style.left;
		shimframe.style.zIndex = divObj.style.zIndex - 1;
		shimframe.style.width = parseInt(divObj.offsetWidth)+'px';
		shimframe.style.height = parseInt(divObj.offsetHeight)+'px';
		if (navigator.appName.indexOf('Microsoft Internet Explorer')<0) {
			shimframe.style.width = (parseInt(shimframe.style.width)-4)+'px';
			shimframe.style.height = (parseInt(divObj.offsetHeight)-4)+'px';
		}
		shimframe.style.visibility = 'visible';
	}
	else {
		shimframe.style.visibility = 'hidden';
		shimframe.style.zIndex = -1;
		divObj.style.visibility = 'hidden';
		divObj.style.zIndex = -1;
		parentObj.removeChild(shimframe);
	}
}
*/

/*
function showmenu(elmnt) {
	document.getElementById(elmnt).style.visibility="visible";
}
function hidemenu(elmnt) {
	document.getElementById(elmnt).style.visibility="hidden";
}
*/


function showMenu(elmnt, status) {
	if (status)	{
		document.getElementById(elmnt).style.visibility="visible";
		document.getElementById(elmnt).style.zIndex = 10;
	} else {
		document.getElementById(elmnt).style.visibility="hidden";
		document.getElementById(elmnt).style.zIndex = -1;
	}
}

function createmenu() {
  	menuarray = [
		{"main": "/images/common/horizonal_menu_01.jpg", "alt": "醫家頭條", "mid": "cate01", "link": "/issues.aspx", "submenu":[
		]}, 
		{"main": "/images/common/horizonal_menu_02.jpg", "alt": "醫家論點", "mid": "cate02", "link": "/professional.aspx", "submenu":[
			{ "sub": "睡眠/情緒", "sublink": "/professional/sleep_emotion.aspx" },
			{ "sub": "關節痛症", "sublink": "/professional/joints.aspx" },
			{ "sub": "泌尿健康", "sublink": "/professional/urinary.aspx" },
			{ "sub": "更年期", "sublink": "/professional/menopause.aspx" },
			{ "sub": "眼睛", "sublink": "/professional/eyes.aspx" },
			{ "sub": "心血管健康", "sublink": "/professional/cardiovascular.aspx" },
			{ "sub": "消化系統", "sublink": "/professional/digestive.aspx" },
			{ "sub": "兩性關係", "sublink": "/professional/relationship.aspx" },
			{ "sub": "癌症", "sublink": "/professional/cancer.aspx" },
			{ "sub": "其它", "sublink": "/professional/others.aspx" }
		]}, 
		{"main": "/images/common/horizonal_menu_03.jpg", "alt": "健康專欄", "mid": "cate03", "link": "/health.aspx", "submenu":[
			{"sub": "代代安寧<br/>梁玳寧", "sublink": "/doreen.aspx"},
			{"sub": "營養師<br/>Heidi話你知", "sublink": "/heidi.aspx" },
			{ "sub": "樂本‧健<br/>SmartTips", "sublink": "/smarttips.aspx" }
		]},
		{"main": "/images/common/horizonal_menu_04.jpg", "alt": "絕世好方", "mid": "cate04", "link": "/Prescription.aspx", "submenu":[
		]},
		{"main": "/images/common/horizonal_menu_06.jpg", "alt": "健康e百科", "mid": "cate06", "link": "/encyclopedia.aspx", "submenu":[
			{"sub": "都市人都市病", "sublink": "/diseases.aspx"},
			{ "sub": "健康小測試", "sublink": "/encyclopedia_01.aspx" },
			{"sub": "查字典", "sublink": "/encyclopedia_02.aspx"},
			{"sub": "醫療機構名稱", "sublink": "/encyclopedia_03.aspx"}
		]},
		{"main": "/images/common/horizonal_menu_05.jpg", "alt": "醫食同源", "mid": "cate05", "link": "/food.aspx", "submenu":[
/*			{"sub": "四季食療", "sublink": "/food.aspx"},
			{"sub": "食物相宜相剋", "sublink": "/food.aspx"}   */
		]},
		{ "main": "/images/common/horizonal_menu_07.jpg", "alt": "最佳銷售榜", "mid": "cate07", "link": "/bestseller.aspx", "submenu": [
		]},
		{"main": "/images/common/horizonal_menu_08.jpg", "alt": "會員通訊", "mid": "cate08", "link": "/newsletter.aspx", "submenu":[
		]}
	];
	menuoutput = '';
		menuoutput += '<table border="0" cellpadding="0" cellspacing="0"><tr valign="bottom">';
	for (i=0; i<menuarray.length ;i++ )
	{
		menuoutput += '<td border="0px" onmouseover="showMenu(\'' + menuarray[i].mid + '\', true)" onmouseout="showMenu(\'' + menuarray[i].mid + '\', false)">';
		menuoutput += '<a href="' + menuarray[i].link + '"><img src="' + menuarray[i].main + '" border=0 alt="' + menuarray[i].alt + '"></a><br />';
		menuoutput += '<div><table class="menu" id="' + menuarray[i].mid + '" cellpadding="0" cellspacing="0">';
		for (j=0; j<menuarray[i].submenu.length; j++ )
		{
			menuoutput += '<tr><td width="2px" background="/images/common/menu_left.gif"><td height="1px" bgcolor="#999999"></td><td width="2px" background="/images/common/menu_right.gif"></tr>';
			menuoutput += '<tr><td width="2px" background="/images/common/menu_left.gif"></td><td class="menu" style="padding:3px" align="center"><a href="'+ menuarray[i].submenu[j].sublink +'" class="content">'+ menuarray[i].submenu[j].sub +'</a></td><td width="2px" background="/images/common/menu_right.gif"></td></tr>';
		}
		if(menuarray[i].submenu.length !=0){
			menuoutput += '<tr><td height="2px" width="2px" background="/images/common/menu_bottom1.gif"></td><td width="95px" background="/images/common/menu_bottom2.gif"></td><td width="2px" background="/images/common/menu_bottom3.gif"></td></tr>';
		} 
		menuoutput += '</table></div></td>';
	}
	menuoutput += '</tr></table>';

	document.getElementById("menu").innerHTML = menuoutput;
}




