﻿var tempHtml;
var tempStr1;
var tempStr2;
var switchLanguagePath=""; 
if (section == null)	var section = 0;
if (level1 == null)	var level1 = "";
if (level2 == null)	var level2 = "";
if (level3 == null)	var level3 = "";
if (selectArray == null)	var selectArray = null;
var id1 = null;
var id2 = null;
var id3 = null;
if (isSearch == null)	var isSearch = false;


/*
if (location.search != '')
{
	if (GetParam('level1'))	level1 = GetParam('level1');
	if (GetParam('level2'))	level2 = GetParam('level2');
	if (GetParam('level3'))	level3 = GetParam('level3');
}*/


//getLevel();
genId();


function getLevel() {
	var link = location.href.toString();
	var obj = sectionArray[section];
	
	if (level1 == "") {
		for (var i=0; i<obj.length; i++) {
			if (link.indexOf(("/" + obj[i].id + "/")) > -1) {
				level1 = obj[i].id;
				
				if (level2 == "" && obj[i].subSection) {
					var obj1 = obj[i].subSection;
					
					for (var j=0; j<obj1.length; j++) {
						if (link.indexOf((obj1[j].id)) > -1) {
							level2 = obj1[j].id;
							
							if (level3 == "" && obj1[j].subSection) {
								var obj2 = obj1[j].subSection;
								
								for (var k=0; k<obj2.length; k++) {
									if (link.indexOf((obj2[k].id)) > -1) {
										level3 = obj2[k].id;
										
										break;
									}
								}
							} else {
								break;
							}
						}
					}
				} else {
					break;
				}
			}
		}
	}	
	
//	alert("level2: "+level2);
}


function genId() {	
	var obj = sectionArray[section];
	
	if (level1 != "") {
		for (var i=0; i<obj.length; i++) {
			//alert(obj[i].id + "  " + level1);
			if (obj[i].id == level1) {
				id1 = i;
				
				if (level2 != "") {
					var obj1 = obj[i].subSection;
					for (var j=0; j<obj1.length; j++) {
						//alert(obj[i].id + "  " + level1);
						if (obj1[j].id == level2) {
							id2 = j;
							
							if (level3 != "") {
								var obj2 = obj1[j].subSection;
								for (var k=0; k<obj2.length; k++) {
									//alert(obj[i].id + "  " + level1);
									if (obj2[k].id == level3) {
										id3 = k;
										break;
									}
								}
							} else {
								break;
							}
						}
					}
				} else {
					break;
				}
			}
		}
	}
//alert("id1: "+id1+"   id2: "+id2+"   id3: "+id3);
}

function genTop() {
	var sect = 0;
	var obj = sectionArray[sect];
	tempHtml = '';
	
	tempHtml += '			<tr valign="top">';
	tempHtml += '				<td align="center">';
	tempHtml += '					<table width="970" border="0" cellspacing="0" cellpadding="0">';
	tempHtml += '						<tr bgcolor="#223B55">';
	tempHtml += '							<td width="189" valign="bottom" height="70" style="padding:0px 0px 0px 8px;"><a href="'+path+'index.htm"><img src="'+path+'images/common/logo.gif" alt="Swire Island East" border="0" vspace="6"></a></td>';
	tempHtml += '							<td valign="top" align="right" height="70">';
	tempHtml += '								<table width="100%" border="0" cellspacing="0" cellpadding="0">';
	tempHtml += '									<tr valign="top">';
	tempHtml += ' 										<form name="googleSearchForm" action="'+ path +'introduction/search/google_search_result.htm" id="searchbox_016064583542050252904:9iz-vxeujka">'; 
	tempHtml += '										<td align="right" style="padding:0px 17px 0px 0px;">';
	tempHtml += '											<table border="0" cellspacing="0" cellpadding="0" height="34">';
	tempHtml += '												<tr valign="top">';
	
	if (!isMobile)
	{
		tempHtml += '													<td style="padding:3px 0px 0px 0px;"><img src="'+path+'images/others/title_font.gif" border="0"></td>';	
		tempHtml += '													<td class="top" style="padding:3px 0px 0px 0px;"><a href="javascript:changeFontSize(\'contentTd\',1);" class=footer><img src="'+path+'images/others/title_increase.gif" border="0"></a></td>';
		tempHtml += '													<td class="top" style="padding:3px 0px 0px 0px;"><a href="javascript:changeFontSize(\'contentTd\',-1);" class=footer><img src="'+path+'images/others/title_decrease.gif" border="0"></a></td>';
	}
	
	tempHtml += '													<td class="top" style="padding:0px 0px 0px 0px;"><a href="http://www.facebook.com/SwireIslandEast/" target="_blank"><img src="'+path+'images/common/btn_facebook.png" border="0"></a></td>';	
	tempHtml += '													<td width="1" class="top" style="padding:11px 0px 0px 0px;"><img src="'+path+'images/common/line_v.gif" width="1" height="7" hspace="1"></td>';
					
					for (var i=0; i<obj.length; i++)
					{
						//Hard Code Remove Map
						//if (isIpad && obj[i].link.indexOf('introduction/transportation/map.htm') >= 0)	continue;
						
						tempHtml += '<td class="top"><a href="'+path+obj[i].link+'" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'btn_'+obj[i].id+'\',\'\',\''+path+'images/common/btn_'+obj[i].id+'_f2.gif\',1)"><img src="'+path+'images/common/btn_'+obj[i].id+'.gif" name="btn_'+obj[i].id+'" border="0"></a></td>';
						tempHtml += '<td width="1" class="top" style="padding:11px 0px 0px 0px;"><img src="'+path+'images/common/line_v.gif" width="1" height="7" hspace="1"></td>';
					}
	
	tempHtml += '													<td colspan=4 class="top" style="padding:3px 4px 0px 0px;"></td>'; 
	//temp for disable google search
	tempHtml += '													<td class="top" style="padding:3px 7px 0px 7px;"><img src="'+path+'images/common/btn_search.gif" border="0"></td>';
	tempHtml += '													<td class="top" style="padding:3px 4px 0px 0px;">';
	tempHtml += '			 											<input type="hidden" name="cx" value="013946077505093816638:denu8tlgpia" />';
	tempHtml += ' 														<input type="hidden" name="cof" value="FORID:10;NB:1" />'; //google search
	tempHtml += '														<input name="q" type="text" class="inputfield" style="width:95px;">';
	tempHtml += '														<input type="hidden" name="ie" value="utf8" />';
	tempHtml += '														<input type="hidden" name="oe" value="utf8" />';	
	tempHtml += '														<input type="hidden" name="hl" value="zh-TW" />';		
	tempHtml += '													</td>';
	tempHtml += '													<td class="top" style="padding:3px 8px 0px 0px;"><a href="javascript:document.googleSearchForm.submit()" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'btn_go\',\'\',\''+path+'images/common/btn_go_f2.gif\',1)"><img src="'+path+'images/common/btn_go.gif" width="19" height="19" name="btn_go" border="0"></a></td>';
	tempHtml += '													<td width="1" class="top" style="padding:11px 0px 0px 0px;"><img src="'+path+'images/common/line_v.gif" width="1" height="7" hspace="1"></td>';
	//End for disable google search
	tempHtml += '													<td class="top"><a href="javascript:changeLanguage(\'eng\');" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'btn_eng\',\'\',\''+path+'images/common/btn_eng_f2.gif\',1)"><img src="'+path+'images/common/btn_eng.gif" name="btn_eng" border="0"></a></td>';
	tempHtml += '												</tr>';
	tempHtml += '											</table>';
	tempHtml += ' 											<script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=zh-Hant&sitesearch=true"></script>'; //google search
	tempHtml += '										</td></form>';
	tempHtml += '									</tr>';
	tempHtml += '									<tr valign="top">';
	tempHtml += '										<td>';
	tempHtml += '											<div style="position:absolute; z-index:10;">';
	tempHtml += '												<div style="visibility:visible; position:absolute; overflow:hidden; top:-20px; left:-112px; width:895px; height:56px; z-index:10;" id="menuDiv">';
//																	innerFlash(path+'images/swf/menu.swf', '765', '246', 'menu', '');
	
	if (GetParam("gosection")) {
		var gosection = GetParam("gosection");
		
		if (gosection.indexOf("T") > -1) {
			level1 = "intro";
			level2 = "transportation";
			
			if (gosection.indexOf("5T") > -1) {
				level3 = "parking";
			}
		}
		if (gosection.indexOf("B") > -1) {
			level1 = "working";
			level2 = "map";
		}
		if (gosection.indexOf("S") > -1) {
			level1 = "shopping";
			level2 = "map";			
		}
		if (gosection.indexOf("D") > -1) {
			level1 = "dining";
			level2 = "map";			
		}
		if (gosection.indexOf("A") > -1) {
			level1 = "art";
			level2 = "map";
		}
	}

	//alert("Leve1: " + level1);
	//alert("Leve2: " + level2);
	
	if (!isMobile)
	{
		if (location.href.indexOf('/NR/exeres/')>0)
		{
		innerFlash(path+'images/swf/menu.swf', '970', '500', 'menuFlash', ('path=/&level1='+level1+'&level2='+level2+'&level3='+level3+'&xmlPath='+path+'images/swf/editmode/&imagePath='+path+'images/'));
		}
		else
		{
		innerFlash(path+'images/swf/menu.swf', '970', '500', 'menuFlash', ('path='+path+'&level1='+level1+'&level2='+level2+'&level3='+level3+'&xmlPath='+path+'images/swf/'));
		}
	}
	else
	{
		//ipad version
		
	}
		
	tempHtml += '												</div>';
	tempHtml += '											</div>';
	tempHtml += '										</td>';
	tempHtml += '									</tr>';
	tempHtml += '								</table>';
	tempHtml += '							</td>';
	tempHtml += '						</tr>';
	tempHtml += '					</table>';
	tempHtml += '				</td>';
	tempHtml += '			</tr>';
	
	document.write(tempHtml);
	
	//if (isMobile)	setTimeout(function(){new genIpadTopNav()}, 500);
}


