var isIE=document.all?1:0;
var isNS6=document.getElementById && !document.all?1:0;
var isNS4=!document.getElementById && document.layers?1:0;
var fadeOutLayerID="";
var fadeOutHeading="";
var fadeOutImage="";
var enableNS=0;

function goChinese(){
	var l=window.location.toString();
	window.location=l.replace(/\/eng\//,"/t_chi/").replace(/\/s_chi\//,"/t_chi/");
}

function goEnglish(){
	var l=window.location.toString();
	window.location=l.replace(/\/t_chi\//,"/eng/").replace(/\/s_chi\//,"/eng/");
}

function goSimChinese(){
	var l=window.location.toString();
	window.location=l.replace(/\/t_chi\//,"/s_chi/").replace(/\/eng\//,"/s_chi/");
}

function goWindsorHouse(){
	document.location="/eng/property_lease/windsor_house.asp";
}

function goMassMatual(){
	document.location="/eng/property_lease/massmutual_tower.asp";
}

function mainOver(ID,obj){
	if(isIE){
		if(obj)obj.className="mainMenuOver";
	}
}

function getDateString(){
	var currentTime=new Date();
	var d="Current Time : "+currentTime.getDate()+"-"+(currentTime.getMonth()+1)+"-"+currentTime.getYear();
	d+=" // "+addDigi(currentTime.getHours(),2)+":"+addDigi(currentTime.getMinutes(),2)+":"+addDigi(currentTime.getSeconds(),2);
	return d;
}

function addDigi(value,digi){
	var temp=value+"";
	var d=temp.length<digi?digi-temp.length:0;
	for(var i=0;i<d;i++)temp="0"+temp;
	return temp;
}

function startTimer(){
	if(document.all.timerLayer && isIE){
		document.all.timerLayer.innerHTML=getDateString();
		if(!window.timer)window.timer=setInterval("startTimer()",250);
	}
}

function mainOut(ID,obj){
	if(isIE){
		if(obj)obj.className="mainMenuOut";
	}
}

function showLayer(layerID){
	if(enableNS==0 && (isNS4 || isNS6))return;
	if(fadeOutLayerID!="")fadeOut();
	var IDs=layerID.split("-");
	//if(isIE)document.all[IDs[0]].className="mainMenuOver";
	//if(isIE)document.all[IDs[1]].className="subMenuOver";
	if(isIE)document.all[IDs[1]].style.visibility="visible";
	else if(isNS6)document.getElementById(IDs[1]).style.visibility="visible";
	else document[IDs[1]].visibility="visible";	
}

function startFadeOut(ID){
	if(enableNS==0 && (isNS4 || isNS6)){
		fadeOut();
		return;
	}
	if(fadeOutLayerID!="")fadeOut();
	fadeOutLayerID=ID;
	if(window.drawit)clearInterval(window.drawit);
	window.drawit=setInterval("fadeOut()",500);
}

function setHeading(head,image){
	fadeOutHeading=head;
	fadeOutImage=image;
}

function fadeOut(){
	if(fadeOutHeading!="")document[fadeOutHeading].src=fadeOutImage;
	fadeOutHeading="";
	fadeOutImage="";
	if(enableNS==0 && (isNS4 || isNS6))return;
	var IDs=fadeOutLayerID.split("-");
	fadeOutLayerID="";
	if(isIE)document.all[IDs[1]].style.visibility="hidden";
	else if(isNS6)document.getElementById(IDs[1]).style.visibility="hidden";
	else document[IDs[1]].visibility="hidden";
	if(window.drawit)
		clearInterval(window.drawit);
}