function init(){
	setTopLayerPosition(true);
	if(printPage){
		window.print();
	}
	onresize=setTopLayerPosition;
}

function getCaption(menu, i){
	var showAlt;
	
	if(langID==1)
		eval('showAlt='+menu+'['+i+'].caption');
	else
		eval('showAlt='+menu+'['+i+'].chiCaption');
	return showAlt;
}

//function for Draw Print Button
function genPrintButton(){

	if(langID==1){ var altText='Print'; }else{ var altText='列印'; }

	document.writeln('<p><table border=0 cellspacing=0 cellpadding=0 width=100%>');
	if(!isText){
		document.writeln('<tr valign=top><td align=right><a href="javascript:PrintDocument();"><img src="'+imagePath+'images/but_print.gif" border=0 align=top alt="'+altText+'"></a></td></tr>');
	}else{
		document.writeln('<tr valign=top><td align=right><a href="javascript:PrintDocument();">'+altText+'</a></td></tr>');
	}
	document.writeln('');
	document.writeln('</table>');
}

function getAcrobat(){
	var StrText='To view or download the following document, please download <a class="text_link" href="javascript:externalLink(\'http://www.adobe.com/prodindex/acrobat/readstep.html\');">Acrobat Reader</a>.';
	if(langID==2) StrText='如想觀看以上文件，請下載<a class="text_link" href="javascript:externalLink(\'http://www.adobe.com/prodindex/acrobat/readstep.html\');">Acrobat Reader</a> 。';
	var StrImg='<img src="'+locationPath+'/images/acrobat.gif" border=0 align=top alt="Acrobat Reader">';
		
	document.writeln('<p><table border=0 cellspacing=0 cellpadding=2 width=585><tr valign=top>');
	if(!isText)
		document.writeln('<td width=1%><a href="javascript:externalLink(\'http://www.adobe.com/prodindex/acrobat/readstep.html\');">'+StrImg+'</a></td>');
	document.writeln('<td class="maincontent" width=99%>'+StrText+'</td>');
	document.writeln('</tr></table>');
}

function getRealPlayer(){
	var StrText='You can use RealPlayer to view the videos in Real Media format. RealPlayer is available free at <a class="text_link" href="javascript:externalLink(\'http://www.real.com/\');">www.real.com</a>.';
	if(langID==2) StrText='以上短片須使用RealPlayer觀看, 此軟件可於<a class="text_link" href="javascript:externalLink(\'http://www.real.com/\');">www.real.com</a>免費下載:';
	var StrImg='<img src="'+locationPath+'/images/realplayer.gif" border=0 align=top alt="RealPlayer">';
		
	document.writeln('<p><table border=0 cellspacing=0 cellpadding=2 width=585><tr valign=top>');
	if(!isText)
		document.writeln('<td width=1%><a href="javascript:externalLink(\'http://www.real.com/\');">'+StrImg+'</a></td>');
	document.writeln('<td width=99%>'+StrText+'</td>');
	document.writeln('</tr></table>');
}

function addMenu(sectionID, caption, url, picNo, hasChild, sitemap, navigationMenu)
{
	var tempCaption = new Array();
	tempCaption=caption.split(",")
	var x=menuObj.length; 
	menuObj[x]	= new Object();
	menuObj[x].id = sectionID;
	menuObj[x].caption = tempCaption[langID-1];
	menuObj[x].url = locationPath+langPath+url;
	menuObj[x].picNo = menuImageName+picNo;
	menuObj[x].picPath = imagePath+menuImagePath+menuObj[x].picNo+menuImageType;
	menuObj[x].hasChild = hasChild;
	menuObj[x].sitemap = sitemap;
	menuObj[x].navigationMenu = navigationMenu;
}