function menuFlash_DoFSCommand(command, args) {
	if (command == "menuOpen")
		{
//			alert(command);
			menuOpen (args);
		}
}


function menuOpen(over) {
	var menuDiv = document.getElementById('menuDiv');

	if (navigator.appName.indexOf("Microsoft") == -1) {
		var divs = document.getElementsByTagName('div');
	}
	var isOverflow = 'hidden';
	
	if (over == 1) {
		menuDiv.style.height = '600';
		
		var tag = document.getElementsByTagName("select");
		for (var i=0 ; i<tag.length; i++ ) {
			tag[i].style.visibility = 'hidden';
		}
		isOverflow = 'hidden';
	} else {
		menuDiv.style.height = '56px';
		
		var tag = document.getElementsByTagName("select");
		for (var i=0 ; i<tag.length; i++ ) {
			tag[i].style.visibility = 'visible';
		}
		isOverflow = 'auto';
	}
	
	if (navigator.appName.indexOf("Microsoft") == -1)
		{
			for (var i=0; i<divs.length; i++)
				{
					if (divs[i].getAttribute('class') == 'divScroller')
						{
							divs[i].style.overflow = isOverflow;
						}
				}
		}
}


// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub menuFlash_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call menuFlash_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}


var homeSection;
							
function homeOver(i, over) {
	var homeBtn = document.getElementById(('home_btn_'+i));
	
	if (over == 1) {
		if (i != homeSection) {
			homeBtn.src = ''+path+'images/home/home_btn_'+i+'.gif';
		}
	} else {
		if (i != homeSection) {
			homeBtn.src = ''+path+'images/home/home_btn_'+i+'_f2.gif';
		}
	}
}

function genHomeBox(temp, start) {
	var sect = 2;
	var obj = sectionArray[sect];

	if (temp != homeSection) {
	
		tempHtml = '';
		tempHtml += '	<table width="100%" border="0" cellspacing="0" cellpadding="0">';
			
			if (temp == 1) {
				tempHtml += '	<tr valign="top">';
				tempHtml += '		<td style="border:#D1D1D1 1px solid; padding:14px 19px 10px 19px;" bgcolor="#F1F1F1">';
				tempHtml += '			<table width="100%" border="0" cellspacing="0" cellpadding="0">';

					for (var i=0; i<obj.length; i++) {
						
						tempHtml += '<tr valign="bottom">';
						
						tempHtml += '<td width="63"><div class="imageFrame" style="width:63px;"><img src="'+path+'images/home/happen_img_'+(i+1)+'.jpg" width="63" height="63"></div></td>';
						tempHtml += '<td style="padding:0px 0px 0px 15px;" class="homeBox"><strong class="title">'+obj[i].name+'</strong><br><a href="'+obj[i].link+'" target="'+obj[i].target+'" class="content">'+obj[i].tempHtml+'</a></td>';
						
						tempHtml += '</tr>';
						
						if (i<(obj.length-1))	tempHtml += '<tr><td colspan="2"><img src="'+path+'images/common/spacer.gif" width="1" height="12"></td></tr>';
					
					}
				tempHtml += '			</table>';
				tempHtml += '		</td>';
				tempHtml += '	</tr>';
				
				} else {
					
					tempHtml += '	<tr valign="top">';
					tempHtml += '		<td style="border:#788CA4 1px solid;">';
						innerFlash(''+path+'images/swf/map.swf', '340', '246', 'map', '');
					tempHtml += '		</td>';
					tempHtml += '	</tr>';
			}
		
		tempHtml += '	</table>';
		
		document.getElementById('homeBox').innerHTML = tempHtml;
			if (! start) {
				var homeBtn = document.getElementById(('home_btn_'+homeSection));
				homeBtn.src = ''+path+'images/home/home_btn_'+homeSection+'.gif';
			}
			homeSection = temp;
	}
}

