	nSiteWidth=1020;
	nMenuY = 108;
	nMenuX = 120;
	nMenuWidth=1000;
	nMenuHeight=21;
	aButtonStates = new Array("off", "on");
	sButtonImagePath = "img";
	sButtonImageType = ".gif";


window.onresize=new Function("oBrowser.fAdjustResizedWindow()");

function oBrowser() {
	//USE: 
	//        single object used for browser-related properties
	
	//ACTION:
	//        instantiate oBrowser object
	//        set browser detect booleans
	//        call fSetBounds()

	this.OPERA = (navigator.userAgent.indexOf("Opera") != -1);
	this.WEBTV = (navigator.appName.indexOf("WebTV") != -1);
	this.NN = (navigator.appName == "Netscape");
	this.NN4 = (navigator.appVersion.charAt(0) == 4 && this.NN);
	this.NN6 = (navigator.appVersion.charAt(0) > 4 && this.NN);
	this.IE = (navigator.appName == "Microsoft Internet Explorer" && !this.OPERA && !this.WEBTV);
	this.IE4 = (navigator.appVersion.indexOf("4.") && this.IE);
	this.IE5 = (navigator.appVersion.indexOf("5.") && this.IE);
	this.DOM = document.getElementById ? 1 : 0;

	this.MAC = (navigator.appVersion.indexOf("Mac")!=-1) ? 1 : 0;

	this.oLiveMenu = null;
	this.fSetBounds();
}

oBrowser.prototype.fSetBounds = function() {
	//USE:
	//        used by oBrowser object
	
	//ACTION:
	//        set browser boundaries

	if (this.NN || this.OPERA) {
		this.w = window.innerWidth;
		this.h = window.innerHeight;
		this.l = window.pageXOffset;
		this.t = window.pageYOffset;
	} else if (this.IE) {
		this.w = document.body.clientWidth;
		this.h = document.body.clientHeight;
		this.l = document.body.scrollLeft;
		this.t = document.body.scrollTop;
	}
	
	this.lsite = this.l + (this.w - nSiteWidth)/2;
	
	//window.status = "w="+this.w+" h="+this.h+" l="+this.l+" t="+this.t+" lsite="+this.lsite;
}

oBrowser.prototype.fAdjustResizedWindow = function() {
	if (this.oLiveMenu != null) {
		this.oLiveMenu.fResetPositionOfMenuOuter();
	}
}


oBrowser.prototype.fStartRollDown = function(oMenu) {
		if (oMenu != this.oLiveMenu) {
			if (this.oLiveMenu != null) {
				this.oLiveMenu.fCompleteRollUp()
//				setTimeout("oBrowser.oLiveMenu.fCompleteRollUp()", 800);
			}
			this.oLiveMenu = oMenu;
//			oMenu.fStartRollDown();
			setTimeout("oBrowser.oLiveMenu.fStartRollDown()", 800);
		}
}



oBrowser.prototype.fCompleteRollDown = function(oMenu) {
	this.oLiveMenu = oMenu;
	oMenu.fCompleteRollDown();
}

oBrowser.prototype.fDelayedCompleteRolldown = function(oMenu) {
	this.oLiveMenu = oMenu;
	setTimeout("oBrowser.oLiveMenu.fCompleteRollDown()", 3000);
}

oBrowser.prototype.fReinstateThisPageMenu = function() {
	if (this.oThisPageMenu) {
		this.fCompleteRollDown(this.oThisPageMenu);
	}
}

///////////////////////////////////////////////////////////

oBrowser.prototype.fStartTimerToRollUp = function(oMenu) { // starts timer to roll up menu
	if (this.oThisPageMenu != this) {
		this.RollUpTimer = window.setTimeout("oBrowser.fTimerToRollUpFinished()", this.nRollUpDelay);
	}
}

oBrowser.prototype.fStopTimerToRollUp = function() { // stops timer to roll up menu
	if (this.RollUpTimer) {
		this.RollUpTimer = window.clearTimeout(this.RollUpTimer);
	}
}

oBrowser.prototype.fTimerToRollUpFinished = function(oMenu) { // starts roll up after timer from rollout. Also reinstates this page's menu
	if (this.oLiveMenu != null){
		this.oLiveMenu.fStartRollUp();
		this.fReinstateThisPageMenu();
	}
}

///////////////////////////////////////////////////////////

var oBrowser = new oBrowser(); //create instance of oBrowser object

///////////////////////////////////////////////////////////

oBrowser.nRollUpDelay = 15000; //millisecond delay before roll up after mouse out
oBrowser.nMenuRollRate = 5 //rate of menu scroll

///////////////////////////////////////////////////////////

