// some MM functions are adopted here - showHideLayer, reloadPage etc

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


function chinesePage(){ //links to corresponding gb2132 enocded page
	var thisURL = new String (window.location);
//	var splitURLnoquery = thisURL.split("?");
//	thisURL=splitURLnoquery[0];
//	thisURL = thisURL.replace("#", "");
	var splitURL = thisURL.split("/site/eng/");
	if (splitURL.length == 2) {
		var big5URL = splitURL[0] + "/site/chi/" + splitURL[1];


//patches. see chi for desc.
		var splitURL = big5URL.split("_Eng");
		if (splitURL.length == 2) {
			big5URL = splitURL[0] + "_Chi" + splitURL[1];
		}
		var splitURL = big5URL.split("_eng");
		if (splitURL.length == 2) {
			big5URL = splitURL[0] + "_chi" + splitURL[1];
		}



		window.location = big5URL;
	} else if (splitURL.length > 2 ) {
		alert("Sorry! Incorrect address, chinese page cannot be displayed." );
	} else {
		alert("Sorry! This page has no Chinese version available." );
	}
}

function EnglishPage(){
//for those wrongly called this fn
	chinesePage();
}

var mlayer;
function hideLayer(){ //one second delay to hide layer menu
	mlayer = setTimeout("hideAll()",500);
}

function stopTimer(){ //stop the timer
	clearTimeout(mlayer);
}

function hideAll(){
	stopTimer();
	MM_showHideLayers('layer1','','hide');
	MM_showHideLayers('layer2','','hide');
	MM_showHideLayers('layer3','','hide');
	MM_showHideLayers('layer4','','hide');
	MM_showHideLayers('layer6','','hide');
	MM_showHideLayers('layer7','','hide');
}

function showLayer(n){ //show layer number
	hideAll();
	MM_showHideLayers('layer'+n,'','show');
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function navMenu(sfolder,dname){ //footer menu links - open index page from the section folder "sfolder"
	var thisURL = new String (window.location);
	splitURL = thisURL.split("eng");
	if (splitURL.length > 0) {
		destURL = splitURL[0] + "eng/" + sfolder + "/"
		if (dname ) { 
			destURL += dname;
		} 
		window.location = destURL;
	}	
}

// today
function today(){
	var dd,mmm,yyyy, dt;
	now = new Date();
	month = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
	dd = "0" + now.getDate();
	dd = dd.substring(dd.length-2, dd.length);
	mmm = month[now.getMonth()];
	yyyy = now.getFullYear();	
	now =  (mmm + " " + dd + ", " + yyyy);
	document.write (now);
}