function getSelected()
{
	var m = document.getElementById('selectMenu');
 //alert(m.selectedIndex);
 //alert(m[m.selectedIndex].value);
	window.open(m[m.selectedIndex].value, '_blank');
}


function genFooter(pad) {
	tempHtml = '';
	
	if (pad) {
		var str = pad;
	} else {
		var str = 0;
	}
	
	tempHtml += '<table width="970" border="0" cellspacing="0" cellpadding="0">';
	tempHtml += '	<tr>';
	tempHtml += '		<td class="footer" style="padding:25px 0px 0px 7px;">';
	tempHtml += '<table cellpadding=0 cellspacing=0 border=0>';
	tempHtml += '	<tr>';
	tempHtml += '	<td valign=middle><select id="selectMenu" class="footer2" onchange="getSelected();">';
	tempHtml += '		<option>-- 太古地產網站 --</option>';
	tempHtml += '		<option value="http://www.azura.com.hk">蔚然</option>';
	tempHtml += '		<option value="http://www.citygateoutlets.com.hk/home/Pages/home.aspx?lang=TC">東薈城名店倉</option>';
	tempHtml += '		<option value="http://www.cityplaza.com/chi/default.htm">太古城中心</option>';
	tempHtml += '		<option value="http://www.icepalace.com.hk/chinese/homepage.html">太古城中心冰上皇宮</option>';
	tempHtml += '		<option value="http://www.east-hongkong.com/tc/Pages/index.aspx">東隅</option>';
	tempHtml += '		<option value="http://www.pacificplace.com.hk/tc/">太古廣場</option>';
	tempHtml += '		<option value="http://www.upperhouse.com/Pages/index.aspx">奕居</option>';
	tempHtml += '		<option value="http://www.indigobeijing.com/index.html?lang=2">頤堤港</option>';
	tempHtml += '		<option value="http://www.sanlitunvillage.com/chi/pages/index.aspx">三里屯VILLAGE</option>';
	tempHtml += '		<option value="http://www.taikoohui.com/sc/index.php">太古滙</option>';
	tempHtml += '		<option value="http://www.theoppositehouse.com/">瑜舍</option>';
	tempHtml += '		<option value="http://www.swirehotels.com">太古酒店</option>';
	tempHtml += '		<option value="http://www.chapterhotels.com">Chapter Hotels</option>';
	tempHtml += '		<option value="http://www.swireproperties.us/">Swire Properties Inc.</option>';
	tempHtml += '		<option value="http://www.swireproperties.com/tc/pages/index.aspx">太古地產</option></select></td>';
	tempHtml += '	<td valign=middle> | <a href="'+ path +'others/sitemap.htm" class="footer" title="網頁指南">網頁指南</a> | <a href="'+ path +'others/email.htm" class="footer" title="電子郵件">電郵登記</a> | <a href="javascript:addBriefcase2();" class="footer" title="我的文件夾">我的文件夾</a> | <a href="http://www.swireproperties.com/Chi/privacy+statement.htm" target="_blank" class="footer" title="私隱政策">私隱政策</a> | <a href="http://www.swireproperties.com/Chi/disclaimer.htm" target="_blank" class="footer" title="免責條款">免責條款</a> </td>';
	tempHtml += '</tr>';
	tempHtml += '	</table>';
	tempHtml += '</td>';
	tempHtml += '<td class="footer" style="padding:25px 10px 0px 0px;" align="right">&copy; 2008 太古地產 版權所有</td>';
	tempHtml += '	</tr>';
	tempHtml += '</table>';
	
	document.write(tempHtml);
	
	init();
	
	if (!isMobile)	getFontSize("contentTd");
}


function updateBuildingThumb(num, snum)
{
	var tree = siteObj["getIndex"];
	//	var bNum = tree[1].ext;
	var bNum = building; //changed by Bin
	var bNum_t = bNum;
	
	var hl = true;
	
	if (bNum < 10)
		{
			bNum_t = "0" + bNum;
		}
	
	tempHtml = '<table border="0" cellspacing="0" cellpadding="0">';
	tempHtml += '	<tr>';
	for (var i=0; i<num; i++)
		{
			hl = (i==snum);
			tempHtml += '		<td style="padding:2px 2px 0px 2px; border:'+((hl)?"#3C91CA":"#FFFFFF")+' 1px solid;">';
			tempHtml += '<a href="javascript:updateBuildingThumb('+ num +','+ i +');">';
			tempHtml += '<img src="eng/images/working/build'+bNum_t+'_0'+(1+i)+'_th.jpg" border="0" />';
//			tempHtml += '<img src="eng/images/working/building_'+bNum+'_thumb_'+(i+1)+'.jpg" border="0">';
			tempHtml += '</a>';
			tempHtml += '		</td>';	
			if (i<num)
				{
					tempHtml += '		<td><img src="eng/images/common/spacer.gif" width="2" height="1"></td>';
				}
		}
	tempHtml += '	</tr>';
	tempHtml += '</table>';
	var psnum = '';
	if (snum>0)
		{
			psnum = '_' + (snum+1);
		}
	document.getElementById("building_pho").src = path + '/images/working/building_'+bNum+'_pho'+psnum+'.jpg';
	document.getElementById("thumb").innerHTML = tempHtml;
}
function newupdateBuildingThumb(num, snum)
{
	var tree = siteObj["getIndex"];
	//	var bNum = tree[1].ext;
	var bNum = building; //changed by Bin

	var hl = true;
	
	
	tempHtml = '<TABLE id=Table1><TBODY><TR><TD><TABLE id=Table3 cellSpacing=0 cellPadding=0 border=0><TBODY><TR>';
	for (var i=0; i<num; i++)
		{
			hl = (i==snum);
			tempHtml += '		<td style="padding:2px 2px 0px 2px; border:'+((hl)?"#3C91CA":"#FFFFFF")+' 1px solid;">';
			tempHtml += '<a href="javascript:newupdateBuildingThumb('+ num +','+ i +');">';
			tempHtml += imagetn[i];
			tempHtml += '</a>';
			tempHtml += '		</td>';	
			if (i<num)
				{
					tempHtml += '		<td><img src="chi/images/common/spacer.gif" width="2" height="1"></td>';
				}
		}
	tempHtml += '</TR></TBODY></TABLE></TD></TR></TBODY></TABLE>';
	var psnum = '';
	if (snum>0)
		{
			psnum = '_' + (snum+1);
		}
	document.getElementById("building_pho").src = imagebig[snum];
	document.getElementById("thumb").innerHTML = tempHtml;
}
function genBuildingThumb(num)
{
	var tree = siteObj["getIndex"];
//	var bNum = tree[1].ext;
	var bNum = buildingpara; //changed by Bin
	var hl = true;
	
	if (bNum < 10)
		{
			bNum = "0" + bNum;
		}
	
	tempHtml = '<table border="0" cellspacing="0" cellpadding="0">';
	tempHtml += '	<tr>';
	for (var i=0; i<num; i++)
		{
			hl = (i==0);
			tempHtml += '		<td style="padding:2px 2px 0px 2px; border:'+((hl)?"#3C91CA":"#FFFFFF")+' 1px solid;">';
			tempHtml += '<a href="javascript:updateBuildingThumb('+ num +','+ i +');">';
			tempHtml += '<img src="eng/images/working/build'+bNum+'_0'+(1+i)+'_th.jpg" border="0" />';
			tempHtml += '</a>';
			tempHtml += '		</td>';	
			if (i<num)
				{
					tempHtml += '		<td><img src="eng/images/common/spacer.gif" width="2" height="1"></td>';
				}
		}
	tempHtml += '	</tr>';
	tempHtml += '</table>';
	document.write(tempHtml);
}