function oMenu (sID, sDir, bThisPageMenu, sParentID) { // initialisation function for menu class
	this.sID = sID;
	this.sIDouter = this.sID + "outer";
	this.sIDinner = this.sID + "inner";
	this.sDir = sDir;
	this.bThisPageMenu = bThisPageMenu;
	if (sParentID) {
		this.sParentID = sParentID;
		//alert(id + " has parent");
	}
	this.bRolledUp = true;
	this.bRolledDown = false;
	this.nMenuInnerX = 0;
	this.nMenuInnerY = 0;
	//alert(this.sID +"; parentID=" + this.sParentID);
	
	this.fSetUpButton();
	
	bDIVLoaded = false;
	this.fOnDIVLoad();
}

oMenu.prototype.fOnDIVLoad = function() { // adds oMenuOuter and oMenuInner to oMenu object, once DIVs are loaded

	var d = document;
	
	var oMenuOuter = oBrowser.DOM ? d.getElementById(this.sIDouter) : oBrowser.IE ? d.all[this.sIDouter] : d.layers[this.sIDouter];
	if (oMenuOuter) var oMenuInner = oBrowser.NN4 ? this.oMenuOuter.layers[this.sIDinner] : oBrowser.IE ? d.all[this.sIDinner] : d.getElementById(this.sIDinner);
	
	if (!oMenuOuter || !oMenuInner) {
		window.setTimeout(this.sID + ".fOnDIVLoad()", 100);
	} else {
		this.oMenuOuter = oMenuOuter;
		this.oMenuInner = oMenuInner;
		sTempFunctionMouseOver = this.sID + ".fMouseOver();" + (this.sParentID ? this.sParentID + ".fMouseOver();" : "");
		sTempFunctionMouseOut = this.sID + ".fMouseOut();" + (this.sParentID ? this.sParentID + ".fMouseOut();" : "");
		oMenuInner.onmouseover = new Function(sTempFunctionMouseOver);
		oMenuInner.onmouseout = new Function(sTempFunctionMouseOut);
		
		bDIVLoaded = true;

		if (this.bThisPageMenu) {
			oBrowser.oThisPageMenu = this;
			if (oBrowser.MAC) {
				oBrowser.fDelayedCompleteRolldown(this);
			} else {
				oBrowser.fCompleteRollDown(this);
			}
		}
	}
}

///////////////////////////////////////////////////////////

oMenu.prototype.fMouseOver = function() { // onmouseover action on each menu
	if (bDIVLoaded) {
		
		//if not a secondary menu, bring it higher up the z-index
		if (!this.sParentID) {
			this.oMenuOuter.style.zIndex = 2;
		}
		
		oBrowser.fStopTimerToRollUp();

		oBrowser.fStartRollDown(this);
	}
}

oMenu.prototype.fMouseOut = function() { // onmouseout action for each menu
	if (bDIVLoaded) {
		if (!this.sParentID) {
			this.oMenuOuter.style.zIndex = 1;
		}
		oBrowser.fStartTimerToRollUp(this);
	}
}

///////////////////////////////////////////////////////////

oMenu.prototype.fSetUpButton = function() { // prepares button states for rollover
	for (var i=0; i != aButtonStates.length; i++) {
		if (document.images) {
			eval(this.sID + aButtonStates[i] + " = new Image ();");
			eval(this.sID + aButtonStates[i] + ".src = '"+ sButtonImagePath + "/" + this.sID + aButtonStates[i] + sButtonImageType + "'");
		} else {
			eval(this.sID + aButtonStates[i] + " = '';");
			document[this.sID].src = "";
    	}
    }

}

oMenu.prototype.fRollButton = function(sState) { // rolls button to specified state
	if (document.images) {
		if( this.sID && document[this.sID+"button"] ) document[this.sID+"button"].src = eval(this.sID + sState + ".src");
	}			
}

///////////////////////////////////////////////////////////

oMenu.prototype.fStartRollUp = function() { // starts roll up MC (or, in this case, immediately calls fCompleteRollUp())
	
	//roll up the menu...
	this.bRollOut = false;
	if (this.RollTimerMC) {
		this.RollTimerMC = window.clearTimeout(this.RollTimerMC);
	}

	//this.RollTimerMC = window.setInterval(this.sID + ".fRollMenuMC()", 20);
	this.fCompleteRollUp(); // immediately turn off menu
}

oMenu.prototype.fCompleteRollUp = function() { // turns menu to rolled up state, and positions it for next roll down
	//alert("removing "+this.sID);
	this.fRollButton("off");

	if (this.RollTimerMC) {
		this.RollTimerMC = window.clearTimeout(this.RollTimerMC);
	}
	
	this.fShowMenuOuter(false); //hide outer layer

	this.bRolledUp = true;
	
	if (oBrowser.oLiveMenu == this) {
		oBrowser.oLiveMenu = null;
	}

}