function addSubMenu(menuID, subSectionID, caption, url, picNo, hasChild, sitemap, navigationMenu)
{
	var tempCaption = new Array();
	tempCaption=caption.split(",")
	var y=subMenuObj.length; 
	subMenuObj[y] = new Object();
	subMenuObj[y].menuID = menuID;
	subMenuObj[y].id = subSectionID;
	subMenuObj[y].caption = tempCaption[langID-1];
	subMenuObj[y].url = locationPath+langPath+url;
	subMenuObj[y].picNo = subMenuImageName+picNo;
	subMenuObj[y].picPath = imagePath+menuImagePath+subMenuObj[y].picNo+menuImageType;
	subMenuObj[y].hasChild = hasChild;
	subMenuObj[y].sitemap = sitemap;
	subMenuObj[y].navigationMenu = navigationMenu;
}

//function for generating the top menu
function getTopMenu(){
	
	document.writeln('<table border="0" cellspacing="0" cellpadding="0" width=775>');
	document.writeln('<tr valign=top>');
	document.writeln('	<td colspan=3><img src="'+imagePath+menuImagePath+'inside_hd_01.jpg" border="0" alt=""></td>');
	document.writeln('</tr>');
	document.writeln('<tr valign=top>');
	document.writeln('	<td colspan=3>');
	document.writeln('	<table border="0" cellspacing="0" cellpadding="0">');
	document.writeln('	<tr valign=top>');
	document.writeln('		<td rowspan=2><img src="'+imagePath+menuImagePath+'inside_hd_02.jpg" border="0" alt=""></td>');
	document.writeln('		<td colspan=2><img src="'+imagePath+menuImagePath+'inside_title.jpg" border="0" alt="'+arTopMenu[langID][0]+'"></td>');
	document.writeln('	</tr>');
	document.writeln('	<tr valign=top>');
	document.writeln('		<td>');
	document.writeln('		<table border="0" cellspacing="0" cellpadding="0">');
	document.writeln('		<tr>');
	document.writeln('			<td><a href="'+locationPath+'/index.htm"><img src="'+imagePath+menuImagePath+'inside_home.jpg" border="0" alt="'+arTopMenu[langID][1]+'"></a></td>');
	document.writeln('			<td><a href="javascript:changeLanguage(\''+arTopMenu[langID][4]+'\')"><img src="'+imagePath+menuImagePath+'inside_'+arTopMenu[langID][6]+'_version.jpg" border="0" alt="'+arTopMenu[langID][2]+'"></a></td>');
	document.writeln('			<td><a href="javascript:changeLanguage(\''+arTopMenu[langID][5]+'\')"><img src="'+imagePath+menuImagePath+'inside_'+arTopMenu[langID][7]+'_version.jpg" border="0" alt="'+arTopMenu[langID][3]+'"></a></td>');
	document.writeln('		</tr>');
	document.writeln('		<tr>');
	document.writeln('			<td colspan=3><img src="'+imagePath+menuImagePath+'inside_hd_03.jpg" border="0" alt=""></td>');
	document.writeln('		</tr>');
	document.writeln('		</table>');
	document.writeln('		</td>');
	document.writeln('		<td>');
	document.writeln('		<table border="0" cellspacing="0" cellpadding="0">');
	document.writeln('		<tr valign=top>');
	document.writeln('			<td><img src="'+imagePath+menuImagePath+'inside_hd_04.jpg" border="0" alt=""></td>');
	document.writeln('			<td><img src="'+imagePath+menuImagePath+'inside_hd_05.jpg" border="0" alt=""></td>');
	document.writeln('		</tr>');
	document.writeln('		</table>');
	document.writeln('		</td>');
	document.writeln('	</tr>');
	document.writeln('	</table>');
	document.writeln('	</td>');
	document.writeln('</tr>');
	document.writeln('<tr valign=top>');
	document.writeln('	<td>');
}