function genBuilding()
{
	var num = 13;
	var topArray = new Array(100,100,100,90,90,80,40,48,55,80,50,55,-27);
	var leftArray = new Array(5,66,123,180,225,260,270,348,383,420,462,505,545);
	var paddingArray = new Array(9,9,9,2,9,9,0,9,9,9,9,9,0);
	
	var icontopArray = new Array(90,90,90,95,95,70,40,35,80,80,40,45,-35);
	var iconleftArray = new Array(17,79,137,196,243,285,320,351,393,435,478,519,565);

	
	var tree = siteObj["getIndex"];
	//	var bNum = tree[1].ext;
	var bNum = buildingpara; //changed by Bin

	tempHtml	= '';
	tempHtml += '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
	tempHtml += '	<tr valign="bottom">';
	tempHtml += '		<td class="content" style="border-bottom:#3C91CA 1px solid; padding:0px 0px 0px 10px;">';
	
	tempHtml += '			<div style="position:absolute;">';
	for (var i=0; i<num; i++)
		{
			if ((i+1) == building)	
				{
					tempHtml += '			<div style="position:absolute; left:'+iconleftArray[i]+'px; top:'+icontopArray[i]+'px;" id="name'+(i+1)+'">';
				//	tempHtml += '<a href="chi/introduction/transportation/map.htm?gosection='+bNum+'B">';
					tempHtml += '<a href="chi/introduction/transportation/map.htm?gosection='+buildingpara+'B">';
					tempHtml += '<img src="chi/images/working/icon_map.gif" border="0">';
					tempHtml += '</a>';
					tempHtml += '</div>';
				}
			else
				{
					// if ((i+1)==num)
						// {
							// tempHtml += '			<div style="visibility:show; position:absolute; left:'+leftArray[i]+'px; top:'+topArray[i]+'px;" id="name'+(i+1)+'"><img src="chi/images/working/name_'+(i+1)+'.gif"></div>';
						// }
					// else
						// {
							tempHtml += '			<div style="visibility:hidden; position:absolute; left:'+leftArray[i]+'px; top:'+topArray[i]+'px;" id="name'+(i+1)+'"><img src="chi/images/working/name_'+(i+1)+'.gif"></div>';
						//}
				}
		}
	tempHtml += '			</div>';
	
	tempHtml += '			<table border="0" cellspacing="0" cellpadding="0" id="buildingNav">';
	tempHtml += '				<tr valign="bottom">';
	for (var i=0; i<num; i++)
		{
			if ((i+1) == building)	
				{
					tempHtml += '					<td style="padding:0px '+paddingArray[i]+'px 0px 0px;"><img src="chi/images/working/building_'+(i+1)+'_f2.gif" border="0" name="building_'+(i+1)+'"></td>';
				}
			else
				{
					tempHtml += '					<td style="padding:0px '+paddingArray[i]+'px 0px 0px;">';
					if ((i+1) != 7)
						{
							tempHtml += '					<a href="chi/working/portfolio/specification/building'+(i+1)+'.htm" onMouseOver="javascript:MM_showHideLayers(\'name'+(num+1)+'\',\'\',\'hidden\'); MM_swapImage(\'building_'+(num+1)+'\',\'\',\'chi/images/working/building_'+(num+1)+'.gif\',1);MM_showHideLayers(\'name'+(i+1)+'\',\'\',\'show\'); MM_swapImage(\'building_'+(i+1)+'\',\'\',\'chi/images/working/building_'+(i+1)+'_f2.gif\',1);" onMouseOut="javascript:MM_showHideLayers(\'name'+(i+1)+'\',\'\',\'hidden\'); MM_swapImage(\'building_'+(i+1)+'\',\'\',\'chi/images/working/building_'+(i+1)+'.gif\',1);">';
						} else {
							tempHtml += '					<a href="chi/working/portfolio/specification/building'+(i+1)+'.htm" onMouseOver="javascript:MM_showHideLayers(\'name'+(num+1)+'\',\'\',\'hidden\'); MM_swapImage(\'building_'+(num+1)+'\',\'\',\'chi/images/working/building_'+(num+1)+'.gif\',1);MM_showHideLayers(\'name'+(i+1)+'\',\'\',\'show\'); MM_swapImage(\'building_'+(i+1)+'\',\'\',\'chi/images/working/building_'+(i+1)+'_f2.gif\',1);" onMouseOut="javascript:MM_showHideLayers(\'name'+(i+1)+'\',\'\',\'hidden\'); MM_swapImage(\'building_'+(i+1)+'\',\'\',\'chi/images/working/building_'+(i+1)+'.gif\',1);">';
						}
					// if ((i+1)==num)
						// {
							// tempHtml += '					<img src="chi/images/working/building_'+(i+1)+'_f2.gif" border="0" name="building_'+(i+1)+'"></a></td>';
						// }
					// else
						// {
							tempHtml += '					<img src="chi/images/working/building_'+(i+1)+'.gif" border="0" name="building_'+(i+1)+'"></a></td>';
						// }
				}
		}
		
	tempHtml += '				</tr>';
	tempHtml += '			</table>';
	tempHtml += '		</td>';
	tempHtml += '	</tr>';
	tempHtml += '</table>';
	
	document.write(tempHtml);
	
	if (isMobile)
	{
		setTimeout(function()
		{
			var buildingNav = d.getElementById('buildingNav');
			var a = buildingNav.getElementsByTagName('a');
			//alert(a.length);
			for (var i=0; i<a.length; i++)
			{
				a[i].onmouseover = null;
				a[i].onmouseout = null;
			}
		}, 500);
	}
}
function clickThumbImage(filename,id) {

	//var detailsTD = document.getElementById('archive_'+id);
	
	//if (!(detailsTD)) return;
	
	//if (!detailsTD.clicked) {
	//	document.getElementById('imageContainer1').src = filename+'.jpg';
	document.getElementById('imageContainer1').src = filename+'';
	//}
}