oMenu.prototype.fStartRollDown = function() { // starts roll down
	oBrowser.fSetBounds();
	
	this.fRollButton("on");
	
	// set position of inner menu to correct start position
	if (this.sDir == "r") {
		this.nMenuInnerX = -nMenuWidth;
		this.nMenuInnerY = 0;
	
	} else if (this.sDir == "l") {
		this.nMenuInnerX = nMenuWidth;
		this.nMenuInnerY = 0;
	
	} else if (this.sDir == "d") {
		this.nMenuInnerX = 0;
		this.nMenuInnerY = -nMenuHeight;;

	}
	this.fMoveMenuInner(this.nMenuInnerX, this.nMenuInnerY);

	this.fShowMenuOuter(true);
	this.bRolledUp = false;

	//roll down the menu
	//t  = 0;
	this.bRollOut = true;
	if (this.RollTimerMC) {
		this.RollTimerMC = window.clearTimeout(this.RollTimerMC);
	}
	this.RollTimerMC = window.setInterval(this.sID + ".fRollMenuMC()", 20);
	//this.fCompleteRollDown(); //temp version!!
}

oMenu.prototype.fCompleteRollDown = function() { // ends roll down
	this.fRollButton("on");

	if (this.RollTimerMC) {
		this.RollTimerMC = window.clearTimeout(this.RollTimerMC);
	}
	this.nMenuInnerX = 0;
	this.nMenuInnerY = 0;
	this.fMoveMenuInner(this.nMenuInnerX, this.nMenuInnerY);

	this.fShowMenuOuter(true);
	this.bRolledDown = true;

}

///////////////////////////////////////////////////////////

oMenu.prototype.fRollMenuMC = function() {
	//t ++;
	//window.status = t;
	if (this.sDir == "d") {
		if (this.bRollOut) {
			this.nMenuInnerY += Math.ceil((0 - this.nMenuInnerY) / oBrowser.nMenuRollRate) + 1; // += nMenuRollRate;
			if (this.nMenuInnerY >= 0) {
				this.fCompleteRollDown();
			}
		} else {
			this.nMenuInnerY += Math.floor((this.nMenuInnerY - 0) / oBrowser.nMenuRollRate) - 1; // -= nMenuRollRate;
			if (this.nMenuInnerY <= -nMenuHeight) {
				this.fCompleteRollUp();
			}
		}
		this.fMoveMenuInner(0, this.nMenuInnerY);
		
	} else if (this.sDir == "r") {
		if (this.bRollOut) {
			this.nMenuInnerX += Math.ceil((0 - this.nMenuInnerX) / oBrowser.nMenuRollRate) + 1; // += nMenuRollRate;
			if (this.nMenuInnerX >= 0) {
				this.fCompleteRollDown();
			}
		} else {
			this.nMenuInnerX += Math.floor((this.nMenuInnerX - 0) / oBrowser.nMenuRollRate) - 1; // -= nMenuRollRate;
			if (this.nMenuInnerX <= -nMenuWidth) {
				this.fCompleteRollUp();
			}
		}
		this.fMoveMenuInner(this.nMenuInnerX, 0);
		
	} else if (this.sDir == "l") {
		if (this.bRollOut) {
			this.nMenuInnerX += Math.floor((0 - this.nMenuInnerX) / oBrowser.nMenuRollRate) - 1; // -= nMenuRollRate;
			if (this.nMenuInnerX <= 0) {
				this.fCompleteRollDown();
			}
		} else {
			this.nMenuInnerX += Math.ceil((this.nMenuInnerX - 0) / oBrowser.nMenuRollRate) + 1; // += nMenuRollRate;
			if (this.nMenuInnerX >= nMenuWidth) {
				this.fCompleteRollUp();
			}
		}
		this.fMoveMenuInner(this.nMenuInnerX, 0);
		
	} 
}

oMenu.prototype.fShowMenuOuter = function(bvisible) { // shows/hides menu outer
	this.fResetPositionOfMenuOuter();
	if (bvisible) {
		this.oMenuOuter.style.visibility = "visible";
	} else {
		this.oMenuOuter.style.visibility = "hidden";
	}
}

oMenu.prototype.fMoveMenuInner = function(x, y) { // moves inner menu
	this.oMenuInner.style.left = x;
	this.oMenuInner.style.top = y;
	//if(NN && !NN6) document.layers[sid].moveTo(nx, ny);
}

oMenu.prototype.fResetPositionOfMenuOuter = function() { // lines up menu outer with page, according to browser, etc.
	oBrowser.fSetBounds();
//	this.oMenuOuter.style.left = oBrowser.lsite;
	this.oMenuOuter.style.left = nMenuX;
	this.oMenuOuter.style.top = nMenuY;
}

function ChangeLanguage(lang)
{	
	var hkifaL = top.location.href;	
	var hkifaList = "/" + lang + "/";
	

	hkifaL = hkifaL.replace("/#/","");
	hkifaL = hkifaL.replace("/chi/",hkifaList);
	hkifaL = hkifaL.replace("/eng/",hkifaList);
	hkifaL = hkifaL.replace("/schi/",hkifaList);

	location.href=hkifaL;
}