function getLeftMenu(){
	document.writeln('	<!-- Left Menu -->');
	document.writeln('	<table border="0" cellspacing="0" cellpadding="0">');
	document.writeln('	<tr valign=top>');
	document.writeln('		<td><img src="'+imagePath+menuImagePath+'nav_hd_01.jpg" border="0" alt=""></td>');
	document.writeln('	</tr>');
	
	for(var i in menuObj){
		if(menuObj[i]){
			if(menuObj[i].navigationMenu){
				if (selectedId==menuObj[i].id){
					var pic = menuObj[i].picPath.replace(menuImageType, menuImageOver+menuImageType);
					var outAction = "";
					var overAction = "";
				}else{
					var pic = menuObj[i].picPath;
					var outAction = " onMouseOut=\"outLeftMenu('"+menuObj[i].picNo+"');\"";
					var overAction = " onMouseOver=\"overLeftMenu('"+menuObj[i].picNo+"');\" ";
				}
				document.writeln("<tr><td><a href='"+menuObj[i].url+"'"+ outAction + overAction + "><img name='"+menuObj[i].picNo+"' id='"+menuObj[i].picNo+"' src='" + pic +  "' alt='"+menuObj[i].caption+"' border=0></a></td></tr>");
			}
		}
	}
	
	document.writeln('	<tr>');
	document.writeln('		<td><img src="'+imagePath+menuImagePath+'nav_hd_02.jpg" border="0" alt=""></td>');
	document.writeln('	</tr>');
	document.writeln('	</table>');
	document.writeln('	<!-- End of Left Menu -->');
	document.writeln('	</td>');
}

function getSubMenu(){
	document.writeln('</td></tr></table></td>');
	document.writeln('	<td align=right background="'+imagePath+menuImagePath+'r_nav_hd01.jpg">');
	document.writeln('	<!-- Right Menu -->');
	document.writeln('	<table border="0" cellspacing="0" cellpadding="0">');
	
	for(var i in subMenuObj){
		if(subMenuObj[i]){
			if(subMenuObj[i].menuID==selectedId){
				if (selectedSubId==subMenuObj[i].id){
					var pic = subMenuObj[i].picPath.replace(menuImageType, menuImageOver+menuImageType);
					var outAction = "";
					var overAction = "";
				}else{
					var pic = subMenuObj[i].picPath;
					var outAction = " onMouseOut=\"outLeftMenu('"+subMenuObj[i].picNo+"');\"";
					var overAction = " onMouseOver=\"overLeftMenu('"+subMenuObj[i].picNo+"');\" ";
				}
				document.writeln("<tr><td><a href='"+subMenuObj[i].url+"'"+ outAction + overAction + "><img name='"+subMenuObj[i].picNo+"' id='"+subMenuObj[i].picNo+"' src='" + pic +  "' alt='"+subMenuObj[i].caption+"' border=0></a></td></tr>");
				document.writeln('	<tr>');
				document.writeln('		<td><img src="'+imagePath+menuImagePath+'r_nav_space.jpg" border="0" alt=""></td>');
				document.writeln('	</tr>');
			}
		}
	}
	
	document.writeln('	</table>');
	document.writeln('	<!-- End of Right Menu -->');
	document.writeln('	</td>');
	document.writeln('</tr>');	
}

function getTopic(){
	var pic="";
	var caption="";
	
	for(var i in menuObj){
		if (selectedId==menuObj[i].id){
			pic = menuObj[i].picPath.replace(menuImageName, topicImageName);
			caption=menuObj[i].caption
		}
	}
	
	if(selectedSubId>0){
		for(var i in subMenuObj){
			if(subMenuObj[i].menuID==selectedId){
				if (selectedSubId==subMenuObj[i].id){
					pic = subMenuObj[i].picPath.replace(subMenuImageName, topicImageName);
					caption+=" > "+subMenuObj[i].caption
				}
			}
		}
	}
	
	document.writeln('<td><img src="'+pic+'" border="0" alt="'+caption+'"><br>');
	document.writeln('<table cellpadding=10 cellspacing=0 border=0 width=100%><tr><td valign=top>');
}