function clickImage(year, place, id) {

	var detailsTD = document.getElementById('archive_'+id);
	
	if (!(detailsTD)) return;
	
	if (!detailsTD.clicked) {
		document.getElementById('imageContainer1').src = path+'images/events/archive_pho_'+year+'_'+place+'_'+id+'.jpg';
	}
}
///////////////////////////////////////////////////////////
// Reflesh Company Table Function 
///////////////////////////////////////////////////////////

var debugStr = "";
var debugMode = false;


function trace() {
	if (arguments.length != 0) {
		debugMode = true ;
		debugStr += arguments[0] + "\n";
	} else {
		alert(debugStr);
		debugStr = "";
	}
}


var alphabetTab_array = new Array();
var alphabetTab_current = null;

function changeClass(elem, toName) {
	if (!(elem.setAttribute('class', toName) )) {
		elem.className = toName;
	}
}

function changeButtonStatus() {
	var idStr = arguments[0];
	var targetElement = document.getElementById(arguments[0]);
	if (!targetElement) return false;
	//status = {'link', 'hover','active','selected','visited'};

	var status = arguments[1];
	switch (status) {
		case 'link':
			
			if (alphabetTab_current != idStr) {				
				changeClass(targetElement, "comTableNormal");
			}
			break;
		case 'hover':
			trace('alphabetTab_current=' + alphabetTab_current + ' ; idStr = ' +  idStr);
			if (alphabetTab_current != idStr) {				
				changeClass(targetElement, "comTableHover");
			}
			break;
		case 'selected':			
			alphabetTab_current = idStr;
			changeButtonOthersExcept(idStr, alphabetTab_array);			
			changeClass(targetElement, "comTableSelected");
			break;
		case 'active':
			break;
		case 'visited':
			break;
		default:
			if (alphabetTab_current != idStr) {				
				changeClass(targetElement, "comTableNormal");
			}		
	}
}

function changeButtonOthersExcept(targetStr, buttonArray) {
	for (var item in buttonArray) {			
		if (item != targetStr) {
			changeClass(document.getElementById(item), "comTableNormal");			
		}
	}

}

function genAlphabetTab() {		
	var menu = document.getElementById('AlphabetTab');
	var tempHtml = "";
	
	tempHtml += '<table width="100%" border="0" cellpadding="0" cellspacing="0" >\n';
	tempHtml += '	<tr valign="top">\n';
	tempHtml += '	<td align="center" style="padding:1px 10px 0px 10px;">\n';
	for (var i = 0 ; i < 26; i++) {
		var code = String.fromCharCode(65 + i);
		var idBaseStr = 'tab_';
		var idStr = idBaseStr + code;
		alphabetTab_array[idStr] = {id:idStr};
tempHtml += '<a id="'+ idStr +'" href="chi/working/ingoodcompany/ingoodcompany.htm?key=' + code + '" class="comTableNormal" onmouseover="changeButtonStatus(\''+ idStr + '\', \'hover\')" onmouseout="changeButtonStatus(\''+ idStr + '\', \'link\')" >'+ code +'</a>';		
		if (i<25) {tempHtml += ' |\n';}
	}

/*tempHtml += '<br><a id="'+ idStr +'" href="company.htm?key=' + "1" + '" class="comTableNormal" onmouseover="changeButtonStatus(\''+ idStr + '\', \'hover\')" onmouseout="changeButtonStatus(\''+ idStr + '\', \'link\')" >'+ "1-5劃" +'</a>';		
tempHtml += ' |\n';

tempHtml += '<a id="'+ idStr +'" href="company.htm?key=' + "6" + '" class="comTableNormal" onmouseover="changeButtonStatus(\''+ idStr + '\', \'hover\')" onmouseout="changeButtonStatus(\''+ idStr + '\', \'link\')" >'+ "6-10劃" +'</a>';		
tempHtml += ' |\n';

tempHtml += '<a id="'+ idStr +'" href="company.htm?key=' + "11" + '" class="comTableNormal" onmouseover="changeButtonStatus(\''+ idStr + '\', \'hover\')" onmouseout="changeButtonStatus(\''+ idStr + '\', \'link\')" >'+ "11-15劃" +'</a>';		
tempHtml += ' |\n';

tempHtml += '<a id="'+ idStr +'" href="company.htm?key=' + "16" + '" class="comTableNormal" onmouseover="changeButtonStatus(\''+ idStr + '\', \'hover\')" onmouseout="changeButtonStatus(\''+ idStr + '\', \'link\')" >'+ "16-20劃" +'</a>';		
tempHtml += ' |\n';

tempHtml += '<a id="'+ idStr +'" href="company.htm?key=' + "21" + '" class="comTableNormal" onmouseover="changeButtonStatus(\''+ idStr + '\', \'hover\')" onmouseout="changeButtonStatus(\''+ idStr + '\', \'link\')" >'+ "21-25劃" +'</a>';		
tempHtml += ' |\n';

tempHtml += '<a id="'+ idStr +'" href="company.htm?key=' + "26" + '" class="comTableNormal" onmouseover="changeButtonStatus(\''+ idStr + '\', \'hover\')" onmouseout="changeButtonStatus(\''+ idStr + '\', \'link\')" >'+ ">26劃" +'</a>';		
tempHtml += ' |\n';*/


	tempHtml +=  '</td>\n';	
	tempHtml += '	</tr>\n';
    tempHtml += '</table>\n';

	menu.innerHTML = tempHtml;
}



