function popupLayerDown(divId) 
{
	state=typeof topPos;
	if(state=='undefined') 
		topPos=-260;

	if(topPos < 250)
	{ 
		topPos+=8;
		if (document.layers) 
			document.layers[divId].top = topPos;
		else if (document.all) 
			document.all[divId].style.top = topPos;
		else if (document.getElementById) 
			document.getElementById(divId).style.top = topPos;	

		setTimeout("popupLayerDown('" + divId + "');",20);
	}
}
function hidePopupLayer(divId){
	if (document.layers) 
		document.layers[divId].visibility ='hidden';
	else if (document.all) 
		document.all[divId].style.visibility ='hidden';
    else if (document.getElementById) 
		document.getElementById(divId).style.visibility = 'hidden';	
}
function eng_chi(){
var lastURL=window.location.href;
var newURL=lastURL.replace(/\/eng\//i,'\/chi\/');
window.location.href=newURL;
}
function chi_eng(){
var lastURL=window.location.href;
var newURL=lastURL.replace(/\/chi\//i,'\/eng\/');
window.location.href=newURL;
}
function MenuItem(name,parent){
	
	this.javascript="";
	this.url="";
	this.name=name;
	this.label=name;
	this.parent=parent;
	this.subMenu=new Array();
	this.applyToChild="true";
	this.target=parent && parent.applyToChild=="true"?parent.target:"";
	this.align=parent && parent.applyToChild=="true"?parent.align:"";
	this.ID=parent && parent.applyToChild=="true"?parent.ID+"_"+this.name:this.name;	
	this.level=parent && parent.applyToChild=="true"?parent.level+1:0;	
	this.separator=parent && parent.applyToChild=="true"?parent.separator:"";
	this.separatorCss=parent && parent.applyToChild=="true"?parent.separatorCss:"";
	this.header=parent && parent.applyToChild=="true"?parent.header:"";
	this.headerCss=parent && parent.applyToChild=="true"?parent.headerCss:"";
	this.leftItem=parent && parent.applyToChild=="true"?parent.leftItem:"";
	this.rightItem=parent && parent.applyToChild=="true"?parent.rightItem:"";
	this.footer=parent && parent.applyToChild=="true"?parent.footer:"";
	this.footerCss=parent && parent.applyToChild=="true"?parent.footerCss:"";	
	this.tableCss=parent && parent.applyToChild=="true"?parent.tableCss:"";
	this.layerCss=parent && parent.applyToChild=="true"?parent.layerCss:"";
	this.layerWidth=parent && parent.applyToChild=="true"?parent.layerWidth:0;
	this.rollOverCss=parent && parent.applyToChild=="true"?parent.rollOverCss:"";
	this.rollOutCss=parent && parent.applyToChild=="true"?parent.rollOutCss:"";
	this.separatorCss=parent && parent.applyToChild=="true"?parent.separatorCss:"";
	this.xoffset=parent && parent.applyToChild=="true"?parent.xoffset:0;	
	this.yoffset=parent && parent.applyToChild=="true"?parent.yoffset:0;
	this.width=parent && parent.applyToChild=="true"?parent.width:0;
	this.height=parent && parent.applyToChild=="true"?parent.height:0;
	this.x=0;
	this.y=0;
	this.rollOverImage="";
	this.rollOutImage="";
	
}

MenuItem.prototype.isRoot=MenuItem_isRoot;
MenuItem.prototype.find=MenuItem_find;
MenuItem.prototype.addMenu=MenuItem_addMenu;
MenuItem.prototype.buildNav=MenuItem_buildNav;
MenuItem.prototype.buildSubNav=MenuItem_buildSubNav;
MenuItem.prototype.buildNavItem=MenuItem_buildNavItem;
MenuItem.prototype.setPosition=MenuItem_setPosition;
MenuItem.prototype.setSubPosition=MenuItem_setSubPosition;
MenuItem.prototype.setXmlNode=MenuItem_setXmlNode;


function MenuItem_setXmlNode(node){
	this.name=getNodeValue(node,"@name",this.name);
	this.url=getNodeValue(node,"@url",this.url);
	this.target=getNodeValue(node,"@target",this.target);
	this.label=getNodeValue(node,"@label",this.label);
	this.javascript=getNodeValue(node,"@javascript",this.javascript);
	this.align=getNodeValue(node,"@align",this.align);	
	this.separator=getNodeValue(node,"@separator",this.separator);
	this.leftItem=getNodeValue(node,"@leftItem",this.leftItem);
	this.rightItem=getNodeValue(node,"@rightItem",this.rightItem);
	this.header=getNodeValue(node,"@header",this.header);
	this.footer=getNodeValue(node,"@footer",this.footer);
	this.headerCss=getNodeValue(node,"@headerCss",this.headerCss);
	this.footerCss=getNodeValue(node,"@footerCss",this.footerCss);
	this.tableCss=getNodeValue(node,"@tableCss",this.tableCss);
	this.layerCss=getNodeValue(node,"@layerCss",this.layerCss);
	this.separatorCss=getNodeValue(node,"@separatorCss",this.separatorCss);
	this.rollOverImage=getNodeValue(node,"@rollOverImage",this.rollOverImage);
	this.rollOutImage=getNodeValue(node,"@rollOutImage",this.rollOutImage);
	this.rollOverCss=getNodeValue(node,"@rollOverCss",this.rollOverCss);
	this.rollOutCss=getNodeValue(node,"@rollOutCss",this.rollOutCss);
	this.applyToChild=getNodeValue(node,"@applyToChild",this.applyToChild);
	this.layerWidth=getNodeValue(node,"@layerWidth",this.layerWidth);
	this.width=getNodeValue(node,"@width",this.width);
	this.height=getNodeValue(node,"@height",this.height);
	this.xoffset=getNodeValue(node,"@xoffset",this.xoffset) *1;
	this.yoffset=getNodeValue(node,"@yoffset",this.yoffset) *1;
	if(this.parent!=null)this.ID=this.parent.ID+"_"+this.name;	
	else this.ID=this.name;	
	var subNodes=selectNodes(node,"menuItem");
	for(var i=0;i<subNodes.length;i++){
		var n=subNodes[i];
		var name=getNodeValue(n,"@name","");
		var m=this.addMenu(name);
		m.setXmlNode(n);
	}
}

function MenuItem_find(ID){
	for(var i=0;i<this.subMenu.length;i++){
		var sm=this.subMenu[i];
		if(ID==sm.ID)return sm;
		else{
			var m=sm.find(ID);
			if(m!=null)return m;
		}
	}
	return null;
}

function MenuItem_isRoot(){
	if(this.parent==null)return true;
	else return false;
}

function MenuItem_addMenu(name){
	var m=new MenuItem(name,this);
	this.subMenu[this.subMenu.length]=m;
	this[m.name]=m;
	return m;
}

function MenuItem_buildNav(builder){
	this.buildSubNav(builder);
}

function MenuItem_buildNavItem(builder){
	builder.writeTableItem(this);	
}

function MenuItem_setSubPosition(builder){
	for(var i=0;i<this.subMenu.length;i++){
		var sm=this.subMenu[i];
		sm.setPosition(builder);
	}	
}

function MenuItem_setPosition(builder){
	builder.setPosition(this);
	this.setSubPosition(builder);
}

function MenuItem_buildSubNav(builder){
	if(this.subMenu.length==0)return;
	
	builder.writeLayerStart(this);
	builder.writeTableStart(this);
	builder.writeHeader(this);
	for(var i=0;i<this.subMenu.length;i++){
		if(i>0){
			builder.writeSeparator(this);
		}
		var sm=this.subMenu[i];
		sm.buildNavItem(builder);
	}
	builder.writeFooter(this);
	builder.writeTableEnd(this);
	builder.writeLayerEnd(this);
	
	for(var i=0;i<this.subMenu.length;i++){
		var sm=this.subMenu[i];
		sm.buildSubNav(builder);		
	}
}

function NavXmlBuilder(){
	this.document=null;
}

NavXmlBuilder.prototype.load=NavXmlBuilder_load;
NavXmlBuilder.prototype.getMenuItem=NavXmlBuilder_getMenuItem;
NavXmlBuilder.prototype.getNavCtrl=NavXmlBuilder_getNavCtrl;

function NavXmlBuilder_load(path){
	
	this.document=loadXmlDoc(path);
}

function NavXmlBuilder_getMenuItem(name,zindex){
	if(zindex==null)zindex=0;
	var rootMenu=new MenuItem(name);
	rootMenu.zindex=zindex;
	var node=selectSingleNode(this.document.documentElement,"navigation/menuItem");
	if(node==null)return null;
	rootMenu.setXmlNode(node);
	rootMenu.qname=name;
	return rootMenu;
}

function NavXmlBuilder_getNavCtrl(name){
	var nav=new NavIE(name);
	var node=selectSingleNode(this.document.documentElement,"navigation/setting");
	if(node==null)return node;
	nav.setXmlNode(node);
	return nav;
}

var lastMenu;

function navClick(td,rootMenu){

	var menu=rootMenu.find(getAttrValue(td,"menuID"));
	if(menu.javascript!="")eval(menu.javascript);
	else if(menu.target!="" && menu.url!="")window.open(menu.url,menu.target);
	else if(menu.url!="")location=menu.url;
}

function navRollOut(td,rootMenu){
	var menu=rootMenu.find(getAttrValue(td,"menuID"));
	td.className=menu.rollOutCss;
	window.hideLayer=setTimeout("navHideLayers(lastMenu)",400);
	
}

function navRollOver(td,rootMenu){
	navHideLayers(lastMenu);
	var menu=rootMenu.find(getAttrValue(td,"menuID"));	
	td.className=menu.rollOverCss;
	navShowLayers(menu,rootMenu);	
	
}

function navShowOver(td,menu){
	if(menu.rollOverCss!="")td.className=menu.rollOverCss;
	if(menu.rollOverImage!=""){
		var img=document.getElementById("img_"+menu.ID);
		if(img!=null)img.src=menu.rollOverImage;
	}
}

function navShowOut(td,menu){
	if(menu.rollOutCss!="")td.className=menu.rollOutCss;
	if(menu.rollOutImage!=""){
		var img=document.getElementById("img_"+menu.ID);
		if(img!=null)img.src=menu.rollOutImage;
	}
}

function navShowLayers(menu,rootMenu){
	if(menu==null)return;
	var layer=document.getElementById("layer_"+menu.ID);
	var td=document.getElementById("td_"+menu.ID);
	if(td!=null)navShowOver(td,menu);
	if(layer!=null){
		layer.style.visibility="visible";
		layer.style.left=menu.x;
		layer.style.top=menu.y;	
		if(menu.layerWidth>0)layer.style.width=menu.layerWidth;	
	}
	navShowLayers(menu.parent,rootMenu);
	lastMenu=menu;
}

function navHideLayers(menu){
	if(menu==null)return;
	if(window.hideLayer!=null){
		clearTimeout(window.hideLayer);
		window.hideLayer=null;
	}
	var layer=document.getElementById("layer_"+menu.ID);
	if(layer!=null)layer.style.visibility="hidden";
	navHideLayers(menu.parent);
	var td=document.getElementById("td_"+menu.ID);
	if(td!=null)navShowOut(td,menu);
}



/*
=================================================================================
=================================================================================
=================================================================================
=================================================================================
*/
function NavIE(navName){
	this.navName=navName;
	this.output="string";
	this.outputString="";
	this.type="h";
}

NavIE.prototype.writeLayerStart=NavIE_writeLayerStart;
NavIE.prototype.writeLayerEnd=NavIE_writeLayerEnd;
NavIE.prototype.writeTableStart=NavIE_writeTableStart;
NavIE.prototype.writeTableEnd=NavIE_writeTableEnd;
NavIE.prototype.writeTableItem=NavIE_writeTableItem;
NavIE.prototype.write=NavIE_write;
NavIE.prototype.setPosition=NavIE_setPosition;
NavIE.prototype.writeSeparator=NavIE_writeSeparator;
NavIE.prototype.writeHeader=NavIE_writeHeader;
NavIE.prototype.writeFooter=NavIE_writeFooter;
NavIE.prototype.setXmlNode=NavIE_setXmlNode;

function NavIE_setXmlNode(node){
	this.output=getNodeValue(node,"@output",this.output);
	this.type=getNodeValue(node,"@type",this.type);
}

function NavIE_setPosition(menu){
	
	var td=document.getElementById("td_"+menu.ID);
	menu.x=td.offsetLeft+menu.parent.x;
	menu.y=td.offsetTop+menu.parent.y;
	
	menu.height=td.offsetHeight;
	menu.width=td.offsetWidth;
	if(menu.level==1){
		
		var table=td.offsetParent;
		if(table!=null){
			menu.x+=getGlobalLeft(table);
			menu.y+=getGlobalTop(table);
			if(this.type=="h")menu.y+=table.offsetHeight;
			else menu.x+=table.offsetWidth;
		}
	}else{
		menu.x+=menu.width;						
	}
	menu.x+=menu.xoffset;
	menu.y+=menu.yoffset;
	
	
}

function getGlobalLeft(obj){
	if(obj==null)return 0;
	return obj.offsetLeft+getGlobalLeft(obj.offsetParent);
}

function getGlobalTop(obj){
	if(obj==null)return 0;
	return obj.offsetTop+getGlobalTop(obj.offsetParent);
}

function NavIE_writeSeparator(menu){
	if(menu.separator=="")return;
	if(menu.isRoot() && this.type=="v")this.write("<tr>");
	this.write("<td class=\""+menu.separatorCss+"\">"+menu.separator+"</td>");
	if(menu.isRoot() && this.type=="v")this.write("</tr>");
}

function NavIE_writeHeader(menu){
	if(menu.header=="")return;
	if(menu.isRoot() && this.type=="v")this.write("<tr>");
	this.write("<td class=\""+menu.headerCss+"\">"+menu.header+"</td>");
	if(menu.isRoot() && this.type=="v")this.write("</tr>");
}

function NavIE_writeFooter(menu){
	if(menu.footer=="")return;
	if(menu.isRoot() && this.type=="v")this.write("<tr>");
	this.write("<td class=\""+menu.footerCss+"\">"+menu.footer+"</td>");
	if(menu.isRoot() && this.type=="v")this.write("</tr>");
}

function NavIE_writeLayerStart(menu){
	if(menu.isRoot())return;
	this.write("<div id=\"layer_");
	this.write(menu.ID);
	this.write("\" ");
	if(menu.layerCss!="")this.write(" class=\""+menu.layerCss+"\" ");
	
	
	//write default style
	this.write("style=\"");
	this.write("position:absolute;visibility:hidden;");
	if(menu.layerWidth>0)this.write("width:"+menu.layerWidth+";");
	this.write("z-index:"+menu.zindex);
	this.write("\" ");	
	
	this.write(">");
}

function NavIE_writeLayerEnd(menu){
	if(menu.isRoot())return;
	this.write("</div>");
}

function NavIE_writeTableStart(menu){
	this.write("<table border=\"0\" cellspacing=0 cellpadding=0 ");
	if(menu.layerWidth>0)this.write(" width=\""+menu.layerWidth+"\" ");
	if(menu.tableCss!="")this.write(" class=\""+menu.tableCss+"\" ");
	this.write(">");
	if(menu.isRoot() && this.type=="h")this.write("<tr>");
}

function NavIE_writeTableEnd(menu){
	if(menu.isRoot() && this.type=="h")this.write("</tr>");
	this.write("</table>");
}

function NavIE_writeTableItem(menu){
	if(menu.parent.isRoot()==false || this.type=="v")this.write("<tr>");
	this.write("<td");
	this.write(" ID=\"td_"+menu.ID+"\"");
	this.write(" menuID=\""+menu.ID+"\"");
	if(menu.parent && menu.parent.layerWidth>0)this.write(" width=\""+menu.layerWidth+"\" ");
	else if(menu.width>0)this.write(" width=\""+menu.width+"\" ");
	if(menu.height>0)this.write(" height=\""+menu.height+"\"");
	if(menu.align!="")this.write(" align=\""+menu.align+"\"");
	
	//write CSS
	if(menu.rollOutCss!="")this.write(" class=\""+menu.rollOutCss+"\"");
	
	//write Events
	this.write(" onmouseover=\"navRollOver(this,"+this.navName+")\"");
	this.write(" onmouseout=\"navRollOut(this,"+this.navName+")\"");
	this.write(" onclick=\"navClick(this,"+this.navName+")\"");
		
	this.write(">");
	if(menu.leftItem!=""){
		this.write(menu.leftItem);
	}
	if(menu.rollOutImage!=""){
		this.write("<img border=0 src=\""+menu.rollOutImage+"\" ");
		this.write(" ID=\"img_"+menu.ID+"\" >");
	}else
		this.write(menu.label);
	
	if(menu.rightItem!=""){
		this.write(menu.rightItem);
	}
	this.write("</td>");
	if(menu.parent.isRoot()==false || this.type=="v")this.write("</tr>");
}

function NavIE_write(html){
	if(this.output=="string")this.outputString+=html;
	else document.write(html);
}

String.prototype.xmlFilter=String_xmlFilter;

var isIE=document.all!=null?true:false;
var isNS6=document.getElementById!=null && document.all==null?true:false;

function String_xmlFilter(){
	var result="";
	for(var i=0;i<this.length;i++){
		var c=this.charAt(i);
		switch(c){
			case "\"":
				result+="&quot;";
				break;
			case "&":
				result+="&amp;";
				break;				
			case "<":
				result+="&lt;";
				break;
			case ">":
				result+="&gt;";
				break;
			case "'":
				result+="&apos;";
				break;			
			default:
				result+=c;
				break;
		}
	}
	return result;
}

function loadXmlDoc(path){
	var doc=null;
	if(isIE){
		doc=new ActiveXObject("Microsoft.XMLDOM");
	}else if(isNS6){
		doc=document.implementation.createDocument("", "xmlDoc", null);
		
	}
	doc.async=false;
	doc.load(path);
	if(doc.documentElement==null)return null;
	else return doc;
}


function selectSingleNode(node,path){
	var nodeList=selectNodes(node,path);
	if(nodeList==null)return null;
	else if(nodeList.length==0)return null;
	else return nodeList[0];
}

function selectNodes(node,path){
	//if(isIE)return node.selectNodes(path);
	//else if(isNS6){
	
	var tagNames=path.split("/");
	var i=0;
	var nextNode=node;
	var nodeList=new Array();
	while(i<tagNames.length){
		
		nodeList=selectChildNodesByTagName(nextNode,tagNames[i]);
		if(nodeList.length==0)return nodeList;
		nextNode=nodeList[0];
		i++;
	}
	return nodeList;
	//}
}

function selectChildNodesByTagName(node,tagName){
	var	nodeList=new Array();
	if(tagName.indexOf("@")==0){
		tagName=tagName.substring(1,tagName.length);
		var n=node.getAttributeNode(tagName);
		if(n!=null)nodeList[0]=n;
		
	}else{
		for(var i=0;i<node.childNodes.length;i++){
			var n=node.childNodes.item(i);
			if(n.nodeName==tagName && n.nodeType==1){
				nodeList[nodeList.length]=n;
			}
		}
	}
	
	return nodeList;
}


function getNodeValue(node,path,defaultValue){
	var n=selectSingleNode(node,path);
	if(n==null)return defaultValue;
	else return n.nodeValue;
}

function setNodeValue(node,name,value){
	if(value==null)return;
	var n=node.selectSingleNode(name);
	if(n==null){
		n=xmlDoc.createElement(name);
		node.appendChild(n);
	}
	n.text=value;
}

function setAttrValue(node,attrName,attrValue){
	if(attrValue==null)return;
	if(node==null)return;
	var attr=node.attributes.getNamedItem(attrName);
	if(attr==null){
		attr=xmlDoc.createAttribute(attrName);
		node.attributes.setNamedItem(attr);
	}
	attr.value=attrValue;
}

function getAttrValue(node,attr,defaultValue){
	if(node.attributes.getNamedItem){
		var n=node.attributes.getNamedItem(attr);
		if(n==null)return defaultValue;
		else return n.nodeValue;
	}else{
		return node[attr];
	}
}

	menuArray = new Array();
	window.onload=setMenuPosition;
	window.onresize=setMenuPosition;
	function addMenu(menu, ctrl) {
		//alert(menuArray.length);
		var obj = new Object();
		obj.menu = menu;
		obj.ctrl = ctrl;
		menuArray[menuArray.length] = obj;
	}
	function setMenuPosition(){
		//alert(menuArray.length);
		for (var i = 0; i < menuArray.length; i++) {
		//topMenu.setSubPosition(topNavCtrl);
			menuArray[i].menu.setSubPosition(menuArray[i].ctrl);
		}
	}
	
	function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}