//function for setting the top button
function setTopLayerPosition(resizeFlag){
	if(topButton=='Y'){
		if (document.all && document.all["footer_layer"]!=null)
		{
	//		footerY = getDim(document.images.leftMenuLineBottom).y;
			moveTopDivs(document.all["footer_layer"].style, getDim(document.images.backtotopspacer).y, getDim(document.images.backtotopspacer).x)
			if (getDim(document.images.backtotopspacer).y > footerY)
			{
				if (resizeFlag)
				{document.all["footer_layer"].style.visibility = "visible"}
			}
		}
		if (document.layers && document.layers["footer_layer"])
		{
	//		footerY = document.images["leftMenuLineBottom"].y;
			moveTopDivs(document.layers["footer_layer"], document.images["backtotopspacer"].y, document.images["backtotopspacer"].x);
			if (document.images["backtotopspacer"].y > footerY)
			{
				if (resizeFlag)
				{document.layers["footer_layer"].visibility = "show"}
			}
		}
		if (!document.all && document.getElementById && document.getElementById("footer_layer")!=null)
		{
	//		footerY = document.images["leftMenuLineBottom"].y;
			moveTopDivs(document.getElementById("footer_layer").style, document.images["backtotopspacer"].y, document.images["backtotopspacer"].x);
			if (document.images["backtotopspacer"].y > footerY)
			{
				if (resizeFlag)
				{document.getElementById("footer_layer").style.visibility = "visible"}
			}
		}
	}
}

//function for generating the layer for top button
function genfooterLayer(){
	var altText='Top';
	
	if(langID!=1) altText='頁首';

	if (document.layers)
		{document.writeln('<layer name=footer_layer top=0 left=0 width=26 height=26 visibility="hide">');}
	else
		{document.writeln('<div id="footer_layer" style="position:absolute; left:0; top:0; width:26; height:26; z-index:1; visibility: hidden"> ');}
	document.writeln('<table width="100%" border="0" cellspacing="0" cellpadding="0">');
	document.writeln('<tr valign=top>');
	document.writeln('	<td><a href="#top"><img src="'+imagePath+'images/btn_top.gif" alt="'+altText+'" border="0" name="backtotopfoot"></a></p></td>');
	document.writeln('</tr>');
	document.writeln('</table>');
	if (document.layers)
		{document.writeln('</layer>');}
	else
		{document.writeln('</div>');}			
}

//function for generating the footer
function getFooter(){
	document.writeln('<tr valign=bottom>');
	document.writeln('	<td><img src="'+imagePath+menuImagePath+'inside_logo.jpg" border="0" alt=""></td>');
if(location.href.toString().search('/institute/index.htm') != -1)
{
//	document.writeln('	<td><img src="'+imagePath+menuImagePath+'inside_flash.jpg" border="0" alt=""></td>');
	document.writeln('	<td><OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" WIDTH=\"515\" HEIGHT=\"126\" id=\"home_2\" ALIGN=\"\"><PARAM NAME=movie VALUE=\"'+imagePath+menuImagePath+'inside_flash.swf\"><PARAM NAME=quality VALUE=high><PARAM NAME=bgcolor VALUE=#FFFFFF><EMBED src=\"'+imagePath+menuImagePath+'inside_flash.swf\" quality=high bgcolor=#FFFFFF  WIDTH=\"515\" HEIGHT=\"126\" NAME=\"home_2\" ALIGN=\"\" TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\"></EMBED></OBJECT></td>');
}
else
{
	document.writeln('	<td><img src="'+imagePath+menuImagePath+'spacer.gif" border="0" alt="" width="515" height="126"></td>');
}
	document.writeln('	<td background="'+imagePath+menuImagePath+'r_nav_hd01.jpg"><img src="'+imagePath+menuImagePath+'r_nav_down.jpg" border="0" alt=""></td>');
	document.writeln('</tr>');
	document.writeln('<tr>');
	document.writeln('	<td colspan=3><img src="'+imagePath+menuImagePath+'inside_footer.jpg" border="0" alt=""></td>');
	document.writeln('</tr>');
	document.writeln('</table>');
}