function refleshCompanyTable(alphabet) {
	var tempHtml = '';
	var code = alphabet;

	tempHtml += '<table width="100%" border="0" cellspacing="0" cellpadding="0">\n';
	tempHtml += '<tr valign="top">\n';
	tempHtml += '  <td width="300" class="blue" style="padding:0px 10px 20px 0px;"><a href="http://www.home.agilent.com/agilent/home.jspx?lc=eng&cc=HK" target="_black" class="blue">Agilent Technologies HK Ltd.</a></td>\n';
	tempHtml += '  <td class="content" style="padding:0px 0px 20px 0px;"><a href="http://www.home.agilent.com/agilent/home.jspx?lc=eng&cc=HK" target="_black" class="blue">Agilent Technologies HK Ltd.</a></td>\n';
	tempHtml += '</tr>\n';
	tempHtml += '<tr valign="top">\n';
	tempHtml += '  <td width="300" class="blue" style="padding:0px 10px 20px 0px;">'+code +'BN AMRO Bank N.V.</td>\n';
	tempHtml += '  <td class="blue" style="padding:0px 0px 20px 0px;">'+code +'BN AMRO Bank N.V.</td>\n';
	tempHtml += '</tr>\n';
	tempHtml += '<tr valign="top">\n';
	tempHtml += '  <td width="300" class="blue" style="padding:0px 10px 20px 0px;">'+code +'BN AMRO Bank N.V.</td>\n';
	tempHtml += '  <td class="blue" style="padding:0px 0px 20px 0px;">'+code +'BN AMRO Bank N.V.</td>\n';
	tempHtml += '</tr>\n';
	tempHtml += '<tr valign="top">\n';
	tempHtml += '  <td width="300" class="blue" style="padding:0px 10px 20px 0px;">'+code +'BN AMRO Bank N.V.</td>\n';
	tempHtml += '  <td class="blue" style="padding:0px 0px 20px 0px;">'+code +'BN AMRO Bank N.V.</td>\n';
	tempHtml += '</tr>\n';
	tempHtml += '<tr valign="top">\n';
	tempHtml += '  <td width="300" class="blue" style="padding:0px 10px 20px 0px;">'+code +'BN AMRO Bank N.V.</td>\n';
	tempHtml += '  <td class="blue" style="padding:0px 0px 20px 0px;">'+code +'BN AMRO Bank N.V.</td>\n';
	tempHtml += '</tr>\n';
	tempHtml += '<tr valign="top">\n';
	tempHtml += '  <td width="300" class="blue" style="padding:0px 10px 20px 0px;">'+code +'BN AMRO Bank N.V.</td>\n';
	tempHtml += '  <td class="blue" style="padding:0px 0px 20px 0px;">'+code +'BN AMRO Bank N.V.</td>\n';
	tempHtml += '</tr>\n';
	tempHtml += '<tr valign="top">\n';
	tempHtml += '  <td width="300" class="blue" style="padding:0px 10px 20px 0px;">'+code +'BN AMRO Bank N.V.</td>\n';
	tempHtml += '  <td class="blue" style="padding:0px 0px 20px 0px;">'+code +'BN AMRO Bank N.V.</td>\n';
	tempHtml += '</tr>\n';
	tempHtml += '<tr valign="top">\n';
	tempHtml += '  <td width="300" class="blue" style="padding:0px 10px 20px 0px;">'+code +'BN AMRO Bank N.V.</td>\n';
	tempHtml += '  <td class="blue" style="padding:0px 0px 20px 0px;">'+code +'BN AMRO Bank N.V.</td>\n';
	tempHtml += '</tr>\n';
	tempHtml += '<tr valign="top">\n';
	tempHtml += '  <td width="300" class="blue" style="padding:0px 10px 20px 0px;">'+code +'BN AMRO Bank N.V.</td>\n';
	tempHtml += '  <td class="blue" style="padding:0px 0px 20px 0px;">'+code +'BN AMRO Bank N.V.</td>\n';
	tempHtml += '</tr>\n';
	tempHtml += '<tr valign="top">\n';
	tempHtml += '  <td width="300" class="blue" style="padding:0px 10px 20px 0px;">'+code +'BN AMRO Bank N.V.</td>\n';
	tempHtml += '  <td class="blue" style="padding:0px 0px 20px 0px;">'+code +'BN AMRO Bank N.V.</td>\n';
	tempHtml += '</tr>\n';
	tempHtml += '</table>\n';

	document.getElementById('CompanyTable').innerHTML = tempHtml;
}

function initPage() {
	genAlphabetTab();	
}

//brief case function starts

var BriefcaseTimeoutId = 0;

function addBriefcase()
{
	var pb = new BriefcaseBasket();
	
	var title = document.title;
	//Modified on 15 Aug 2007 by gary, Client request to show Page name instead of page title
	var pageNameElement = document.getElementById("title");
	title = pageNameElement.innerHTML;	

	var url = document.URL;
	var BriefcaseMsg = document.getElementById("addBriefcaseMessage");
	
	if (pb.addBriefcaseItem(title, url)) {
		//updateBriefcase();
		//alert("new print item added");
		BriefcaseMsg.innerHTML = "<span style=\"color:#F00;\">This page was added to Briefcase basket.</span>";
	}
	else {
		// print item added before
		//alert("the print item added before");
		BriefcaseMsg.innerHTML = "<span style=\"color:#2543C3;\">This page has been added to Briefcase basket before.</span>";
	}
	BriefcaseTimeoutId = setTimeout("clearBriefcaseMessage()", 5000);
}
function addItems()
{
	var pb = new BriefcaseBasket();	
	var dtitle = document.formadd.title.value;
	//Modified on 15 Aug 2007 by gary, Client request to show Page name instead of page title
	var durl = document.formadd.titleUrl.value;	
	if (pb.addBriefcaseItem(dtitle, durl)) {
	   //		
	}
	
	BriefcaseTimeoutId = setTimeout("clearBriefcaseMessage()", 5000);
}
function addBriefcase2()
{
	var title = document.title;
	var url = document.URL;
    createCookie('tempTitle', title, 30);
    createCookie('tempUrl', url, 30);
    newwindow=window.open(path +'others/briefcase.htm','briefcase','toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=500,height=350');  

}

function clearBriefcaseMessage()
{
	var BriefcaseMsg = document.getElementById("addBriefcaseMessage");
	BriefcaseMsg.innerHTML = "";
	clearTimeout(BriefcaseTimeoutId);
}

// Briefcase obj
function BriefcaseBasket() {
	this._cookieNamePrefix += 'eng' + "_";
	this.BriefcaseItems = this.getBriefcaseItemFromCookie();
}

BriefcaseBasket.prototype.BriefcaseItems = new Array();
BriefcaseBasket.prototype._duration = 30; //days
BriefcaseBasket.prototype._cookieNamePrefix = "swire_briefcase_basket_";

BriefcaseBasket.prototype.addBriefcaseItem = function(title, url) {
	
	var count = 0;
	var len = this.BriefcaseItems.length;
	for (var i = 0; i < len; i++) {
		if (this.BriefcaseItems[i].url != url) {
			count++;
		}
		else {
			break;
		}
	}
	
	if (count == len) {
		this.BriefcaseItems.push(new BriefcaseItem(title, url));
		this.addBriefcaseItemToCookie(this.BriefcaseItems.length - 1, title, url);
		return true;
	}
	else {
		return false;
	}
}

BriefcaseBasket.prototype.deleteBriefcaseItem = function(idx) {
	this.BriefcaseItems.splice(idx, 1);
	this.resetBriefcaseItemToCookie();
}

BriefcaseBasket.prototype.clearAllBriefcaseItems = function(idx) {
	this.BriefcaseItems = new Array();
	this.eraseAllBriefcaseItemsFromCookie();
}

BriefcaseBasket.prototype.getBriefcaseItemFromCookie = function() {
	var i = 0;
	var items = new Array();
	while (1) {
		var title = readCookie(this._cookieNamePrefix + "title" + i);
		var url = readCookie(this._cookieNamePrefix + "url" + i);
		if ((title != null) && (url != null)) {
			items.push(new BriefcaseItem(title, url));
			i++;
		}
		else {
			break;
		}
	}
	return items;
}

BriefcaseBasket.prototype.addBriefcaseItemToCookie = function(idx, title, url) {
	createCookie(this._cookieNamePrefix + "title" + idx, title, this._duration);
	createCookie(this._cookieNamePrefix + "url" + idx, url, this._duration);
}

BriefcaseBasket.prototype.resetBriefcaseItemToCookie = function() {
	this.eraseAllBriefcaseItemsFromCookie();
	var len = this.BriefcaseItems.length;
	for (var i = 0; i < len; i++) {
		createCookie(this._cookieNamePrefix + "title" + i, this.BriefcaseItems[i].title, this._duration);
		createCookie(this._cookieNamePrefix + "url" + i, this.BriefcaseItems[i].url, this._duration);
	}
}

BriefcaseBasket.prototype.eraseAllBriefcaseItemsFromCookie = function() {
	eraseAllCookies(this._cookieNamePrefix);
}

// print item obj
function BriefcaseItem(title, url) {
	this.title = title;
	this.url = url;
}

BriefcaseItem.prototype.title = "";
BriefcaseItem.prototype.url = "";

// cookie util
function createCookie(name,value,days) {
	value = encodeURIComponent(value);
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return decodeURIComponent(c.substring(nameEQ.length,c.length));
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function eraseAllCookies(prefix) {
	
	var pattern = new RegExp(prefix + "[^=]*=", "g");
	var names = document.cookie.match(pattern);
	
	if (names != null) {
		var len = names.length;
		for (var i = 0; i < len; i++) {
			eraseCookie(names[i].substr(0, names[i].length-1));
		}
	}
	
}
function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f
	
	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );
		
		
		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
	
		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}				
	
	
		var pb = new BriefcaseBasket();
	
	function addPb() {
		var title = document.addBriefcaseBasketForm.store_name.value;;
		var url = document.addBriefcaseBasketForm.title_url.value;
		
		if (pb.addBriefcaseItem(title, url)) {
			updateBriefcaseBasket();
			alert("Added to Briefcase Basket");
		}
		else {
			// Briefcase item added before
			alert("Exist in Briefcase Basket");
		}
	}
	
	function deleteBriefcaseItems() {
		var len = pb.BriefcaseItems.length;
		var count = 0;		
		
		for (var i = 0; i < len; i++) {
			if (document.BriefcaseBasketForm["BriefcaseBasketItem" + i].checked) {
				pb.deleteBriefcaseItem(i - count);
				count++;
			}
		}
		updateBriefcaseBasket();
	}
	function parentchange(url) {  
     parent.window.opener.document.location.href = url;  
}		
	function clearBasket() {
		pb.clearAllBriefcaseItems();
		updateBriefcaseBasket();
	}
	
	function updateBriefcaseBasket() {
		var len = pb.BriefcaseItems.length;
		var html = "";	
			
		html += "<table id=\"BriefcaseBasketTable\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">";
		for (var i = 0; i < len; i++) {
			html +=
			"<tr>"+
			"	<td width=\"23\" style=\"padding:7px 0px 0px 0px;\" align=\"center\"><img src=\"../images/common/pt_gray.gif\" width=\"3\" height=\"3\"></td>"+
			"	<td d=\"BriefcaseBasketContentDetails\" class=\"content\" widht=\"99%\"><strong>"+
			"		<a href=\"#\" onClick=\"parentchange('"+ pb.BriefcaseItems[i].url + "')\">" + pb.BriefcaseItems[i].title + "</a>"+
			"	</strong></td>"+		
			"	<td width=\"4%\" class=\"content\" style=\"padding:0px 5px 0px 0px;\" align=\"left\">"+
			"		<input type='checkbox' name='BriefcaseBasketItem" + i + "' value='" + i + "'/>"+
			"	</td>"+		
			"</tr>"+
			"<tr>"+
			"<td colspan=\"3\" style=\"background:url(../images/common/dash.gif) repeat-x center;\"><img src=\"../images/common/spacer.gif\" width=\"1\" height=\"11\"></td>"+
			"</tr>"+
			"<tr>"+
			"	<td id=\"dottedLineHorizontal\" colspan=\"5\" width=\"505\"/></td>"+
			"</tr>";
		}
		html += "</table>";	
		document.getElementById("BriefcaseBasketItems").innerHTML = html;
	}

	function selectAllBriefcaseItem(flag) {
		var len = pb.BriefcaseItems.length;
		for (var i = 0; i < len; i++) {
			document.BriefcaseBasketForm["BriefcaseBasketItem" + i].checked = flag;
		}
	}
	
function displayGoogleSearch(ele) {
	str = "";
	str += "<!-- Google CSE Search Box Begins  -->\n";
	str += "<form target=\"_blank\" action=\"#\" id=\"searchbox_000109602145754868180:1_dflormmr8\">\n";
	str += "  <input type=\"hidden\" name=\"cx\" value=\"000109602145754868180:1_dflormmr8\" />\n";
	str += "  <input type=\"hidden\" name=\"cof\" value=\"FORID:11\" />\n";
	str += "  <input type=\"text\" name=\"q\" class=\"googleSearchBox\"/>\n";
	str += "  <input type=\"submit\" name=\"sa\" value=\"Search\" />\n";
	str += "</form>\n";
	str += "<!-- Google CSE Search Box Ends -->\n";

	$(ele).innerHTML = str;
}

function displayMiceGoogleSearch(ele) {
	str = "";
	str += "<!-- Google CSE Search Box Begins  -->\n";
	str += "<form target=\"_blank\" action=\"#\" id=\"searchbox_000109602145754868180:1_dflormmr8\">\n";
	str += "  <input type=\"hidden\" name=\"cx\" value=\"000109602145754868180:1_dflormmr8\" />\n";
	str += "  <input type=\"hidden\" name=\"cof\" value=\"FORID:11\" />\n";
	str += "  <input type=\"text\" name=\"q\" class=\"googleSearchBox\"/>\n";
	str += "  <input type=\"submit\" name=\"sa\" value=\"Search\" />\n";
	str += "</form>\n";
	str += "<!-- Google CSE Search Box Ends -->\n";

	$(ele).innerHTML = str;
}