function getSiteMap(){
	document.writeln('<ul type="square">');
	for(var i=1;i<x;i++){
		if(menuObj[i]){
			if(menuObj[i].sitemap=="Y"){
				document.write('	<li><a href="'+menuObj[i].url+'">'+getCaption('menuObj', i)+'</a>');
				if(menuObj[i].hasChild=="Y"){
					document.writeln('	<ul type="square">');
					for(var j=1;j<y;j++){
						if (subMenuObj[j].menuID==i)
							document.write('	<li><a href="'+subMenuObj[j].url+'">'+getCaption('subMenuObj', j)+'</a></li>');
					}
					document.writeln('	</ul><br></li>');
				}else{
				document.writeln('<br><br></li>');
				}
			}
		}
	}
	document.writeln('</ul>');
}

function getTemplateHead(){
	getTopMenu();
	getLeftMenu();
	getTopic();
}

function getTemplateFooter(){
	getSubMenu();
	getFooter();
}

var m_caption;
var m_pic;
var m_alt;
var m_caption;
var m_tcImgFolder;

if(location.href.toString().search('/sc/') != -1){
	m_tcImgFolder = "sc"
}
else
{
	m_tcImgFolder = "tc"
}


function openwindow(address,id,title,w,h){
//if(isText) address="ht"+"tp://"+graphicPath+langPath;
var blnScrollResize = "yes";
h=h+40; //show the caption and close window button
//if (w>400){w=400;blnScrollResize="yes"}
//if (h>400){h=400;blnScrollResize="yes"}


window.open(address+"popuppic.htm?id=" + id,title,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars="+blnScrollResize+",resizable="+blnScrollResize+",pageXOffset=300,pageYOffset=500,top=80,left=150,width="+ w + ",height=" + h);
}


//function for displaying the image, caption and alt text
function getPopupData(){
sourceUrl = document.location.search;
sid = sourceUrl.substring(sourceUrl.indexOf('=')+1, sourceUrl.length);


switch(sid){

case "1":
m_pic=m_tcImgFolder + "/gallery/images/large/vec2.jpg";
m_alt="相片";
break;

case "1e":
m_pic="en/gallery/images/large/vec2.jpg";
m_alt="Photo";
break;

case "2":
m_pic=m_tcImgFolder + "/gallery/images/large/vec1.jpg";
m_alt="相片";
break;

case "2e":
m_pic="en/gallery/images/large/vec1.jpg";
m_alt="Photo";
break;

case "3":
m_pic=m_tcImgFolder + "/gallery/images/large/vec3.jpg";
m_alt="相片";
break;

case "3e":
m_pic="en/gallery/images/large/vec3.jpg";
m_alt="Photo";
break;

case "4":
m_pic=m_tcImgFolder + "/gallery/images/large/vec4.jpg";
m_alt="相片";
break;

case "4e":
m_pic="en/gallery/images/large/vec4.jpg";
m_alt="Photo";
break;

case "5":
m_pic=m_tcImgFolder + "/gallery/images/large/cpd1.jpg";
m_alt="相片";
break;

case "5e":
m_pic="en/gallery/images/large/cpd1.jpg";
m_alt="Photo";
break;

case "6":
m_pic=m_tcImgFolder + "/gallery/images/large/cpd2.jpg";
m_alt="相片";
break;

case "6e":
m_pic="en/gallery/images/large/cpd2.jpg";
m_alt="Photo";
break;

case "7":
m_pic=m_tcImgFolder + "/gallery/images/large/pta2.jpg";
m_alt="相片";
break;

case "7e":
m_pic="en/gallery/images/large/pta2.jpg";
m_alt="Photo";
break;

case "8":
m_pic=m_tcImgFolder + "/gallery/images/large/pta1.jpg";
m_alt="相片";
break;

case "8e":
m_pic="en/gallery/images/large/pta1.jpg";
m_alt="Photo";
break;

case "9":
m_pic=m_tcImgFolder + "/gallery/images/large/scan0001.jpg";
m_alt="相片";
break;

case "9e":
m_pic="en/gallery/images/large/scan0001.jpg";
m_alt="Photo";
break;

case "10":
m_pic=m_tcImgFolder + "/gallery/images/large/scan0002.jpg";
m_alt="相片";
break;

case "10e":
m_pic="en/gallery/images/large/scan0002.jpg";
m_alt="Photo";
break;

case "11":
m_pic=m_tcImgFolder + "/gallery/images/large/scan0003.jpg";
m_alt="相片";
break;

case "11e":
m_pic="en/gallery/images/large/scan0003.jpg";
m_alt="Photo";
break;

case "12":
m_pic=m_tcImgFolder + "/gallery/images/large/scan0004.jpg";
m_alt="相片";
break;

case "12e":
m_pic="en/gallery/images/large/scan0004.jpg";
m_alt="Photo";
break;

case "13":
m_pic=m_tcImgFolder + "/gallery/images/large/grad_day3.jpg";
m_alt="相片";
break;

case "13e":
m_pic="en/gallery/images/large/grad_day3.jpg";
m_alt="Photo";
break;

case "14":
m_pic=m_tcImgFolder + "/gallery/images/large/grad_day1.jpg";
m_alt="相片";
break;

case "14e":
m_pic="en/gallery/images/large/grad_day1.jpg";
m_alt="Photo";
break;

case "15":
m_pic=m_tcImgFolder + "/gallery/images/large/028.jpg";
m_alt="相片";
break;

case "15e":
m_pic="en/gallery/images/large/028.jpg";
m_alt="Photo";
break;

case "16":
m_pic=m_tcImgFolder + "/gallery/images/large/049.jpg";
m_alt="相片";
break;

case "16e":
m_pic="en/gallery/images/large/049.jpg";
m_alt="Photo";
break;

case "17":
m_pic=m_tcImgFolder + "/gallery/images/large/106.jpg";
m_alt="相片";
break;

case "17e":
m_pic="en/gallery/images/large/106.jpg";
m_alt="Photo";
break;

case "18":
m_pic=m_tcImgFolder + "/gallery/images/large/1431.jpg";
m_alt="相片";
break;

case "18e":
m_pic="en/gallery/images/large/1431.jpg";
m_alt="Photo";
break;

case "19":
m_pic=m_tcImgFolder + "/gallery/images/large/1429.jpg";
m_alt="相片";
break;

case "19e":
m_pic="en/gallery/images/large/1429.jpg";
m_alt="Photo";
break;

case "20":
m_pic=m_tcImgFolder + "/gallery/images/large/060.jpg";
m_alt="相片";
break;

case "20e":
m_pic="en/gallery/images/large/060.jpg";
m_alt="Photo";
break;

case "21":
m_pic=m_tcImgFolder + "/gallery/images/large/agm1.jpg";
m_alt="相片";
break;

case "21e":
m_pic="en/gallery/images/large/agm1.jpg";
m_alt="Photo";
break;

case "22":
m_pic=m_tcImgFolder + "/gallery/images/large/agm2.jpg";
m_alt="相片";
break;

case "22e":
m_pic="en/gallery/images/large/agm2.jpg";
m_alt="Photo";
break;

case "23":
m_pic=m_tcImgFolder + "/gallery/images/large/agm3.jpg";
m_alt="相片";
break;

case "23e":
m_pic="en/gallery/images/large/agm3.jpg";
m_alt="Photo";
break;

case "24":
m_pic=m_tcImgFolder + "/gallery/images/large/agm5.jpg";
m_alt="相片";
break;

case "24e":
m_pic="en/gallery/images/large/agm5.jpg";
m_alt="Photo";
break;

default:
m_pic="";
m_alt="";
}


imgURL = "<img src='" + m_pic + "' border='0' alt='" + m_alt + "'>"
return imgURL;

}