/* ipad version starts */
function genIpadTopNav()
{
	var xmlPath = lang + '/images/swf/nav.xml';
	if (isSearch)	xmlPath = '../../../' + xmlPath;
	
	//var container = d.getElementById('topNav');
	var contentTD;
	var container;
	
	var pulldown;
	var colArray = new Array();
	var subPulldownArray = new Array();
	var total = 0;
	var overlay;
	var self = this;
	
	this.init = function()
	{
		$.ajax(
		{
			url:xmlPath,
			dataType:'xml',
			cache:false,
			async:false,
			success: function(data)
			{
				contentTD = d.getElementById('contentTD');
				if (!contentTD)	contentTD = d.getElementById('contentTd');
				if (!contentTD)
				{
					container = d.getElementById('topNav');
				}
				else
				{
					container = contentTD.parentNode;
				}
				
				var navs = data.firstChild.childNodes;
				self.genTopNav(navs);
				
				self.xmlDone();
			},
			error:function(e)
			{
				//alert(e)
				//xmlPath = path + 'images/swf/nav.xml';
				//self.init();
			}
		});
	};
	
	this.xmlDone = function()
	{
		overlay = createDiv('topNavOverlay', '');
		overlay.addEventListener('touchstart', onTouchStart);
		
		//var table = d.getElementsByTagName('table')[0];
		//table.addEventListener('touchstart', onTouchStart);
		
		function onTouchStart(e)
		{
			self.pulldownShow(false);
		}
	};
	
	this.genTopNav = function(data)
	{
		var topNavigation = createDiv('topNavigation');
		var ul = createTag('ul', '', 'topNav');
		var navId;
		
		for (var i=0; i<data.length; i++)
		{
			if (data[i].nodeName != 'nav')	continue;
			
			var name = data[i].getAttribute('name').toString();
			var id = data[i].getAttribute('id').toString();
			
			var li = d.createElement('li');
			
			var a = createA('javascript:;', '');
			var span = d.createElement('span');
			span.innerHTML = name;
			a.appendChild(span);
			
			a.navId = id;
			if (i >= data.length - 2)	a.className = 'last';
			a.onclick = function()
			{
				self.navClick(this.navId);
				self.subNavClick(null);
			}
			
			//Highlight
			if (level1 == id)	a.className += ' active';
			
			li.appendChild(a);
			ul.appendChild(li);
			
			total ++;
		}
		
		topNavigation.appendChild(ul);
		container.appendChild(topNavigation);
		
		//Pulldown
		var topNavigationDropdown = createDiv('topNavigationDropdown');
		var transparentBg = createDiv('', 'transparentBg');
		var dropDownContent = createDiv('', 'dropDownContent');
		
		for (var i=0; i<data.length; i++)
		{
			if (data[i].nodeName != 'nav')	continue;
			
			var id = data[i].getAttribute('id').toString();
			var navData = data[i].childNodes;
			navId = id;
				
			var dashedContainer = createDiv('', 'dashedContainer');
			var div = createDiv('', id + 'Col');
			var ul = createTag('ul', '', 'subNav');
			
			//Pulldown Nav
			for (var j=0; j<navData.length; j++)
			{
				if (navData[j].nodeName != 'nav')	continue;
				
				var name = navData[j].getAttribute('name').toString();
				var level2Id = navData[j].getAttribute('id').toString();
				var link = navData[j].getAttribute('link').toString();
				var target = navData[j].getAttribute('target').toString();
				
				//Hard Code Remove Map
				//if (link.indexOf('introduction/transportation/map.htm') >= 0)	continue;
				
				var li = d.createElement('li');
				var a = createA(lang + '/' + link, target, name);
				li.appendChild(a);
				
				//Highlight
				if (level1 == id && level2 == level2Id)	li.className += ' highlight';
				
				//Pulldown SubNav
				if (navData[j].childNodes.length)
				{
					a.href = 'javascript:;';
					a.target = '';
					a.className = 'arrow';
					a.num = subPulldownArray.length;
					a.navId = navId;
					a.onclick = function()
					{
						self.navClick(this.navId);
						self.subNavClick(this.num);
					}
					
					var subNavData = navData[j].getElementsByTagName('nav');
					var subUL = createTag('ul', '', 'subNav_sub');
					
					//Landing Nav
					var subLI = d.createElement('li');
					var a = createA(lang + '/' + link, target, '簡介');
					subLI.appendChild(a);
					subUL.appendChild(subLI);
						
					//Highlight
					if (level2 == level2Id && level3 == '')	subLI.className += ' highlight';
					
					for (var k=0; k<subNavData.length; k++)
					{
						var name = subNavData[k].getAttribute('name').toString();
						var level3Id = subNavData[k].getAttribute('id').toString();
						var link = subNavData[k].getAttribute('link').toString();
						var target = subNavData[k].getAttribute('target').toString();
						
						var subLI = d.createElement('li');
						var a = createA(lang + '/' + link, target, name);
						subLI.appendChild(a);
						subUL.appendChild(subLI);
						
						//Highlight
						if (level2 == level2Id && level3 == level3Id)	subLI.className += ' highlight';
					}
					
					li.appendChild(subUL);
					subPulldownArray.push(subUL);
				}
				
				ul.appendChild(li);
			}
			
			div.appendChild(ul);
			dashedContainer.appendChild(div);
			dropDownContent.appendChild(dashedContainer);
			colArray.push(div);
		};
		
		topNavigationDropdown.appendChild(transparentBg);
		topNavigationDropdown.appendChild(dropDownContent);
		topNavigation.appendChild(topNavigationDropdown);
		
		pulldown = topNavigationDropdown;
	};
	
	this.navClick = function(id)
	{
		//var container = d.getElementById(id + 'Col');
		for (var i=0; i<colArray.length; i++)
		{
			if (colArray[i].className.indexOf(id + 'Col') >= 0)
			{
				colArray[i].className += ' active';
			}
			else
			{
				colArray[i].className = colArray[i].className.replace(/active/g, '');
			}
		}
		this.pulldownShow(true);
	};
	
	this.pulldownShow = function(isShow)
	{
		pulldown.style.display = (isShow)?	'block':'none';
		
		if (isShow)
		{
			container.appendChild(overlay);
		}
		else
		{
			container.removeChild(overlay);
		}
	};
	
	this.subNavClick = function(id)
	{
		for (var i=0; i<subPulldownArray.length; i++)
		{
			if (id == i)
			{
				if (subPulldownArray[i].style.display == 'block')
				{
					subPulldownArray[i].style.display = 'none';
					subPulldownArray[i].parentNode.className = subPulldownArray[i].parentNode.className.replace(/active/g, '');
				}
				else
				{
					subPulldownArray[i].style.display = 'block';
					subPulldownArray[i].parentNode.className += ' active';
				}
			}
			else
			{
				subPulldownArray[i].style.display = 'none';
				subPulldownArray[i].parentNode.className = subPulldownArray[i].parentNode.className.replace(/active/g, '');
			}
		}
		this.pulldownShow(true);
	};
	
	this.init();
}
/* ipad version ends */
