
// Copyright 2005
//jsinit
function MyCentamap(){
	this.password = "";  
	this.wait = 400;
	this.freedragcnt = 9999;
	this.lg = "b5";
	this.waitpage = 1;
	this.top = parent;
	this.checker= 45;
	this.zs =	Array( 0.21183,0.61883,0.972,1.53167,2.51,4.49016,6.86731,9.50858,17.1683,22.4508,33.8083,83.1473,0	);
	this.w= 640;
	this.h= 480;
	this.x= 834025;
	this.y = 815605;
	this.z = 1;
	this.lck = '';
	this.gmurl = 'http://hk.centamap.com/gm/';
	
	this.gmtileurl = "http://hkmap.centamap.com/gm/";
	//this.gmtileurl = "http://www1.centamap.com/gm/";
	//this.gmtileurl = "http://152.101.13.106/gm/";
	//this.gmtileurl = "http://202.72.14.156/gm/";
	//this.gmtileurl = "http://202.72.14.29/gm/";
	
	this.iconurl = this.gmurl + "mapicon/";
	this.allowdrag = 0;
	this.allowclick = 0;
	this.afterclick = function(){};
	this.allowrotatetile = true;
	this.viewcnt = 0;
	this.mapmode = 0;
	this.iscensus = 0;
	this.iswatchlist = 0;
	this.expressmode = 0;
	this.mapoffset = 0;
}
MyCentamap.prototype.cango=function(acnt){
	//return (_jsmapapp.map.loadinfourlcnt < this.waitpage);
	return true;
}

var mc = new MyCentamap();
var majax=null;
var majaxprocess=null;
var _u = navigator.userAgent.toLowerCase();
var _myissupport = true;


var catlistb5 = '<div id="divtheme" style="z-index:1px"><div style="z-index:11;background:#FF0000;position:absolute;top:25px;left:8px;width:310px"><table border="0" cellpadding="0" cellspacing="0"><tr><td><div style="border:2px solid #A0A0A0;overflow:auto;overflow-x:hidden;width:318px;"><table width="100%" align="top" bgcolor="#FCFCFF"><tr><th style="border-bottom:solid 1px #000000">交通運輸</th></tr><tr><td>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gbus1","","","","","");};>巴士及小巴</A>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gi","","","tb000","","");};>鐵路及其他交通工具</A>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gi","","","ta00","","");};>車主便覽</A></td></tr><tr><td></td></tr><tr><th style="border-bottom:1px solid #000000">飲食娛樂</th></tr><tr><td>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gi","","","gocfood00","","");};>飲食指南</A>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gi","","","ac00","","");};>娛樂蒲點</A>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gi","","","ab00","","");};>康體消閒</A>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gi","","","bb00","","");};>郊遊景點</A></td></tr><tr><td></td></tr><tr><th style="border-bottom:1px solid #000000">社會教育</th></tr><tr><td>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gi","","","sa00","","");};>社會服務</A>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gi","","","da00","","");};>政社團體</A>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gi","","","ca00","","");};>教育進修</A></td></tr><tr><td></td></tr><tr><th style="border-bottom:1px solid #000000">香港資訊</th></tr><tr><td>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gcensus","","","","","");};>人口普查</A><IMG style="POSITION: relative; TOP: 0px" src="../gm/mapicon/new.gif">&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gi","","","video00","","");};>影片地圖</A>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gi","","","ga00","","");};>歷史掌故</A>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gi","","","ja00","","");};>地理資料</A>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gi","","","na00","","");};>環境生態</A>&nbsp;&nbsp;</td></tr><tr><td></td></tr><tr><th style="border-bottom:1px solid #000000">樓市資訊(每日更新)</th></tr><tr><td>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("glist","","","ct001","","");};>易搜筍盤</A>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gtran1","","","ct001","","");};>樓市成交</A>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gprop1","","","ct000","","");};>住宅資料</A>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("glistcis","","","ct000","","");};>工商筍盤</A>&nbsp;&nbsp;</td></tr><tr><td></td></tr><tr><th style="border-bottom:1px solid #000000">地產代理</th></tr><tr><td>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gi","","","centbranch","","");};>中原分行</A>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gi","","","ricabranch","","");};>利嘉閣分行</A>&nbsp;&nbsp;</tr></td><tr><td></td></tr><tr><td></td></tr><tr><td align="right"><input type="button" value="關閉視窗" style="font-size:10pt;" onclick="parent.map.ecjsfLayerClearTheme();"></td></tr></table></div></td></tr></table></div>';
var catlisten = '<div id="divtheme" style="z-index:1px"><div style="z-index:11;background:#FF0000;position:absolute;top:25px;left:8px;width:310px"><table border="0" cellpadding="0" cellspacing="0"><tr><td><div style="border:2px solid #A0A0A0;overflow:auto;overflow-x:hidden;width:318px;"><table width="100%" align="top" bgcolor="#FCFCFF"><tr><th style="border-bottom:solid 1px #000000">Transportation</th></tr><tr><td>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gbus1","","","","","");};>Bus&Green Minibus</A>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gi","","","tb000","","");};>Railway&Other public transport</A>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gi","","","ta00","","");};>Motorists Guide </A></td></tr><tr><td></td></tr><tr><th style="border-bottom:1px solid #000000">Entertainment</th></tr><tr><td>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gi","","","gocfood00","","");};>Restaurant</A>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gi","","","ac00","","");};>Entertainment</A>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gi","","","ab00","","");};>Recreational Facilities</A>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gi","","","bb00","","");};>Countryside</A></td></tr><tr><td></td></tr><tr><th style="border-bottom:1px solid #000000">Public Services & Education</th></tr><tr><td>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gi","","","sa00","","");};>Social Services</A>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gi","","","da00","","");};>Govt. and Society</A>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gi","","","ca00","","");};>Education</A></td></tr><tr><td></td></tr><tr><th style="border-bottom:1px solid #000000">Hong Kong Information</th></tr><tr><td>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gCensus","","","","","");};>Census Information</A><IMG style="POSITION: relative; TOP: 0px" src="../gm/mapicon/new.gif">&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gi","","","video00","","");};>Video Map</A>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gi","","","ga00","","");};>History</A>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gi","","","ja00","","");};>Geography</A>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gi","","","na00","","");};>Environment</A></td></tr><tr><td></td></tr><tr><th style="border-bottom:1px solid #000000">Property Market</th></tr><tr><td>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("glist","","","ct001","","");};>Property Listing</A>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gtran1","","","ct001","","");};>Property Transaction</A>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gprop1","","","ct000","","");};>Building Information</A>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("glistcis","","","ct000","","");};>CIS Listing</A>&nbsp;&nbsp;</td></tr><tr><td></td></tr><tr><th style="border-bottom:1px solid #000000">Property Agency</th></tr><tr><td>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gi","","","centbranch","","");};>Centaline Property Agency Ltd - Branch Offices</A>&nbsp;&nbsp;<A href=javascript:{parent.jsfsetck("gi","","","ricabranch","","");};>Ricacorp Properties Ltd - Branch Offices</A>&nbsp;&nbsp;</tr></td><tr><td></td></tr><tr><td align="right"><input type="button" value="Close" style="font-size:10pt;" onclick="parent.map.ecjsfLayerClearTheme();"></td></tr></table></div></td></tr></table></div>';
var catlist = catlistb5;






function Mybrowser(ke,Mg,Si){this.mtype=ke;this.mversion=Mg;this.mos=Si};
var mybrowser=new Mybrowser(0,0,null);
ls1=navigator.userAgent.toLowerCase();
if(ls1.indexOf("opera")!=-1){mybrowser.mtype=40}
	else if(ls1.indexOf("msie")!=-1&&document.all){
		mybrowser.mtype=1;
		if(ls1.indexOf("msie 5")){mybrowser.mversion=5}
	}
	else if(ls1.indexOf("safari")!=-1){
		mybrowser.mtype=30;
		if(ls1.indexOf("safari/125")!=-1){mybrowser.mversion=1}
	}
	else if(ls1.indexOf("mozilla")!=-1){
		mybrowser.mtype=20
	}
	
	if(ls1.indexOf("x11;")!=-1){
		mybrowser.mos=1
	};
	//var W=Number.MAX_VALUE;
	var majaxcnt=1000;
	var Kf=0;Object.prototype.setTimeout=function(ye,hj){
		var ze="tempVar"+Kf;
		Kf++;eval(ze+" = this;");
		var vi=ye.replace(/\\/g,"\\\\").replace(/\"/g,'\\"');
		return window.setTimeout(ze+'._setTimeoutDispatcher("'+vi+'");'+ze+" = null;",hj)
	}
	;Object.prototype._setTimeoutDispatcher=function(ye){eval(ye)}
	;Object.prototype.eventHandler=function(Rg){
		var g=this;
		g=g;
		return function(b){
			if(!b){b=window.event}if(b&&!b.target){b.target=b.srcElement}g[Rg](b)
		}
}
		

function mysetCursor(adiv,acur){
	try{
		adiv.style.cursor=acur;
	}catch(xxx){
		if(acur=="pointer"){
			mysetCursor(adiv,"hand")
			//mysetCursor(adiv,"url(http:\/\/localhost\/gm\/img\/hand_drop.cur)");
		}
		
		
	}
}


function llayer(){}
llayer.count=0;
llayer.createElement=function(aM,aAc){
	if(typeof arguments.callee.hasFilters=="undefined"){
		var lzi=document.createElement("div");
		arguments.callee.hasFilters=typeof lzi.style.filter!="undefined"
	}
	var rtn;
	if(arguments.callee.hasFilters){
		rtn=document.createElement("div");
		rtn.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+aM+(aAc?'",sizingMethod=crop)':'")')
	}else{
		rtn=document.createElement("img");
		rtn.src=aM
	}
	//rtn.id = "ka-l";
	return rtn
}
;llayer.create=function(aM,i,n,S,top,Va,aAc,Ia){
	return lbcelement.create(aM,i,n,S,top,Va,aAc,Ia,llayer.createElement)
};


function lbcelement(){}
lbcelement.create=function(aM,i,n,S,top,Va,aAc,Ia,allay){
	var rtn;
	if(!allay){
		rtn=document.createElement("IMG");
		if(aM)f.src=aM
	}
	else{
		rtn=allay(aM,aAc)
	}if(i&&n){
		rtn.style.width=mysetpx(i);
		rtn.style.height=mysetpx(n);
		rtn.width=i;
		rtn.height=n;
	}
	//f.id = "hahaha-bc";
	if(top||(S||(top==0||S==0))){
		rtn.style.position="absolute";
		rtn.style.left=mysetpx(S);
		rtn.style.top=mysetpx(top)
	}
	if(Va||Va==0){
		rtn.style.zIndex=Va
	}if(mybrowser.mtype==1){
		rtn.unselectable="on";
		rtn.onselectstart=freturnfalse
	}else{
		rtn.style.MozUserSelect="none"
	}
	rtn.style.border="0";
	rtn.oncontextmenu=freturnfalse;
	//if(Ia){ad(f,Ia)}
	return rtn
}

;
function myaddevent(acontrol,aname,afunc){
	if(acontrol.attachEvent){
		acontrol.attachEvent("on"+aname,afunc)
	}
	else if(acontrol.addEventListener){
		acontrol.addEventListener(aname,afunc,false)
	}
	else{
		acontrol["on"+aname]=afunc
	}
}
function mydelevent(acontrol,aname,afunc){
	if(acontrol.removeEventListener){
		acontrol.removeEventListener(aname,afunc,false);
	}else if(acontrol.detachEvent){
		acontrol.detachEvent("on"+aname,afunc);
	}
	else{
		acontrol["on"+aname]=null;
	}
}
function P(b){
	if(mybrowser.mtype==1){
		window.event.cancelBubble=true
	}else{
		b.cancelBubble=true;
		b.preventDefault();
		b.stopPropagation()
	}
}

if(!Array.prototype.push){Array.prototype.push=function(Gf){this[this.length]=Gf}}
function mysetpx(ax){return ax+"px"}
function myaddoffset(a1){
	var l1={"x":0,"y":0};
	while(a1){
		l1.x+=a1.offsetLeft;
		l1.y+=a1.offsetTop;
		a1=a1.offsetParent
	}
	return l1;
}

function freturnfalse(){return false};



;function myqpoint(x,o){this.x=x;this.y=o}
myqpoint.prototype.toString=function(){return"("+this.x+", "+this.y+")"}
myqpoint.prototype.equals=function(Z){if(!Z)return false;return this.x==Z.x&&this.y==Z.y}

;function mycasize(i,n){this.width=i;this.height=n}

;function mypancontrol(Tg){this.ticks=Tg;this.tick=0}
mypancontrol.prototype.reset=function(){this.tick=0}
;mypancontrol.prototype.next=function(){this.tick++;var pb=Math.PI*(this.tick/this.ticks-0.5);return(Math.sin(pb)+1)/2}
;mypancontrol.prototype.more=function(){return this.tick < this.ticks}
;


function myclabelitem(ax,ay,atxt){
	this.mtxt = atxt;
	this.mx = ax;
	this.my = ay;
}
function myclabel(acnt){
	//alert(1);
	this.mcnt = 0;
	this.mlabel = new Array(this.mcnt);
	//alert(2);
}
myclabel.prototype.additem=function(ax,ay,atxt){
	
	this.mlabel[this.mcnt] = new myclabelitem(ax,ay,atxt);
	this.mcnt++;
	
}
myclabel.prototype.createlayer=function(){
	ls1 = "";
	
	for(i=0;i < this.mcnt;i++){
		a = this.mlabel[i];
		ls1 +='<DIV id=xxx style="POSITION:absolute; background-color:#d0d0d0; Z-INDEX:10; TOP:'+a.my +'px; LEFT:'+a.mx+'px ; " >'+a.mtxt+'</DIV>';
	}
	
	return ls1;
}



function mycmap(Y,ia,i,n,bh,adrag,Hh,Dj){
	if(!Y)return;
	this.container=Y; //map container //map div

	
	this.toloadinfo = 0;
	this.disablePopups=bh;
	this.disableDragging=adrag;
	if(!ia)ia=myimged;
	this.mapTypes=Hh;
	if(!this.mapTypes)this.mapTypes=new Array(ia);
	this.zoomLevel=mc.z;
	this.topLeftTile=null;
	this.currentPanOffset=new mycasize(0,0); //pan tile offset
	this.centerBitmap=new myqpoint(0,0);
	this.tilePaddingOffset=new mycasize(0,0);
	this.tableSize=new mycasize(0,0);
	this.overlays=new Array();
	this.locations=new Array();
	this.panDistance=new mycasize(0,0);
	//this.panKeys=new Sc();
	this.setSpecification(ia);
	this.container.style.overflow="hidden";
	if(this.container.style.position!="absolute")this.container.style.position="relative";
	this.container.style.backgroundColor=this.spec.backgroundColor;
	
	if(!i||!n){
		i=this.container.offsetWidth;
		n=this.container.offsetHeight
	}
	this.viewSize=new mycasize(i,n);
	this.div=this.createMapDiv();
	this.container.appendChild(this.div);
	this.dragObject=new mydrag(this.div,0,0);
	this.dragObject.ondrag=this.eventHandler("onDrag");
	this.dragObject.ondragstart=this.eventHandler("onDragStart");
	this.dragObject.ondragend=this.eventHandler("onDragEnd");
	this.dragObject.onclick=this.eventHandler("onClick");
	if(adrag){
		this.dragObject.disable()
	}
	this.initializeMap();
	if(!Dj)this.showCopyright();
	this.onzoom=null;
	this.mygrid = null;
	this.onpan=null;
	this.onmousedown=null;
	this.onspecificationchange=null;
	this.oninfowindowclose=null;
	this.onresize=null;
	this.stateListeners=null;
	this.useRawVml=false
	this.createmylayer();
	this.mapcounter = 0;
	
	this.loadinfoTolerant = 0;
	
	//set hand-icon as cursor on map face
	mysetCursor(this.container,"http:\/\/hk.centamap.com\/gm\/img\/hand_drop.cur"); 
	//mysetCursor(this.container,"http:\/\/www.centamap.com\/gm\/img\/hand_drop.cur"); //Louis modified on 2009-12-09
	
}
mycmap.prototype.createmylayer=function(){
	this.myzoombutton = new Array(10);
	this.mypanbutton = new Array(20);
	this.loadinfourl = '';
	this.loadinfourlcnt = 0;


	this.mylayerlbl = document.createElement("div");
	this.mylayerlbl.id = "mylayerlbl";
	this.mylayerlbl.style.position="absolute";
	this.mylayerlbl.style.visibility="visible";
	this.mylayerlbl.style.top="0px";
	this.mylayerlbl.style.left="0px";
	this.mylayerlbl.style.width = "600px";
	this.mylayerlbl.style.height = "600px";
	this.mylayerlbl.style.zIndex=1;
	this.div.appendChild(this.mylayerlbl);


	this.mylayerbase = document.createElement("div");
	this.mylayerbase.id = "mylayerbase";
	this.mylayerbase.style.position="absolute";
	this.mylayerbase.style.visibility="visible";
	this.mylayerbase.style.top="0px";
	this.mylayerbase.style.left="0px";
	this.mylayerbase.style.width = "600px";
	this.mylayerbase.style.height = "600px";
	this.mylayerbase.style.zIndex=2;
	this.div.appendChild(this.mylayerbase);

	this.mylayer0 = document.createElement("div");
	this.mylayer0.id = "mylayer0";
	this.mylayer0.style.position="absolute";
	this.mylayer0.style.visibility="visible";
	this.mylayer0.style.top="0px";
	this.mylayer0.style.left="0px";
	this.mylayer0.style.width = "600px";
	this.mylayer0.style.height = "600px";
	this.mylayer0.style.zIndex=2;
	this.div.appendChild(this.mylayer0);

	this.mylayer1 = document.createElement("div");
	this.mylayer1.id = "mylayer1";
	this.mylayer1.style.position="absolute";
	this.mylayer1.style.visibility="visible";
	this.mylayer1.style.top="0px";
	this.mylayer1.style.left="0px";
	this.mylayer1.style.width = "600px";
	this.mylayer1.style.height = "600px";
	this.mylayer1.style.zIndex=2;
	this.div.appendChild(this.mylayer1);
	
	this.mylayer2 = document.createElement("div");
	this.mylayer2.id = "mylayer2";
	this.mylayer2.style.position="absolute";
	this.mylayer2.style.visibility="visible";
	this.mylayer2.style.top="0px";
	this.mylayer2.style.left="0px";
	this.mylayer2.style.width = "800px";
	this.mylayer2.style.height = "800px";
	this.mylayer2.style.zIndex=100;
	this.mylayer2.innerHTML = "";
	this.container.appendChild(this.mylayer2);
				
}
mycmap.prototype.createMapDiv=function(){
	var j=document.createElement("div");
	j.style.position="absolute";
	j.style.top="0px";
	j.style.left="0px";
	j.style.zIndex=0;
	j.style.backgroundColor=this.spec.backgroundColor;
	j.style.MozUserFocus = "normal";
	return j
}
;

mycmap.prototype.loadTileImages=function(){
	while(this.tileImages.length>this.tableSize.width){
		var If=this.tileImages.pop();
		for(var a=0;a < If.length;a++){
			this.div.removeChild(If[a])
		}
	}
	for(var a=this.tileImages.length;a < this.tableSize.width;a++){
		this.tileImages.push(new Array())
	}
	for(var a=0;a<this.tileImages.length;a++){
		while(this.tileImages[a].length>this.tableSize.height){
			var f=this.tileImages[a].pop();
			this.div.removeChild(f)
		}
		for(var O=this.tileImages[a].length;O < this.tableSize.height;O++){
			var f=lbcelement.create(null,this.spec.tileSize,this.spec.tileSize,null,null,0,null,null);
			f.style.position="absolute";
			//f.style.filter = "alpha(opacity=30)";
			this.tileImages[a].push(f);
			this.div.appendChild(f);
			this.configureImage(f,a,O);
		}
	}
}

;mycmap.prototype.deleteTiles=function(){if(this.tileImages){for(var a=0;a<this.tileImages.length;a++){if(this.tileImages[a]){for(var O=0;O<this.tileImages[a].length;O++){this.div.removeChild(this.tileImages[a][O])}}}}this.tileImages=null}
;mycmap.prototype.initializeMap=function(){
	this.deleteTiles();
	this.tileImages=new Array();
	this.calculateTileMeasurements();
	this.loadTileImages()
}

/*;mycmap.prototype.delgetSpanLatLng=function(e){
	if(!e)e=new mycasize(0,0);
	var Ha=this.spec.getLatLng(this.centerBitmap.x-this.viewSize.width/2,this.centerBitmap.y-this.viewSize.height/2,this.zoomLevel);
	var Da=this.spec.getLatLng(this.centerBitmap.x+this.viewSize.width/2,this.centerBitmap.y+this.viewSize.height/2,this.zoomLevel);
	e.width=Math.abs(Da.x-Ha.x);
	e.height=Math.abs(Da.y-Ha.y);
	return e
};*/

mycmap.prototype.drawCenter=function(){
	lflag = false;
	if(!e)e=new myqpoint(0,0);	 
	if(this.lastLatLng){
		e.x=this.lastLatLng.x  ;
		e.y=this.lastLatLng.y ;
		lflag = true;
	}
	/*else if(this.centerLatLng){
		e.x=this.centerLatLng.x  ;
		e.y=this.centerLatLng.y ;
		lflag = true;
	}*/	
	if(lflag){
		var ea=this.spec.getBitmapCoordinate(e.y,e.x,this.zoomLevel);
		ea.x = ea.x - this.centerBitmap.x + this.viewSize.width/2 - 10;
		ea.y = ea.y - this.centerBitmap.y + this.viewSize.height/2 - 10;
		ls1 = '<DIV id=xxx2tbl style="POSITION:absolute; Z-INDEX:16; TOP:'+ ea.y +'px; LEFT:'+ ea.x +'px ; " ><img src='+mc.iconurl+'mgif.gif></div>'
		this.mylayerbase.innerHTML = ls1;
		this.mylayerbase.style.visibility = "visible";
	}

	this.drawlabel();
}

;mycmap.prototype.drawlabel2=function(atxt){
	this.mylayerlbl.innerHTML = "";
	if (atxt != ''){
		this.mylayerlbl.innerHTML = atxt;
	}
}
;mycmap.prototype.drawlabel=function(){
	//draw label
	
	mc.viewcnt++;
	if(majax && majax.readyState!=0){
		majax.abort()
	}
	majax=jbcreateajax(); 
	if(majax){ 
		e = new myqpoint();
		this.getCenterLatLng(e);

		ls1 = mc.gmurl+"maplabel.aspx?zz=" + Math.random();
		ls1 += "&cx="+ Math.floor(e.x); 
		ls1 += "&cy="+Math.floor(e.y);
		ls1 += "&zm="+(1.0+this.zoomLevel);
		ls1 += "&vw="+this.viewSize.width;
		ls1 += "&vh="+this.viewSize.height;
		ls1 += "&ipcheck="+mc.checker;
		ls1 += "&ck=" ;
		if(mc.top){
			if(mc.top.ck != "gedit"){
				ls1 += mc.top.ck;
			}
		}
		ls1 += "&lg=";
		if(mc.top){
			ls1 += mc.top.lg;
		}
		ls1 += "&pw=" + mc.password ;
		//ls1 = "mc.top.jssetinfo("++","+Math.floor(e.y)+"," + this.zoomLevel + "," + this.viewSize.width +"," +this.viewSize.height+");"

		majax.open("GET",ls1,true); 
		majax.onreadystatechange=function(){ 
			if(majax.readyState==4 && majax.responseText){ 
				if(majax.responseText.charAt(0)==">"	){ majaxcnt-- }
				else{eval(majax.responseText);
				}
				
			}
		}
	}
	 majax.send(null); 
	 
}


;mycmap.prototype.getCenterLatLng=function(e){
	if(!e)e=new myqpoint(0,0);
	/*
	if(this.centerLatLng){
		e.x=this.centerLatLng.x  ;
		e.y=this.centerLatLng.y ;
	}
	
	if(this.lastLatLng){
		var ea=this.spec.getBitmapCoordinate(this.lastLatLng.y,this.lastLatLng.x,this.zoomLevel);
		if(ea.equals(this.centerBitmap)){
			e.x=this.lastLatLng.x;
			e.y=this.lastLatLng.y;
			//alert(1);
			return e
		}
	}
	*/
	var k=this.spec.getLatLng(this.centerBitmap.x,this.centerBitmap.y,this.zoomLevel);
	e.x=k.x;
	e.y=k.y;
	
	
	//Added by Louis on 2009-9-28
	
	parent.lx = e.x;
	parent.ly = e.y;
	
	return e
	
};

mycmap.prototype.calculateTileMeasurements=function(){
	var Ei=Math.ceil(this.viewSize.width/this.spec.tileSize)+2;
	var Vh=Math.ceil(this.viewSize.height/this.spec.tileSize)+2;
	

	//var Ei=Math.ceil(this.viewSize.width/this.spec.tileSize);
	//var Vh=Math.ceil(this.viewSize.height/this.spec.tileSize);
	
	this.tableSize.width=Ei;
	this.tableSize.height=Vh;
	//alert(Ei + " " + Vh);
	var Vb= Math.floor((this.tableSize.width*this.spec.tileSize-this.viewSize.width)/2) ;
	var Gb= Math.floor((this.tableSize.height*this.spec.tileSize-this.viewSize.height)/2) ;
	
	//alert( 3.0 * this.spec.tileSize / 2.0);
	this.tilePaddingOffset.width=Vb;
	this.tilePaddingOffset.height=Gb
}
;

mycmap.prototype.configureImage=function(f,x,o){
	//currentpanoffset = tile pan offset;
	//tilepaddingoffset = dpeend on browser minimize / maximize size
	//S,top drawing div location
	if(mc.iswatchlist == 1)return;
	
	var xh=(this.currentPanOffset.width+x)*this.spec.tileSize;
	var sj=(this.currentPanOffset.height+o)*this.spec.tileSize;
	var S=-this.tilePaddingOffset.width+xh -this.spec.tileSize/2 ;
	var top=-this.tilePaddingOffset.height+sj-this.spec.tileSize/2;
//	alert(this.tilePaddingOffset.width + "," + this.tilePaddingOffset.height);
	if(f.tileLeft!=S||f.tileTop!=top){
		f.style.left=S+"px";
		f.style.top=top+"px";
		f.tileLeft=S;
		f.tileTop=top
	}
	if(!this.topLeftTile){
		f.src=this.spec.emptyTileURL
		//f.src is transparent
	}
	else{
	//alert(this.topLeftTile.x);
		var M=this.spec.getTileURL(this.topLeftTile.x+x,this.topLeftTile.y+o,this.zoomLevel);
		
		if(f.src!=M){
			f.src=this.spec.emptyTileURL;
			f.src=M;
		}
	}
}

;var Origin=new mycasize(0,0);
mycmap.prototype.onMove=function(){
	this.centerLatLng=null;
	var La=this.getCurrentOffset(Origin);
	var x=this.topLeftTile.x*this.spec.tileSize+Math.floor(this.viewSize.width/2)+this.tilePaddingOffset.width-La.width;
	var o=this.topLeftTile.y*this.spec.tileSize+Math.floor(this.viewSize.height/2)+this.tilePaddingOffset.height-La.height;
	this.centerBitmap.x=x;
	this.centerBitmap.y=o;
	//this.drawDirections(this.directions,this.directionsDiv);
	if(this.onpan){
		this.onpan(x,o)
	}
}

mycmap.prototype.rotateTiles=function(){
	var La=this.getCurrentOffset(Origin);
	if(Math.abs(this.dragObject.left)>10000000||Math.abs(this.dragObject.top)>10000000){
		this.cancelPan();
		this.centerAtBitmap(this.centerBitmap);
		this.onStateChanged();
		return
	}
	while(La.width<-this.tilePaddingOffset.width/2){
		this.rotateRight();
		this.getCurrentOffset(La)
	}
	while(La.width>this.tilePaddingOffset.width/2){
		this.rotateLeft();
		this.getCurrentOffset(La)
	}
	while(La.height<-this.tilePaddingOffset.height/2){
		this.rotateDown();
		this.getCurrentOffset(La)
	}
	while(La.height>this.tilePaddingOffset.height/2){
		this.rotateUp();
		this.getCurrentOffset(La)
	}
};
mycmap.prototype.rotateLeft=function(){
	this.currentPanOffset.width--;
	this.topLeftTile.x--;
	var kb=this.tileImages.pop();
	if(kb){
		this.tileImages.unshift(kb);
		for(var a=0;a<kb.length;a++){
			this.configureImage(kb[a],0,a)
		}
	}
}
;mycmap.prototype.rotateRight=function(){
	this.currentPanOffset.width++;
	this.topLeftTile.x++;
	var kb=this.tileImages.shift();
	this.tileImages.push(kb);
	var x=this.tileImages.length-1;
	for(var a=0;a<kb.length;a++){
		this.configureImage(kb[a],x,a)
	}
}
;mycmap.prototype.rotateUp=function(){this.currentPanOffset.height--;this.topLeftTile.y--;for(var a=0;a<this.tileImages.length;a++){var f=this.tileImages[a].pop();this.tileImages[a].unshift(f);this.configureImage(f,a,0)}}
;mycmap.prototype.rotateDown=function(){this.currentPanOffset.height++;this.topLeftTile.y++;var o=this.tileImages[0].length-1;for(var a=0;a<this.tileImages.length;a++){var f=this.tileImages[a].shift();this.tileImages[a].push(f);this.configureImage(f,a,o)}}
;mycmap.prototype.onDragStart=function(b){
	if(this.onmousedown){
		this.onmousedown(b)
	}
	
};
mycmap.prototype.onDragEnd=function(b){
	/*if(!mc.cango(this.loadinfourlcnt)  || mc.allowdrag != 1){
		return false;
	}*/
	
	this.onStateChanged()
	
}

;mycmap.prototype.onDrag=function(){
	//if(this.loadinfourl!='')return;
	if(!this.topLeftTile)return;
	
	this.toloadinfo = 1;
	// added by Joe @ 2006-07-05
	/*
	this.toloadinfo = 2;

	if(mc.top.info != "undefined" && mc.top.info != null){
		if(mybrowser.mtype==20){
			mc.top.info.document.body.style.opacity = "0.2";
		}
		else{
			mc.top.info.document.body.style.filter = "alpha(opacity=20)";
		}
	}
	*/
	//aaa

	this.onMove();
	this.rotateTiles();
}

;
mycmap.prototype.onClick3=function(b,z){
	if(b==null)	b= new myqpoint(100,100);
	this.toloadinfo = 1;
	// added by joe @ 2006-07-06
	
	//this.toloadinfo = 3;
	if(!mc.top.head)return;
	if(mc.top.head)mc.top.jsfsetft(0,"");
	
	var x1 = 1.0*this.centerBitmap.x + 1.0* b.x - 1.0* this.viewSize.width/2;
	var y1 = 1.0*this.centerBitmap.y + 1.0 *b.y - 1.0* this.viewSize.height/2;
	

	var xy2 = this.spec.getLatLng(x1,y1,this.zoomLevel);
	this.zoomLevel += z;
	if(this.zoomLevel<0)this.zoomLevel=0;
	this.centerAtLatLng(xy2);
	this.onStateChanged(); //add2
	this.scaleChanged();
};

mycmap.prototype.zoomIn=function(){
	var x1 = 1.0*this.centerBitmap.x;
	var y1 = 1.0*this.centerBitmap.y;
	var xy2 = this.spec.getLatLng(x1,y1,this.zoomLevel);
	
	
		if (mc.top.ck && mc.top.ck.toUpperCase() != 'GSHKP')
			this.zoomLevel -= 1;
		else
			this.zoomLevel = 2;
	
	
	if(this.zoomLevel<0)this.zoomLevel=0;
	this.centerAtLatLng(xy2);
	
	this.onStateChanged(); //add2
	this.scaleChanged();
	
};

mycmap.prototype.zoomOut=function(){
	var x1 = 1.0*this.centerBitmap.x;
	var y1 = 1.0*this.centerBitmap.y;
	var xy2 = this.spec.getLatLng(x1,y1,this.zoomLevel);
	
	
		if (mc.top.ck && mc.top.ck.toUpperCase() != 'GSHKP')
			this.zoomLevel +=1;
		else
			this.zoomLevel = 6;
	
	
	
	if(this.zoomLevel>=12)this.zoomLevel=11;
	this.centerAtLatLng(xy2);
	this.onStateChanged(); //add2	
	this.scaleChanged();
	
};

mycmap.prototype.onClick=function(b){

	
	if( mc.allowclick != 1){
		return false;
	}
	this.toloadinfo = 1;
	if(mc.top.head)mc.top.jsfsetft(0,"");


	
	// add by joe 2006-06-02
	var x1 = 1.0*this.centerBitmap.x + 1.0* b.clientX  - 1.0* this.viewSize.width/2;
	var y1 = 1.0*this.centerBitmap.y + 1.0 *b.clientY - mc.mapoffset - 1.0* this.viewSize.height/2;

	var xy2 = this.spec.getLatLng(x1,y1,this.zoomLevel);

	if(this.mygrid != null ){
		if(this.mygrid.zstepflag == 1){
			this.zoomLevel += this.mygrid.zstep + 1;
			this.mygrid.zstepflag = 0;
		}
	}

	if (mc.top.ck && mc.top.ck.toUpperCase() != 'GSHKP')
	{
		this.zoomLevel --;
		if(this.zoomLevel<0)this.zoomLevel=0;
		this.centerAtLatLng(xy2);
		this.onStateChanged(); //add2
		this.scaleChanged();
		mc.afterclick();
	}
	else if (mc.top.ck && mc.top.ck.toUpperCase() == 'GSHKP' && this.zoomLevel > 3 && this.zoomLevel <= 7 )
	{
			this.zoomLevel = 2 ;
			if(this.zoomLevel<0)this.zoomLevel=0;
			this.centerAtLatLng(xy2);
			this.onStateChanged(); //add2
			this.scaleChanged();
			mc.afterclick();
	}
	else if (mc.top.ck && mc.top.ck.toUpperCase() == 'GSHKP' && this.zoomLevel <= 3)
	{	
		this.zoomLevel = 2;
		if(this.zoomLevel<0)this.zoomLevel=0;
		this.centerAtLatLng(xy2);
		this.onStateChanged(); //add2
		this.scaleChanged();
		mc.afterclick();
	}
	else if (mc.top.ck && mc.top.ck.toUpperCase() == 'GSHKP' && this.zoomLevel > 7)
	{
			this.zoomLevel = 6 ;
			if(this.zoomLevel<0)this.zoomLevel=0;
			this.centerAtLatLng(xy2);
			this.onStateChanged(); //add2
			this.scaleChanged();
			mc.afterclick();
	}
	else
	{
		this.zoomLevel --;
		if(this.zoomLevel<0)this.zoomLevel=0;
		this.centerAtLatLng(xy2);
		this.onStateChanged(); //add2
		this.scaleChanged();
		mc.afterclick();
	}
	
	
	//Modified by Louis on 2009-09-01, add new criteria for gShkp project
	//this.zoomLevel --;
	//if(this.zoomLevel<0)this.zoomLevel=0;
	//this.centerAtLatLng(xy2);
	//this.onStateChanged(); //add2
	//this.scaleChanged();
	//mc.afterclick();
	
	
	
	//b.target.releaseCapture();
	//window.captureEvents(Event.MouseDown|Event.MouseMove|Event.MouseOut|Event.Click|Event.MouseUp);
	//window.releaseEvents(Event.MOUSEDOWN|Event.MOUSEMOVE|Event.MOUSEUP|Event.CLICK);
	
	if(mybrowser.mtype == 20 && this.mygrid != null){
		var tmpwindow = window.open("about:blank", "dummy", "alwaysLowered=1,height=10,width=10");
		tmpwindow.close();
	}
	
}

mycmap.prototype.reconfigureAllImages=function(){
	if(this.tileImages.length==0){return}
	var Dd=new Array();
	for(var a=0;a<this.tileImages.length;a++){
		for(var O=0;O<this.tileImages[a].length;O++){
			f=this.tileImages[a][O];
			f.coordX=a;
			f.coordY=O;
			var wg=Math.min(a,this.tileImages.length-a-1);
			var Df=Math.min(O,this.tileImages[a].length-O-1);
			if(wg==0||Df==0){
				f.priority=0
			}else{
				f.priority=wg+Df
			}
			Dd.push(f)
		}
	}
	Dd.sort(function(Bh,ij){return ij.priority-Bh.priority});
	// Dd.sort(function(Bh,ij){return Bh.priority-ij.priority});
	
	
	for(var a=0;a<Dd.length;a++){
		var f=Dd[a];
		if(mybrowser.mtype==1)this.div.removeChild(f);
		this.configureImage(f,f.coordX,f.coordY);
		if(mybrowser.mtype==1)this.div.appendChild(f)
	}
}


;mycmap.prototype.pan=function(Ga,Ka){
	//if(this.loadinfourl!='')return;
	if(!this.topLeftTile){return}
	var sb=Math.sqrt(Ga*Ga+Ka*Ka);
	var Gi=Math.max(10,Math.floor(sb/20));
	this.mpnacontrol=new mypancontrol(Gi);
	this.mpnacontrol.reset();
	this.panDistance.width=Ga;
	this.panDistance.height=Ka;
	this.panStart=new myqpoint(this.dragObject.left,this.dragObject.top);
	this.doPan();
	this.centerLatLng = this.getCenterLatLng(new myqpoint());

}
;mycmap.prototype.doPan=function(){
	//if(this.loadinfourl!='')return;
	var pb=this.mpnacontrol.next();
	this.dragObject.moveTo(this.panStart.x+this.panDistance.width*pb,this.panStart.y+this.panDistance.height*pb);
	this.onMove();
	if(this.mpnacontrol.more()){
		this.panTimeout=this.setTimeout("this.doPan()",10);
		this.rotateTiles()
	}else{
		this.panTimeout=null;
		this.toloadinfo = 1;
		// added by joe @ 2006-07-06
		//this.toloadinfo = 3;
		this.onStateChanged()
	}
}
;mycmap.prototype.cancelPan=function(){if(this.panTimeout){clearTimeout(this.panTimeout)}}
;mycmap.prototype.recenterOrPanToLatLng=function(k){
	//if(this.loadinfourl!='')return;
	if(!this.topLeftTile){return}
	this.centerLatLng=new myqpoint(k.x,k.y);
	var k=this.spec.getBitmapCoordinate(this.centerLatLng.y,this.centerLatLng.x,this.zoomLevel);

	var lx=this.centerBitmap.x-k.x;
	var ly=this.centerBitmap.y-k.y;
	if(lx==0&&ly==0)return;
	if(Math.abs(lx)<this.viewSize.width&&Math.abs(ly)<this.viewSize.height){
		this.pan(lx,ly);return
	}
	this.centerAtBitmap(k);
	this.toloadinfo = 1;
	// added by joe @ 2006-07-06
	//this.toloadinfo = 3;
	this.onStateChanged()

}

;mycmap.prototype.ecrecenter=function(k){
	//if(this.loadinfourl!='')return;
	//alert(1);
	this.centerLatLng = this.lastLatLng;
	var k=this.spec.getBitmapCoordinate(this.centerLatLng.y,this.centerLatLng.x,this.zoomLevel);

	var lx=this.centerBitmap.x-k.x;
	var ly=this.centerBitmap.y-k.y;
	if(lx==0&&ly==0)return;

	if(Math.abs(lx)<this.viewSize.width&&Math.abs(ly)<this.viewSize.height){
		this.pan(lx,ly);
		return
	}else{
		this.centerAtBitmap(k);
		this.onStateChanged()
	}
}
mycmap.prototype.centerAndZoom=function(apoint,azoom){
	//if(this.loadinfourl!='')return;
	if(mc.top.head)mc.top.jsfsetft(0,"");
	var lflag=false;
	if(azoom!=this.zoomLevel){
		var ve=this.zoomLevel;
		this.zoomLevel=azoom;
		lflag=true
	}
	this.centerAtLatLng(apoint);
	if(lflag&&this.onzoom)
	this.onzoom(ve,this.zoomLevel);
}
;
mycmap.prototype.setlastlatlng=function(k){
	//this.lastLatLng=this.centerLatLng;
	this.lastLatLng=k;
}

mycmap.prototype.setwatchlist=function(k){
	mc.iswatchlist = 1;
}

mycmap.prototype.centerAtLatLng=function(k){
	//if(this.loadinfourl!='')return;
	this.centerLatLng=new myqpoint(k.x,k.y);
	var k=this.spec.getBitmapCoordinate(this.centerLatLng.y,this.centerLatLng.x,this.zoomLevel);
	this.centerAtBitmap(k)
};

mycmap.prototype.centerAtBitmap=function(k){
	this.centerBitmap.x=k.x;
	this.centerBitmap.y=k.y;
	var S=k.x-Math.floor(this.viewSize.width/2)-this.tilePaddingOffset.width;
	var top=k.y-Math.floor(this.viewSize.height/2)-this.tilePaddingOffset.height;
	var oc=Math.floor(S/this.spec.tileSize);
	var Gc=Math.floor(top/this.spec.tileSize);
	var Vb=oc*this.spec.tileSize-S;
	var Gb=Gc*this.spec.tileSize-top;
	if(Vb<-this.tilePaddingOffset.width/2){
		oc++;
		Vb+=this.spec.tileSize
	}else if(Vb>this.tilePaddingOffset.width/2){
		oc--;
		Vb-=this.spec.tileSize
	}
	if(Gb<-this.tilePaddingOffset.height/2){
		Gc++;
		Gb+=this.spec.tileSize
	}else if(Gb>this.tilePaddingOffset.height/2){
		Gc--;Gb-=this.spec.tileSize
	}
	if(!this.topLeftTile){
		this.topLeftTile=new myqpoint(oc,Gc);
		//new Qc(this)
	}else{
		this.topLeftTile.x=oc;
		this.topLeftTile.y=Gc
	}
	this.currentPanOffset.width=0;
	this.currentPanOffset.height=0;
	this.reconfigureAllImages();
	this.dragObject.moveTo(Vb,Gb);
	this.setlastlatlng(this.centerLatLng);
	this.toloadinfo = 1;
}

;mycmap.prototype.addStateListener=function(hi){
	if(!this.stateListeners)this.stateListeners=new Array();
	this.stateListeners.push(hi)
};

mycmap.prototype.scaleChanged= function(){

	if (mc.lck.toUpperCase() == 'GSHKP'){	
			this.setScalePanel();
	}
	else{
		if(mc.expressmode == 0 || mc.expressmode == 2){
			
			if(this.zoomLevel != null){
				for(i=1;i<mc.zs.length;i++){
					this.myzoombutton[i].innerHTML = this.myzoombutton[i].img1;
				}
				this.myzoombutton[this.zoomLevel+1].innerHTML = this.myzoombutton[this.zoomLevel+1].img2;
			}		
			this.setScalePanel();
		}
	}
	
	
}

mycmap.prototype.onStateChanged=function(){
	
	if(!this.topLeftTile)return;
	
	if(this.stateListeners){
		
		e = new myqpoint();
/*
		if(this.viewSize.width > 1024){
			this.viewSize.width = 1024;
		}
		if(this.viewSize.height > 768){
			this.viewSize.height = 768;
		}
*/
		
		this.mylayerlbl.style.left=( -1.0 * this.div.style.left.replace("px",""))  + "px";
		this.mylayerlbl.style.top= (-1.0* this.div.style.top.replace("px",""))+"px";
		this.mylayerlbl.style.width = this.viewSize.width + "px";
		this.mylayerlbl.style.height = this.viewSize.height + "px";
		this.mylayerlbl.visibility = "visible";

		if(mc.expressmode == 0){
			var j = document.getElementById("divscale");
			j.style.top = this.viewSize.height-65;
			j.style.left = 5;
		}
		
		
		if(mc.lck.toUpperCase() == 'GSHKP'){
			var j = document.getElementById("divscale");
			j.style.top = this.viewSize.height-40;
			j.style.left = 5;
		}
		
		

		this.mylayerbase.innerHTML = "";
		this.mylayer0.innerHTML = "";
		this.mylayer0.innerHTML = " <DIV id=xxx style=\"POSITION:absolute; Z-INDEX:10; TOP:0px; LEFT:0px ; \" ><table border=0 width= " +this.viewSize.width+" height="+this.viewSize.height+"><tr><td></td></tr></table></DIV>";
		this.mylayer1.innerHTML = "";
		this.mylayer2.innerHTML = "";
	
	
		this.getCenterLatLng(e);
		this.drawCenter();
		
		if(mc.checker=='-100'){
			alert('invalid password');
			top.location.href='http://hk.centamap.com';
			//top.location.href='http://www.centamap.com'; //Louis modified on 2009-12-09
		};
		
		

		if(this.toloadinfo==1 ){
			this.toloadinfo=0;
			if(mc.top.head && mc.lck != "gbase"){
				if(mc.lck == ""){
					mc.lck = "gbase";
					ls1 = "mc.top.jssetinfo("+Math.floor(e.x)+","+Math.floor(e.y)+"," + this.zoomLevel + "," + this.viewSize.width +"," +this.viewSize.height+");";
					ls2 = "mc.top.jssetxy("+Math.floor(e.x)+","+Math.floor(e.y)+"," + this.zoomLevel + "," + this.viewSize.width +"," +this.viewSize.height+");";
					this.loadinfo(ls1, ls2);
				}
				else if (mc.lck.toUpperCase() == 'GSHKP'){
					ls1 = "mc.top.jssetinfo("+Math.floor(e.x)+","+Math.floor(e.y)+"," + this.zoomLevel + "," + this.viewSize.width +"," +this.viewSize.height+");";
					ls2 = "mc.top.jssetxy("+Math.floor(e.x)+","+Math.floor(e.y)+"," + this.zoomLevel + "," + this.viewSize.width +"," +this.viewSize.height+");";
					this.loadinfo(ls1, ls2);
				}
				else{
					mc.top.jssetinfowait();
					ls1 = "mc.top.jssetinfo("+Math.floor(e.x)+","+Math.floor(e.y)+"," + this.zoomLevel + "," + this.viewSize.width +"," +this.viewSize.height+");";
					ls2 = "mc.top.jssetxy("+Math.floor(e.x)+","+Math.floor(e.y)+"," + this.zoomLevel + "," + this.viewSize.width +"," +this.viewSize.height+");";
					this.loadinfo(ls1, ls2);
				}
				
			}
			else if(mc.top.head){
				ls1 = "";
				ls2 = "mc.top.jssetxy("+Math.floor(e.x)+","+Math.floor(e.y)+"," + this.zoomLevel + "," + this.viewSize.width +"," +this.viewSize.height+");";
				this.loadinfo(ls1, ls2);
			}
			
			
			
			if(mc.top.feedbackf){
				mc.top.feedback(Math.floor(e.x),Math.floor(e.y), this.zoomLevel +1);
			}
			

			this.mylayerbase.style.left=( -1.0 * this.div.style.left.replace("px",""))  + "px";
			this.mylayerbase.style.top= (-1.0* this.div.style.top.replace("px",""))+"px"  ;
			this.mylayerbase.style.width = this.viewSize.width + "px";
			this.mylayerbase.style.height = this.viewSize.height + "px";
			this.mylayerbase.visibility = "visible";
			
			this.mylayer0.style.left=( -1.0 * this.div.style.left.replace("px",""))  + "px";
			this.mylayer0.style.top= (-1.0* this.div.style.top.replace("px",""))+"px"  ;
			this.mylayer0.style.width = this.viewSize.width + "px";
			this.mylayer0.style.height = this.viewSize.height + "px";
			this.mylayer0.visibility = "visible";
			
			this.mylayer1.style.left=( -1.0 * this.div.style.left.replace("px",""))  + "px";
			this.mylayer1.style.top= (-1.0* this.div.style.top.replace("px",""))+"px"  ;
			this.mylayer1.style.width = "0px";
			//this.mylayer1.style.width = this.viewSize.width + "px";
			this.mylayer1.style.height = this.viewSize.height + "px";
			this.mylayer1.innerHTML = "";
			this.mylayer1.visibility = "visible";
			
			this.mylayer2.style.left="0px";//this.mylayer0.style.left;
			this.mylayer2.style.top= "0px";//this.mylayer0.style.top;
			this.mylayer2.style.width = "0px";
			//this.mylayer2.style.width = this.viewSize.width + "px";
			this.mylayer2.style.height = this.viewSize.height + "px";
			this.mylayer2.visibility = "visible";
			
		}
	}
	



	if (document.selection)document.selection.empty();
	else if (window.getSelection) window.getSelection().removeAllRanges();

	ecjsCheckAction();

}

;mycmap.prototype.loadinfo=function(a, b){
	if(b){
		eval(b);
	}
	if(a != ""){
		this.loadinfourlcnt ++;	
		this.waitprocess(a);
	}
}

;mycmap.prototype.loadinfo_go=function(a){
	this.loadinfourlcnt = 0;
	eval(a);		
}

mycmap.prototype.waitprocess=function(a){
	if(majaxprocess && majaxprocess.readyState!=0){
		majaxprocess.abort();
	}
	majaxprocess=jbcreateajax(); 
	if(majaxprocess){ 
		ls1 = mc.gmurl+"waitprocess.aspx?url="+a+"&b="+Math.random(); 
		majaxprocess.open("GET",ls1,true); 
		majaxprocess.onreadystatechange=function(){ 
			if(majaxprocess.readyState==4 && majaxprocess.responseText){ 
				eval(majaxprocess.responseText);
			}
		}
	}
	 majaxprocess.send(null); 
};

/*
;mycmap.prototype.loadinfo=function(a){
	this.loadinfourlcnt ++;
	this.loadinfourl = a;
	//if(this.loadinfourlcnt >2)alert('please wait...');
	b = "_jsmapapp.map.loadinfourlcnt --;if(_jsmapapp.map.loadinfourl=='"+a+"'){"+a+";_jsmapapp.map.loadinfourl='';}"; 
	//c = "if(_jsmapapp.map.waitprocess == 0){_jsmapapp.map.loadinfourlcnt --;if(_jsmapapp.map.loadinfourl=='"+a+"'){"+a+";_jsmapapp.map.loadinfourl='';}}"; 
	//setTimeout(b,mc.wait);
	eval(b);
}
*/

;mycmap.prototype.onReload=function(b){
		this.calculateTileMeasurements();
		this.loadTileImages();
		this.centerAtBitmap(this.centerBitmap);
		this.onStateChanged();
}

;mycmap.prototype.onResize=function(b){
	if(this.viewSize.width!=this.container.offsetWidth||this.viewSize.height!=this.container.offsetHeight){
		this.viewSize.width=this.container.offsetWidth;
		this.viewSize.height=this.container.offsetHeight;
		
		
		this.calculateTileMeasurements();
		this.loadTileImages();
		this.centerAtBitmap(this.centerBitmap);
		this.onStateChanged();
		
		if (mc.lck.toUpperCase() != 'GSHKP'){
			for(i=1;i<mc.zs.length;i++){
				this.myzoombutton[i].style.left=this.viewSize.width-50 + "px";
			}
		}
		
		
		for(i=1;i<10;i++){
			if(miconspan[i] != ""){
				this.mypanbutton[i].style.left= String(this.viewSize.width-70 + miconspantx[i]) + "px";
			}
		}
		
		// three map mode
		//this.myzoombutton[15].style.left=this.viewSize.width-70 + "px";
		//this.myzoombutton[16].style.left=this.viewSize.width-70 + "px";
		//this.myzoombutton[17].style.left=this.viewSize.width-70 + "px";
		
		if (mc.lck.toUpperCase() != 'GSHKP'){
			this.myzoombutton[15].style.left=this.viewSize.width-180-70 + "px";
			this.myzoombutton[16].style.left=this.viewSize.width-125-70 + "px";
			this.myzoombutton[17].style.left=this.viewSize.width-70-70 + "px";
			this.myzoombutton[18].style.left=this.viewSize.width-70-70 + "px";
			
		}
		else{
			this.myzoombutton[23].style.left=this.viewSize.width-58 + "px";
			this.myzoombutton[24].style.left=this.viewSize.width-58 + "px";
		}
		
	
		if(this.onresize){this.onresize()}
	
	
		if (mc.lck.toUpperCase() != 'GSHKP')
		{	
			// resize the frame size
			if(parent.document.body.offsetWidth > 1024 && parent.document.body.offsetHeight > 768){
				var a = mc.top.document.getElementById("fmap");
				var b = mc.top.document.getElementById("finfo");
				var c = mc.top.document.getElementById("fhead");
				a.rows = "*,150px";
				b.cols = "35px,390px,*";
				c.cols = "430px,*";
				mc.top.info.document.getElementById('divinfo').style.height = mc.top.info.document.body.offsetHeight-mc.top.info.document.getElementById('divinfo').offsetTop;
			}
			else if(parent.document.body.offsetWidth <=800 && parent.document.body.offsetHeight <= 600){
				var a = mc.top.document.getElementById("fmap");
				var b = mc.top.document.getElementById("finfo");
				var c = mc.top.document.getElementById("fhead");
				a.rows = "*,2px";
				b.cols = "1px,319px,*";
				c.cols = "320px,*";
				mc.top.info.document.getElementById('divinfo').style.height = mc.top.info.document.body.offsetHeight-mc.top.info.document.getElementById('divinfo').offsetTop;			
			}
			else if(parent.document.body.offsetWidth <= 1024){
				var a = mc.top.document.getElementById("fmap");
				var b = mc.top.document.getElementById("finfo");
				var c = mc.top.document.getElementById("fhead");
				a.rows = "*,2px";
				b.cols = "35px,340px,*";
				c.cols = "380px,*";
				mc.top.info.document.getElementById('divinfo').style.height = mc.top.info.document.body.offsetHeight-mc.top.info.document.getElementById('divinfo').offsetTop;
			}
		}
		

	}
};

mycmap.prototype.getCurrentOffset=function(e){
	if(!e)e=new mycasize(0,0);
	e.width=this.dragObject.left+this.currentPanOffset.width*this.spec.tileSize;
	e.height=this.dragObject.top+this.currentPanOffset.height*this.spec.tileSize;
	return e;
}
;mycmap.prototype.setSpecification=function(Qa){
	this.spec=Qa;
	if(!Qa.emptyTilePreload){
		var ac=document.createElement("IMG");
		ac.style.position="absolute";
		ac.style.visibility="hidden";
		ac.style.top=mysetpx(-200);
		ac.style.left=mysetpx(-200);
		
		//ac.style.top=mysetpx(30);
		//ac.style.left=mysetpx(30);
		document.body.appendChild(ac);
		Qa.emptyTilePreload=ac
	}
	this.spec.emptyTilePreload.src=this.spec.emptyTileURL
}
;mycmap.prototype.zoomTo=function(va){
	if(! mc.cango(this.loadinfourlcnt) ){
		return;
	}
	if(!this.topLeftTile)return;
	if(va>=this.spec.numZoomLevels){
		va=this.spec.numZoomLevels-1
	}else if(va<0){
		va=0
	}
	var ve=this.zoomLevel;
	if(va!=ve){
		llast = this.lastLatLng ;
		var G=this.getCenterLatLng();
		this.centerAndZoom(G,va)
		this.setlastlatlng(llast);
		this.onStateChanged();
		this.scaleChanged();
		//this.mapModeChange();
	}
}

;mycmap.prototype.mapModeChange=function(mode){

	if(! mc.cango(this.loadinfourlcnt) ){
		return;
	}
	this.toloadinfo = 0;
	if(mode != -1){
		mc.mapmode = mode;
	}
	this.reconfigureAllImages();
	//this.onStateChanged();
	
	// change map mode
	if(mc.lg == "b5"){
		this.myzoombutton[15].img1 = "<img src="+micons[15] + " border=0 alt=\"Map Mode\" onmouseover=\"this.src='"+micons2[15]+"';\"  onmouseout=\"this.src='"+micons[15]+"';\">";
		this.myzoombutton[15].img2 = "<img src="+micons2[15] + " border=0 alt=\"Map Mode\">";
		
		this.myzoombutton[16].img1 = "<img src="+micons[16] + " border=0 alt=\"Aerial Mode\" onmouseover=\"this.src='"+micons2[16]+"';\"  onmouseout=\"this.src='"+micons[16]+"';\">";
		this.myzoombutton[16].img2 = "<img src="+micons2[16] + " border=0 alt=\"Aerial Mode\">";
		
		this.myzoombutton[17].img1 = "<img src="+micons[17] + " border=0 alt=\"Hybrid Mode\" onmouseover=\"this.src='"+micons2[17]+"';\"  onmouseout=\"this.src='"+micons[17]+"';\">";
		this.myzoombutton[17].img2 = "<img src="+micons2[17] + " border=0 alt=\"Hybrid Mode\">";	
	
		this.myzoombutton[18].img1 = "<img src="+micons[21] + " border=0 alt=\"Print Map\" onmouseover=\"this.src='"+micons2[21]+"';\"  onmouseout=\"this.src='"+micons[21]+"';\">";
		this.myzoombutton[18].img2 = "";
		//this.myzoombutton[18].img2 = "<img src="+micons2[21] + " border=0 alt=\"Print Map\">";	
	}
	else{
		this.myzoombutton[15].img1 = "<img src="+micons[18] + " border=0 alt=\"Map Mode\" onmouseover=\"this.src='"+micons2[18]+"';\"  onmouseout=\"this.src='"+micons[18]+"';\">";
		this.myzoombutton[15].img2 = "<img src="+micons2[18] + " border=0 alt=\"Map Mode\">";
		
		this.myzoombutton[16].img1 = "<img src="+micons[19] + " border=0 alt=\"Aerial Mode\" onmouseover=\"this.src='"+micons2[19]+"';\"  onmouseout=\"this.src='"+micons[19]+"';\">";
		this.myzoombutton[16].img2 = "<img src="+micons2[19] + " border=0 alt=\"Aerial Mode\">";
		
		this.myzoombutton[17].img1 = "<img src="+micons[20] + " border=0 alt=\"Hybrid Mode\" onmouseover=\"this.src='"+micons2[20]+"';\"  onmouseout=\"this.src='"+micons[20]+"';\">";
		this.myzoombutton[17].img2 = "<img src="+micons2[20] + " border=0 alt=\"Hybrid Mode\">";
		
		this.myzoombutton[18].img1 = "<img src="+micons[22] + " border=0 alt=\"Print Map\" onmouseover=\"this.src='"+micons2[22]+"';\"  onmouseout=\"this.src='"+micons[22]+"';\">";
		//this.myzoombutton[18].img1 = "<img src="+micons[22] + ">";
		this.myzoombutton[18].img2 = "";
		//this.myzoombutton[18].img2 = "<img src="+micons2[22] + " border=0 alt=\"Print Map\">";	
	}
	
	this.myzoombutton[15].innerHTML = this.myzoombutton[15].img1;
	this.myzoombutton[16].innerHTML = this.myzoombutton[16].img1;
	this.myzoombutton[17].innerHTML = this.myzoombutton[17].img1;
	this.myzoombutton[18].innerHTML = this.myzoombutton[18].img1;

				
	if(mc.mapmode == 0){
		this.myzoombutton[15].innerHTML = this.myzoombutton[15].img2;
	}
	else if(mc.mapmode == 1){
		this.myzoombutton[16].innerHTML = this.myzoombutton[16].img2;
	}
	else if(mc.mapmode == 2){
		this.myzoombutton[17].innerHTML = this.myzoombutton[17].img2;
	}
	
	//Modified by Louis on 2009/06/02, requested by Lands
	//alert(mc.lg);
	this.showCopyright(); //update the CopyRight statement.
}

;mycmap.prototype.mapiscensus=function(mode){
	if(! mc.cango(this.loadinfourlcnt) ){
		return;
	}
	mc.iscensus = mode;
	this.reconfigureAllImages();
}

;mycmap.prototype.toggleTileBorders=function(){if(this.tileImages){for(var a=0;a<this.tileImages.length;a++){if(this.tileImages[a]){for(var O=0;O<this.tileImages[a].length;O++){var f=this.tileImages[a][O];if(f.hasBorder){f.style.border="0";f.hasBorder=false}else{f.style.border="1px solid black";f.hasBorder=true}}}}}}
;mycmap.prototype.createMapControl=function(){
	var E=document.createElement("div");
	E.setAttribute('class', 'printhidden');
	E.setAttribute('id', 'controlpanel');
	this.createPanningControls(E);
	this.createZoom8Controls(E);
	this.createIntDiv(E);
	

	
	return E;
}



var micons = new Array(
mc.iconurl+"xxx.png",
mc.iconurl+"zoom1.gif",
mc.iconurl+"zoom2.gif",
mc.iconurl+"zoom3.gif",
mc.iconurl+"zoom4.gif",
mc.iconurl+"zoom5.gif",
mc.iconurl+"zoom6.gif",
mc.iconurl+"zoom7.gif",
mc.iconurl+"zoom8.gif",
mc.iconurl+"zoom9.gif",
mc.iconurl+"zoom10.gif",
mc.iconurl+"zoom11.gif",
mc.iconurl+"zoom12.gif",
mc.iconurl+"zoomplus.gif",
mc.iconurl+"zoomminus.gif",
mc.iconurl+"map.gif",
mc.iconurl+"A_map.gif",
mc.iconurl+"H_map.gif",
mc.iconurl+"emap.gif",
mc.iconurl+"eA_map.gif",
mc.iconurl+"eH_map.gif",
mc.iconurl+"printmap.gif",
mc.iconurl+"eprintmap.gif",
mc.iconurl+"Bigin.png",
mc.iconurl+"Bigout.png",
mc.iconurl+"xxx.png");


var micons2 = new Array(
mc.iconurl+"xxx.png",
mc.iconurl+"zoom1a.gif",
mc.iconurl+"zoom2a.gif",
mc.iconurl+"zoom3a.gif",
mc.iconurl+"zoom4a.gif",
mc.iconurl+"zoom5a.gif",
mc.iconurl+"zoom6a.gif",
mc.iconurl+"zoom7a.gif",
mc.iconurl+"zoom8a.gif",
mc.iconurl+"zoom9a.gif",
mc.iconurl+"zoom10a.gif",
mc.iconurl+"zoom11a.gif",
mc.iconurl+"zoom12a.gif",
mc.iconurl+"zoomplusa.gif",
mc.iconurl+"zoomminusa.gif",
mc.iconurl+"map_over.gif",
mc.iconurl+"A_map_over.gif",
mc.iconurl+"H_map_over.gif",
mc.iconurl+"emap_over.gif",
mc.iconurl+"eA_map_over.gif",
mc.iconurl+"eH_map_over.gif",
mc.iconurl+"printmap_over.gif",
mc.iconurl+"eprintmap_over.gif",
mc.iconurl+"Bigin_over.png",
mc.iconurl+"Bigout_over.png",
mc.iconurl+"xxx.png");

var mscaleicons = new Array(
mc.iconurl+"xxx.png",
mc.iconurl+"/scale/z1_scale.gif",
mc.iconurl+"/scale/z2_scale.gif",
mc.iconurl+"/scale/z3_scale.gif",
mc.iconurl+"/scale/z4_scale.gif",
mc.iconurl+"/scale/z5_scale.gif",
mc.iconurl+"/scale/z6_scale.gif",
mc.iconurl+"/scale/z7_scale.gif",
mc.iconurl+"/scale/z8_scale.gif",
mc.iconurl+"/scale/z9_scale.gif",
mc.iconurl+"/scale/z10_scale.gif",
mc.iconurl+"/scale/z11_scale.gif",
mc.iconurl+"/scale/z12_scale.gif",
mc.iconurl+"xxx.png",
mc.iconurl+"xxx.png");


var mlabeliconslist1 = new Array(
mc.iconurl+"list.gif",
mc.iconurl+"uprice.gif",
mc.iconurl+"bldgage.gif"
);
var mlabeliconslist2 = new Array(
mc.iconurl+"listover.gif",
mc.iconurl+"upriceover.gif",
mc.iconurl+"bldgageover.gif"
);

var mthemeiconslist1 = new Array(
mc.iconurl+"cancel.gif",
//mc.iconurl+"theme.gif"
mc.iconurl+"btntheme.gif"

);
var mthemeiconslist2 = new Array(
mc.iconurl+"cancelover.gif",
//mc.iconurl+"themeover.gif"
mc.iconurl+"btnthemeover.gif"
);

var mlabel = new Array(
mc.iconurl+"labelbg.gif"
);

mycmap.prototype.createmapiconsdiv=function(aimg,aimg2, asizex,asizey,ax,ay,aalt){
	var j=document.createElement("div");
	j.style.position="absolute";
	mysetCursor(j,"default");
	//aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
	//mysetCursor(this.src,"url(http:\/\/localhost\/gm\/img\/hand_drag.cur)");
	j.unselectable="on";
	j.onselectstart=freturnfalse;
	j.img1 = "<img src="+aimg + " border=0 alt=\""+aalt+"\" onmouseover=\"this.src='"+aimg2+"';\"  onmouseout=\"this.src='"+aimg+"';\">";
	j.img2 = "<img src="+aimg2 + " border=0 alt=\""+aalt+"\">";
	j.innerHTML=j.img1;
	j.style.top = ay + "px";
	j.style.left = ax + "px";
	
	j.style.fontSize="11px";
	j.style.fontFamily="Arial, sans serif";
	j.style.MozUserSelect="none";
	
	return j
}





mycmap.prototype.createLabelbutton=function(ax,ay, awidth, aheight, acontent, aid, aalt, aactive){
	
	var k=document.createElement("div");
	k.style.position="relative";
	
	var j=document.createElement("div");
	j.setAttribute("id", "link" + aid);
	j.style.position="absolute";
	mysetCursor(j,"default");
	j.unselectable="on";
	j.onselectstart=freturnfalse;
	j.innerHTML="<a href='javascript:parent.map.labelcontrolPressed("+aid+");'>" + acontent + "</a>";
	j.style.top = ay + "px";
	j.style.left = ax + "px";
	j.style.width = awidth + "px";
	j.style.height = aheight + "px";
	j.style.border="solid 1px #000000";
	j.style.background = "#FFFFFF";
	j.style.padding = "0 2 0 2";
	j.style.fontSize="10pt";
	j.style.fontFamily="Arial, sans serif";
	j.style.MozUserSelect="none";
	j.style.zindex= "101";
	j.style.TextAlignment = "middle";
	
	var l = document.createElement("div");
	l.setAttribute("id", aid);
	l.style.position="absolute";
	mysetCursor(l,"default");
	l.unselectable="on";
	l.onselectstart=freturnfalse;
	l.innerHTML="<b>" + acontent + "</b>";
	l.style.top = ay + "px";
	l.style.left = ax + "px";
	l.style.width = awidth + "px";
	l.style.height = aheight + "px";
	l.style.border="solid 1px #000000";
	l.style.background = "#FFFFFF";
	l.style.padding = "0 2 0 2";
	l.style.fontSize="10pt";
	l.style.fontFamily="Arial, sans serif";
	l.style.MozUserSelect="none";
	l.style.zindex= "100";
	l.style.TextAlignment = "middle";
	
	if(aactive == 1)
	{
		l.style.visibility = "visible";
		j.style.visibility = "hidden";
	}
	else{
		j.style.visibility = "visible";
		l.style.visibility = "hidden";
	}
	
	k.appendChild(j);
	k.appendChild(l);
	
	return k;
	
}


// create theme at the top left hand coner of the map
mycmap.prototype.createIntDiv=function(E){

	if (mc.top.ck && mc.top.ck.toUpperCase() == 'GSHKP'){
		var myScale = this.createScalePanel();
		E.appendChild(myScale);
	}
	else
	{
		//if(parent.ft && parent.ft[4] == 'exp'){
		//Condition modified by Paul Tam on 20080827
		if(parent.ft && (parent.ft[4] == 'exp' || parent.ft[4] == 'cpn')){
			if(mc.expressmode == 0){
				var myScale = this.createScalePanel();
				E.appendChild(myScale);
			}
		}
		//Condition added by Paul Tam on 20080922
		else if(mc.expressmode != 3)
		{
			var g = this;
			var myIntPanel = this.createIntPanel(0,0);
			
			var myThemeButton = this.createThemeButton(0, 0, '');
			myIntPanel.appendChild(myThemeButton);

			var myCustomControlsPanel = this.createCustomControlsPanel();
			myIntPanel.appendChild(myCustomControlsPanel);
			
			var myGuideButton = this.createGuideButton();	
			myIntPanel.appendChild(myGuideButton);
			
			E.appendChild(myIntPanel);
			
			if(mc.expressmode == 0){
				var myScale = this.createScalePanel();
				E.appendChild(myScale);
			}
		}
	}	
};

mycmap.prototype.createIntPanel=function(ax,ay){
	var j = document.createElement("span");
	j.style.top = ay;
	j.style.left = ax;
	j.style.position = "relative";
	j.style.padding = "2 2 2 2";
	return j;
}

mycmap.prototype.createScalePanel=function(){

	var j = document.createElement("div");
	j.setAttribute("id", "divscale");	
	//j.style.top = this.viewSize.height-65;
	
	if (mc.top.ck && mc.top.ck.toUpperCase() != 'GSHKP')
		j.style.top = this.viewSize.height-65;
	else
		j.style.top = this.viewSize.height-40;
	
	//j.style.top = 100;
	j.style.left = 0;
	j.style.position = "relative";
	j.style.padding = "2 2 2 2";
	j.innerHTML = "<img src='"+mscaleicons[(1.0+this.zoomLevel)]+"'/>";

	return j;	
}

mycmap.prototype.setScalePanel=function(){
	var j = document.getElementById("divscale");
	if(j){
		j.innerHTML = "<img src='"+mscaleicons[(1.0+this.zoomLevel)]+"'/>";
	}
}

mycmap.prototype.createThemeButton=function(ax,ay,aalt){
	var j=document.createElement("span");
	mysetCursor(j,"default");

	j.setAttribute("id", "divthemebutton");
	j.unselectable="on";
	j.onselectstart=freturnfalse;
	if(mc.lg == "b5"){
		//j.innerHTML="<span onmouseover='javascript:parent.map.ecjsfLayerSet(\"myLayer2\",catlist);'><img style='position:relative;top:2px;left:0px' src='"+mc.iconurl+"search.gif'><span style='text-decoration:underline;color:#000099;position:relative;top:-4px;left:0px' id='txtthemebutton' >地圖面資訊</span></span>";
		//j.innerHTML="<input type=button onmouseover='javascript:parent.map.ecjsfLayerSet(\"myLayer2\",catlist);' value='地圖面資訊'/>";
		j.innerHTML="<a href='javascript:parent.map.ecjsfLayerSet(\"myLayer2\",catlist);'><img style='position:relative;top:2px;left:0px' src='"+mc.iconurl+"search.gif'><span style='position:relative;top:-4px;left:0px' id='txtthemebutton' >地圖面資訊</span></a>";
	}
	else{
		//j.innerHTML="<a href='javascript:top.map.ecjsfLayerSet(\"myLayer2\",catlist);'><img style='position:relative;top:3px;left:-3px' src='"+mc.iconurl+"search.gif'><span style='position:relative;top:-4px;left:0px' id='txtthemebutton' >Query</span></a><span style='position:relative;top:-4px;left:0px'>&nbsp;&nbsp;>&nbsp;</span>";
		j.innerHTML="<a href='javascript:parent.map.ecjsfLayerSet(\"myLayer2\",catlist);'><img style='position:relative;top:3px;left:-3px' src='"+mc.iconurl+"search.gif'><span style='position:relative;top:-4px;left:0px' id='txtthemebutton' >Query</span></a>";
		//j.innerHTML="<a href='javascript:top.map.ecjsfLayerSet(\"myLayer2\",catlist);'><span id='txtthemebutton' >Theme Map</span></a>&nbsp;&nbsp;>&nbsp;";
	}
	j.style.background = "#FFFFFF";
	j.style.padding = "2 5 2 5";
	j.style.fontSize="10pt";
	j.style.fontFamily="Arial, sans serif";
	j.style.MozUserSelect="none";
	j.style.postion = "absolute";
	
	j.style.borderLeft = "outset 1px #dcdcdc";
	j.style.borderTop = "outset 1px #dcdcdc";
	j.style.borderBottom = "outset 1px #dcdcdc";
	j.style.borderRight = "outset 1px #dcdcdc";
	
	return j
}

mycmap.prototype.createBackButton1=function(ax,ay,aalt){
	var j=document.createElement("span");
	mysetCursor(j,"default");

	j.setAttribute("id", "divbackbutton");
	j.unselectable="on";
	j.onselectstart=freturnfalse;
	
	if(mc.lg == "b5"){
		j.innerHTML="<a href='javascript:parent.jsfsetck(\"gbase\",\"\",\"\",\"\",\"\",\"\");'><img style='position:relative;top:2px;left:-2px' src='"+mc.iconurl+"btnback.gif'><span style='position:relative;top:-4px;left:0px' id='txtbackbutton' >返回主頁</span></a>";
	}
	else{
		j.innerHTML="<a href='javascript:parent.jsfsetck(\"gbase\",\"\",\"\",\"\",\"\",\"\");'><img style='position:relative;top:2px;left:-2px' src='"+mc.iconurl+"btnback.gif'><span style='position:relative;top:-4px;left:0px' id='txtbackbutton' >Back to Main Page</span></a>";
	}
	
	j.style.background = "#FFFFFF";
	j.style.padding = "2 5 2 5";
	j.style.fontSize="10pt";
	j.style.fontFamily="Arial, sans serif";
	j.style.MozUserSelect="none";
	j.style.postion = "absolute";
	
	j.style.borderLeft = "outset 1px #dcdcdc";
	j.style.borderTop = "outset 1px #dcdcdc";
	j.style.borderBottom = "outset 1px #dcdcdc";
	j.style.borderRight = "outset 1px #dcdcdc";
	j.style.margin = "0 2 0 2";
	
	return j
}

mycmap.prototype.createGuideButton=function(ax,ay,aalt){
	var j=document.createElement("span");
	mysetCursor(j,"default");

	j.setAttribute("id", "divbackbutton");
	j.unselectable="on";
	j.onselectstart=freturnfalse;
	
	return j
}

mycmap.prototype.setGuideText=function(c, btn, url)
{
	E = document.getElementById('divbackbutton');
	
	if(E != null){
		E.innerHTML = ""
		if(c != ""){
		E.appendChild(this.createGuideButton1(c, btn, url));
		}
	}
}

mycmap.prototype.createGuideButton1=function(c, btn, url)
{
	var a =	document.createElement("span");

	a.unselectable="on";
	a.onselectstart=freturnfalse;

	if(url == 0){
		a.innerHTML="<a href='javascript:parent.map.ecjsfLayerSet(\"myLayer2\",catlist);'><img style='position:relative;top:2px;left:-2px' src='"+mc.iconurl+ btn+"'><span style='position:relative;top:-4px;left:0px' id='txtbackbutton' >"+c+"</span></a>";
	}
	else if(url == 1){
		//a.innerHTML="<a href='javascript:parent.jsfsetck(\"gbase\",\"\",\"\",\"\",\"\",\"\");'><img style='position:relative;top:2px;left:-2px' src='"+mc.iconurl+ btn+"'><span style='position:relative;top:-4px;left:0px' id='txtbackbutton' >"+c+"</span></a>";
		// Modify by Paul Tam on 20080722 for debug
		a.innerHTML="<a href='javascript:parent.catlist.catclick(null,\"home\");javascript:parent.jsfsetck(\"gbase\",\"\",\"\",\"\",\"\",\"\");'><img style='position:relative;top:2px;left:-2px' src='"+mc.iconurl+ btn+"'><span style='position:relative;top:-4px;left:0px' id='txtbackbutton' >"+c+"</span></a>";
		//javascript:{catclick(this, "home");parent.jsfsetck("gbase","","","","","");};
	}
	a.style.background = "#FFFFFF";
	a.style.padding = "2 5 2 5";
	a.style.fontSize="10pt";
	a.style.fontFamily="Arial, sans serif";
	a.style.MozUserSelect="none";
	a.style.postion = "absolute";
	
	a.style.borderLeft = "outset 1px #dcdcdc";
	a.style.borderTop = "outset 1px #dcdcdc";
	a.style.borderBottom = "outset 1px #dcdcdc";
	a.style.borderRight = "outset 1px #dcdcdc";
	a.style.margin = "0 2 0 2";

	return a;
}

mycmap.prototype.createThemeName=function(content, width, height, ax,ay, z){
	var j=document.createElement("span");
	mysetCursor(j,"default");

	j.style.postion = "absolute";
	j.setAttribute("'id", "divthemename");
//	j.setAttribute("id", "txtthemename");
	
	j.unselectable="on";
	j.onselectstart=freturnfalse;
	j.style.fontSize="10pt";
	j.style.fontFamily="Arial, sans serif";
	j.style.MozUserSelect="none";
	j.style.padding = "11 5 2 2";
	j.style.background = "#FFFFFF";
	j.style.borderRight = "outset 1px #dcdcdc";
	j.style.borderTop = "outset 1px #dcdcdc";
	j.style.borderBottom = "outset 1px #dcdcdc";
	j.style.visibility = "hidden";
	//j.innerHTML = content;
	
	
	

	
	var n = document.createElement("span");
	n.setAttribute("id", "txtthemename");
	n.innerHTML = content;
	n.style.position = "relative";
	n.style.top = "-4px";
	
	j.appendChild(n);
	
	
	
	return j
}

mycmap.prototype.setThemeButton=function(lg){
	var j = document.getElementById("txtthemebutton");
	if(lg == "b5"){
		j.innerHTML="地圖面資訊";
		catlist = catlistb5;
	}
	else{
		j.innerHTML="Query";
	//	k.innerHTML="Back to Main Page";
		catlist = catlisten;
	}
}

mycmap.prototype.setThemeText=function(c)
{
	//document.getElementById("txtthemename").innerHTML = c;
}

mycmap.prototype.createCustomControlsPanel=function(){
	var j = document.createElement("span");
	mysetCursor(j,"default");

	j.setAttribute("id", "divcustomcontrol");
	j.unselectable="on";
	j.onselectstart=freturnfalse;
	j.style.fontSize="10pt";
	j.style.fontFamily="Arial, sans serif";
	j.style.MozUserSelect="none";
	//j.style.padding = "2 2 2 2"
	//j.style.margin = "0 2px 0 2px";

	
	return j;
}

mycmap.prototype.createLabelControls=function(idx, arr){
		var g = this;
		E = document.getElementById('divcustomcontrol');
		if(E != null){
			E.innerHTML = "";
			if(arr != null){
				E.appendChild(this.createLabelButton1("0",arr[0],idx));
				E.appendChild(this.createLabelButton1("1",arr[1], idx));
				E.appendChild(this.createLabelButton1("2",arr[2], idx));
			}
		}
};

mycmap.prototype.createLabelButton1=function(id, name, status)
{
	var a =	document.createElement("span");
	a.setAttribute("id", "labelcontrol" + id);
	a.setAttribute("idx", id);
	a.className = "labelcontrol";
	a.unselectable="on";
	a.onselectstart=freturnfalse;
	a.innerHTML = name;
	a.style.textAlign = "center";
	a.style.fontSize = "10pt";
	a.style.padding = "5 10 2 10";
	a.style.margin = "0 2 0 2";
	if(id == status){
		status = 0;
	}
	else{
		status = 1;
	}
	if(status == 0){
		mysetCursor(a,"default");
		a.style.background = "#FFFFFF";
		a.style.color = "#ff0000";
		//a.style.border = "outset 1px #dcdcdc";
		a.style.border = "solid 1px #ff0000";
		//a.style.fontWeight = "bold";
		//a.style.border = "inset 1px #dcdcdc";
	}
	else{
		mysetCursor(a,"pointer");
		a.style.background = "#FFFFFF";
		a.style.color = "#000000";		
		a.style.border = "outset 1px #dcdcdc";
		a.onclick = function(){_jsmapapp.map.LabelButtonClick("labelcontrol"+id, id);};
	}

	return a;
}

mycmap.prototype.LabelButtonClick=function(id, idx){
	parent.info.myinfo.changelabel(idx);
	//reset all label button
	var b = document.getElementsByTagName('SPAN');
	

	for(i=0;i<b.length;i++){
		if(b[i].className == 'labelcontrol'){

			mysetCursor(b[i],"pointer");
			b[i].style.background = "#FFFFFF";
			b[i].style.color = "#000000";		
			b[i].style.border = "outset 1px #dcdcdc";
			b[i].style.fontWeight = "normal";
			//b[i].onmouseover = function(){this.style.background="#FF0000";this.style.color="#FFFFFF"};
			//b[i].onmouseout = function(){this.style.background="#FFFFFF";this.style.color="#000000"};
			aid = b[i].getAttribute("id");
			aidx = b[i].getAttribute("idx");
			b[i].onclick = new Function("_jsmapapp.map.LabelButtonClick('" + aid + "', '"+aidx+"');");			

		}
	}
	
	var a = document.getElementById(id);
	mysetCursor(a,"default");
	a.style.background = "#FFFFFF";
	a.style.color = "#ff0000";
	//a.style.fontWeight = "bold";
	//a.style.border = "outset 1px #dcdcdc";
	a.style.border = "solid 1px #ff0000";
	
}




mycmap.prototype.createmaplabeliconsdiv=function(aimg,aimg2, asizex,asizey,ax,ay,aalt, ad){
	var j=document.createElement("div");
	j.style.position="absolute";
	mysetCursor(j,"default");
	j.unselectable="on";
	j.onselectstart=freturnfalse;
	if(ad == 1)
	{
		j.img1 = "<img src="+aimg2 + " border=0 alt=\""+aalt+"\">";
	}
	else{
		j.img1 = "<img src="+aimg + " border=0 alt=\""+aalt+"\" onmouseover=\"this.src='"+aimg2+"';\"  onmouseout=\"this.src='"+aimg+"';\">";
	}
	j.img2 = "<img src="+aimg2 + " border=0 alt=\""+aalt+"\">";
	j.innerHTML=j.img1;
	j.style.top = ay + "px";
	j.style.left = ax + "px";
	
	j.style.fontSize="11px";
	j.style.fontFamily="Arial, sans serif";
	j.style.MozUserSelect="none";
	
	return j
}

/*
mycmap.prototype.createZoom8Controls=function(E){
	var g = this;		

	if (mc.top.ck && mc.top.ck.toUpperCase() == 'GSHKP'){
		this.myzoombutton[23]=this.createmapiconsdiv(micons[23],micons2[23],17,17,this.viewSize.width-58,70,"Zoom In");
		mysetCursor(this.myzoombutton[23],"pointer");
		myaddevent(this.myzoombutton[23],"click",function(b){g.zoomIn();P(b)});
		E.appendChild(this.myzoombutton[23]);
	
		this.myzoombutton[24]=this.createmapiconsdiv(micons[24],micons2[24],17,17,this.viewSize.width-58,70+38,"Zoom Out");
		mysetCursor(this.myzoombutton[24],"pointer");
		myaddevent(this.myzoombutton[24],"click",function(b){g.zoomOut();P(b)});
		E.appendChild(this.myzoombutton[24]);
				
	}
	else{
		for(i=1;i<mc.zs.length;i++){
			//eb[i]=llayer.create(micons[i],17,17,20,70+20*(i-1),1,false);
			//if(mc.expressmode == 1){
			//Condition modified by Paul Tam on 20080827
			if(mc.expressmode == 1 || mc.expressmode == 3){
				
				this.myzoombutton[13]=this.createmapiconsdiv(micons[13],micons2[13],17,17,this.viewSize.width-51,70,"Zoom In");
				mysetCursor(this.myzoombutton[13],"pointer");
				myaddevent(this.myzoombutton[13],"click",function(b){g.zoomIn();P(b)});
				E.appendChild(this.myzoombutton[13]);
				
				this.myzoombutton[14]=this.createmapiconsdiv(micons[14],micons2[14],17,17,this.viewSize.width-51,70+18,"Zoom Out");
				mysetCursor(this.myzoombutton[14],"pointer");
				myaddevent(this.myzoombutton[14],"click",function(b){g.zoomOut();P(b)});
				E.appendChild(this.myzoombutton[14]);
					
			}
			else{
				//this.myzoombutton[i]=this.createmapiconsdiv(micons[i],micons2[i],17,17,this.viewSize.width-51,70+18*(i-1),"zoom "+i);
				this.myzoombutton[i]=this.createmapiconsdiv(micons[i],micons2[i],17,17,this.viewSize.width-51,70+18*(i-1),"zoom "+i);

				mysetCursor(this.myzoombutton[i],"pointer");
				
				if(i==1)myaddevent(this.myzoombutton[i],"click",function(b){g.zoomTo(0);P(b)});
				if(i==2)myaddevent(this.myzoombutton[i],"click",function(b){g.zoomTo(1);P(b)});
				if(i==3)myaddevent(this.myzoombutton[i],"click",function(b){g.zoomTo(2);P(b)});
				if(i==4)myaddevent(this.myzoombutton[i],"click",function(b){g.zoomTo(3);P(b)});
				if(i==5)myaddevent(this.myzoombutton[i],"click",function(b){g.zoomTo(4);P(b)});
				if(i==6)myaddevent(this.myzoombutton[i],"click",function(b){g.zoomTo(5);P(b)});
				if(i==7)myaddevent(this.myzoombutton[i],"click",function(b){g.zoomTo(6);P(b)});
				if(i==8)myaddevent(this.myzoombutton[i],"click",function(b){g.zoomTo(7);P(b)});
				if(i==9)myaddevent(this.myzoombutton[i],"click",function(b){g.zoomTo(8);P(b)});
				if(i==10)myaddevent(this.myzoombutton[i],"click",function(b){g.zoomTo(9);P(b)});
				if(i==11)myaddevent(this.myzoombutton[i],"click",function(b){g.zoomTo(10);P(b)});
				if(i==12)myaddevent(this.myzoombutton[i],"click",function(b){g.zoomTo(11);P(b)});

				//myzoombutton[i].title="zoom ?";

				E.appendChild(this.myzoombutton[i]);
			}
	
			// Condition add by Paul Tam on 20080922
			if (mc.expressmode != 3)
			{
				if(mc.lg == "b5"){
					//this.myzoombutton[15]=this.createmapiconsdiv(micons[15],micons2[15],17,17,this.viewSize.width-70,75+20*(13-1),"Map Mode");
					this.myzoombutton[15]=this.createmapiconsdiv(micons[15],micons2[15],17,17,this.viewSize.width-180-70,0,"Map Mode");
					mysetCursor(this.myzoombutton[15],"pointer");
					myaddevent(this.myzoombutton[15],"click",function(b){g.mapModeChange(0);P(b)});
					E.appendChild(this.myzoombutton[15]);
					
					//this.myzoombutton[16]=this.createmapiconsdiv(micons[16],micons2[16],17,17,this.viewSize.width-70,75+20*(14-1),"Aerial Mode");
					this.myzoombutton[16]=this.createmapiconsdiv(micons[16],micons2[16],17,17,this.viewSize.width-125-70,0,"Aerial Mode");
					mysetCursor(this.myzoombutton[16],"pointer");
					myaddevent(this.myzoombutton[16],"click",function(b){g.mapModeChange(1);P(b)});
					E.appendChild(this.myzoombutton[16]);

					this.myzoombutton[17]=this.createmapiconsdiv(micons[17],micons2[17],17,17,this.viewSize.width-70,75+20*(15-1),"Hybrid Mode");
					this.myzoombutton[17]=this.createmapiconsdiv(micons[17],micons2[17],17,17,this.viewSize.width-70-70,0,"Hybrid Mode");
					mysetCursor(this.myzoombutton[17],"pointer");			
					myaddevent(this.myzoombutton[17],"click",function(b){g.mapModeChange(2);P(b)});
					E.appendChild(this.myzoombutton[17]);
					
					//this.myzoombutton[18]=this.createmapiconsdiv(micons[21],micons2[21],17,17,this.viewSize.width-70,75+20*(15-1),"Print Map");
					this.myzoombutton[18]=this.createmapiconsdiv(micons[21],micons2[21],17,17,this.viewSize.width-70-70,20,"Print Map");
					mysetCursor(this.myzoombutton[18],"pointer");			
					myaddevent(this.myzoombutton[18],"click",function(b){parent.map.print();P(b)});
					E.appendChild(this.myzoombutton[18]);
				}
				else{
					//this.myzoombutton[15]=this.createmapiconsdiv(micons[18],micons2[18],17,17,this.viewSize.width-70,75+20*(13-1),"Map Mode");
					this.myzoombutton[15]=this.createmapiconsdiv(micons[18],micons2[18],17,17,this.viewSize.width-180-70,0,"Map Mode");
					mysetCursor(this.myzoombutton[15],"pointer");
					myaddevent(this.myzoombutton[15],"click",function(b){g.mapModeChange(0);P(b)});
					E.appendChild(this.myzoombutton[15]);
					
					//this.myzoombutton[16]=this.createmapiconsdiv(micons[19],micons2[19],17,17,this.viewSize.width-70,75+20*(14-1),"Aerial Mode");
					this.myzoombutton[16]=this.createmapiconsdiv(micons[19],micons2[19],17,17,this.viewSize.width-125-70,0,"Aerial Mode");
					mysetCursor(this.myzoombutton[16],"pointer");
					myaddevent(this.myzoombutton[16],"click",function(b){g.mapModeChange(1);P(b)});
					E.appendChild(this.myzoombutton[16]);

					this.myzoombutton[17]=this.createmapiconsdiv(micons[20],micons2[20],17,17,this.viewSize.width-70,75+20*(15-1),"Hybrid Mode");
					this.myzoombutton[17]=this.createmapiconsdiv(micons[20],micons2[20],17,17,this.viewSize.width-70-70,0,"Hybrid Mode");
					mysetCursor(this.myzoombutton[17],"pointer");			
					myaddevent(this.myzoombutton[17],"click",function(b){g.mapModeChange(2);P(b)});
					E.appendChild(this.myzoombutton[17]);
					
					//this.myzoombutton[18]=this.createmapiconsdiv(micons[22],micons2[22],17,17,this.viewSize.width-70,75+20*(15-1),"Print Map");
					this.myzoombutton[18]=this.createmapiconsdiv(micons[22],micons2[22],17,17,this.viewSize.width-70-70,20,"Print Map");
					mysetCursor(this.myzoombutton[18],"pointer");			
					myaddevent(this.myzoombutton[18],"click",function(b){parent.map.print();P(b)});
					E.appendChild(this.myzoombutton[18]);
				}
			
				this.scaleChanged();		
				this.mapModeChange(mc.mapmode);
			}
		
		//llogo=this.createmapiconsdiv(mc.iconurl+"centamaplogo.gif",mc.iconurl+"centamaplogo.gif",115,57,0,0,"");
		//E.appendChild(llogo);
		}
	}
};

*/
mycmap.prototype.createZoom8Controls=function(E){
	var g = this;		
		
	if (mc.top.ck && mc.top.ck.toUpperCase() == 'GSHKP'){
		this.myzoombutton[23]=this.createmapiconsdiv(micons[23],micons2[23],17,17,this.viewSize.width-58,70,"Zoom In");
		mysetCursor(this.myzoombutton[23],"pointer");
		myaddevent(this.myzoombutton[23],"click",function(b){g.zoomIn();P(b)});
		E.appendChild(this.myzoombutton[23]);
	
		this.myzoombutton[24]=this.createmapiconsdiv(micons[24],micons2[24],17,17,this.viewSize.width-58,70+38,"Zoom Out");
		mysetCursor(this.myzoombutton[24],"pointer");
		myaddevent(this.myzoombutton[24],"click",function(b){g.zoomOut();P(b)});
		E.appendChild(this.myzoombutton[24]);
	}
	else{
		for(i=1;i<mc.zs.length;i++){
			//Condition modified by Paul Tam on 20080827
			if(mc.expressmode == 1 || mc.expressmode == 3){
				this.myzoombutton[13]=this.createmapiconsdiv(micons[13],micons2[13],17,17,this.viewSize.width-51,70,"Zoom In");
				mysetCursor(this.myzoombutton[13],"pointer");
				myaddevent(this.myzoombutton[13],"click",function(b){g.zoomIn();P(b)});
				E.appendChild(this.myzoombutton[13]);
				
				this.myzoombutton[14]=this.createmapiconsdiv(micons[14],micons2[14],17,17,this.viewSize.width-51,70+18,"Zoom Out");
				mysetCursor(this.myzoombutton[14],"pointer");
				myaddevent(this.myzoombutton[14],"click",function(b){g.zoomOut();P(b)});
				E.appendChild(this.myzoombutton[14]);
			}
			else{
				this.myzoombutton[i]=this.createmapiconsdiv(micons[i],micons2[i],17,17,this.viewSize.width-51,70+18*(i-1),"zoom "+i);
				mysetCursor(this.myzoombutton[i],"pointer");
				
				if(i==1)myaddevent(this.myzoombutton[i],"click",function(b){g.zoomTo(0);P(b)});
				if(i==2)myaddevent(this.myzoombutton[i],"click",function(b){g.zoomTo(1);P(b)});
				if(i==3)myaddevent(this.myzoombutton[i],"click",function(b){g.zoomTo(2);P(b)});
				if(i==4)myaddevent(this.myzoombutton[i],"click",function(b){g.zoomTo(3);P(b)});
				if(i==5)myaddevent(this.myzoombutton[i],"click",function(b){g.zoomTo(4);P(b)});
				if(i==6)myaddevent(this.myzoombutton[i],"click",function(b){g.zoomTo(5);P(b)});
				if(i==7)myaddevent(this.myzoombutton[i],"click",function(b){g.zoomTo(6);P(b)});
				if(i==8)myaddevent(this.myzoombutton[i],"click",function(b){g.zoomTo(7);P(b)});
				if(i==9)myaddevent(this.myzoombutton[i],"click",function(b){g.zoomTo(8);P(b)});
				if(i==10)myaddevent(this.myzoombutton[i],"click",function(b){g.zoomTo(9);P(b)});
				if(i==11)myaddevent(this.myzoombutton[i],"click",function(b){g.zoomTo(10);P(b)});
				if(i==12)myaddevent(this.myzoombutton[i],"click",function(b){g.zoomTo(11);P(b)});

				E.appendChild(this.myzoombutton[i]);
			}
		}	

		// Condition add by Paul Tam on 20080922
		if (mc.expressmode != 3)
		{
			if(mc.lg == "b5"){
				//this.myzoombutton[15]=this.createmapiconsdiv(micons[15],micons2[15],17,17,this.viewSize.width-70,75+20*(13-1),"Map Mode");
				this.myzoombutton[15]=this.createmapiconsdiv(micons[15],micons2[15],17,17,this.viewSize.width-180-70,0,"Map Mode");
				mysetCursor(this.myzoombutton[15],"pointer");
				myaddevent(this.myzoombutton[15],"click",function(b){g.mapModeChange(0);P(b)});
				E.appendChild(this.myzoombutton[15]);
				
				//this.myzoombutton[16]=this.createmapiconsdiv(micons[16],micons2[16],17,17,this.viewSize.width-70,75+20*(14-1),"Aerial Mode");
				this.myzoombutton[16]=this.createmapiconsdiv(micons[16],micons2[16],17,17,this.viewSize.width-125-70,0,"Aerial Mode");
				mysetCursor(this.myzoombutton[16],"pointer");
				myaddevent(this.myzoombutton[16],"click",function(b){g.mapModeChange(1);P(b)});
				E.appendChild(this.myzoombutton[16]);

				this.myzoombutton[17]=this.createmapiconsdiv(micons[17],micons2[17],17,17,this.viewSize.width-70,75+20*(15-1),"Hybrid Mode");
				this.myzoombutton[17]=this.createmapiconsdiv(micons[17],micons2[17],17,17,this.viewSize.width-70-70,0,"Hybrid Mode");
				mysetCursor(this.myzoombutton[17],"pointer");			
				myaddevent(this.myzoombutton[17],"click",function(b){g.mapModeChange(2);P(b)});
				E.appendChild(this.myzoombutton[17]);
				
				//this.myzoombutton[18]=this.createmapiconsdiv(micons[21],micons2[21],17,17,this.viewSize.width-70,75+20*(15-1),"Print Map");
				this.myzoombutton[18]=this.createmapiconsdiv(micons[21],micons2[21],17,17,this.viewSize.width-70-70,20,"Print Map");
				mysetCursor(this.myzoombutton[18],"pointer");			
				myaddevent(this.myzoombutton[18],"click",function(b){parent.map.print();P(b)});
				E.appendChild(this.myzoombutton[18]);
			}
			else{
				//this.myzoombutton[15]=this.createmapiconsdiv(micons[18],micons2[18],17,17,this.viewSize.width-70,75+20*(13-1),"Map Mode");
				this.myzoombutton[15]=this.createmapiconsdiv(micons[18],micons2[18],17,17,this.viewSize.width-180-70,0,"Map Mode");
				mysetCursor(this.myzoombutton[15],"pointer");
				myaddevent(this.myzoombutton[15],"click",function(b){g.mapModeChange(0);P(b)});
				E.appendChild(this.myzoombutton[15]);
				
				//this.myzoombutton[16]=this.createmapiconsdiv(micons[19],micons2[19],17,17,this.viewSize.width-70,75+20*(14-1),"Aerial Mode");
				this.myzoombutton[16]=this.createmapiconsdiv(micons[19],micons2[19],17,17,this.viewSize.width-125-70,0,"Aerial Mode");
				mysetCursor(this.myzoombutton[16],"pointer");
				myaddevent(this.myzoombutton[16],"click",function(b){g.mapModeChange(1);P(b)});
				E.appendChild(this.myzoombutton[16]);

				this.myzoombutton[17]=this.createmapiconsdiv(micons[20],micons2[20],17,17,this.viewSize.width-70,75+20*(15-1),"Hybrid Mode");
				this.myzoombutton[17]=this.createmapiconsdiv(micons[20],micons2[20],17,17,this.viewSize.width-70-70,0,"Hybrid Mode");
				mysetCursor(this.myzoombutton[17],"pointer");			
				myaddevent(this.myzoombutton[17],"click",function(b){g.mapModeChange(2);P(b)});
				E.appendChild(this.myzoombutton[17]);
				
				//this.myzoombutton[18]=this.createmapiconsdiv(micons[22],micons2[22],17,17,this.viewSize.width-70,75+20*(15-1),"Print Map");
				this.myzoombutton[18]=this.createmapiconsdiv(micons[22],micons2[22],17,17,this.viewSize.width-70-70,20,"Print Map");
				mysetCursor(this.myzoombutton[18],"pointer");			
				myaddevent(this.myzoombutton[18],"click",function(b){parent.map.print();P(b)});
				E.appendChild(this.myzoombutton[18]);
			}
		
			this.scaleChanged();		
			this.mapModeChange(mc.mapmode);
		}
	}	

}
;

mycmap.prototype.createLabelDiv=function(E){
	var j=document.createElement("div");
	j.setAttribute("id", "labelcontroldiv");
	//j.style.top = 0;
	//j.style.left = 115;
//	j.width = 170;
//	j.height = 21;
//	j.style.background = '#000000';
	j.style.zIndex = 100;
	j.style.position = "relative";
	E.appendChild(j);
}
;






mycmap.prototype.labelcontrolPressed=function(idx){
	var g = this;
	var j=document.getElementById('labelcontroldiv');
	var arrinfo = j.getElementsByTagName('IMG')
	for(var i=0; i<arrinfo.length;i++){
		arrinfo[i].src = mlabeliconslist1[i];
		if(i==0){
			arrinfo[i].onmouseover = function(){_jsmapapp.map.labelused(this,0, 'over');};
			arrinfo[i].onmouseout = function(){_jsmapapp.map.labelused(this,0, 'out');};
		}
		else if(i==1){
			arrinfo[i].onmouseover = function(){_jsmapapp.map.labelused(this,1, 'over');};
			arrinfo[i].onmouseout = function(){_jsmapapp.map.labelused(this,1, 'out');};
		}
		else if(i==2){
			arrinfo[i].onmouseover = function(){_jsmapapp.map.labelused(this,2, 'over');};
			arrinfo[i].onmouseout = function(){_jsmapapp.map.labelused(this,2, 'out');};
		}
		//arrinfo[i].onmouseout = function(){"this.src = " + mlabeliconslist1[i] + ";"};
		
	}
	arrinfo[idx].onmouseover = null;
	arrinfo[idx].onmouseout = null;
	arrinfo[idx].src = mlabeliconslist2[idx];
}
;
mycmap.prototype.labelused=function(obj,idx,mouse){
	if(mouse == 'over'){
		obj.src = mlabeliconslist2[idx];
	}
	else{
		obj.src = mlabeliconslist1[idx];
	}
}
;

var miconspan = new Array("","pan1.gif","pan2.gif","pan3.gif","pan4.gif","pan5.gif","pan6.gif","pan7.gif","pan8.gif","pan9.gif");
var miconspan2 = new Array("","pan1a.gif","pan2a.gif","pan3a.gif","pan4a.gif","pan5a.gif","pan6a.gif","pan7a.gif","pan8a.gif","pan9a.gif");
var miconspant = new Array("","","go south","","go west","recenter","go east","","go north","");
//if(mc.expressmode == 1)
//Condition Modified by Paul Tam on 20080827
if(mc.expressmode == 1 || mc.expressmode == 3)
{
	var miconspantx = new Array(0,0,18,36,9,18,27,0,18,36);
}
else{
	var miconspantx = new Array(0,0,18,36,0,18,36,0,18,36);
}
var miconspanty = new Array(0,36,36,36,18,18,18,0,0,0);
var miconspanactionx = new Array(0,1,0,-1,1,0,-1,1,0,-1)
var miconspanactiony = new Array(0,-1,-1,-1,0,0,0,1,1,1)
mycmap.prototype.createPanningControls=function(E){
	var g=this;
	
	/*
	var qb=llayer.create(mc.iconurl+"xxxxxx.png",59,64,0,0,0,false);
	E.appendChild(qb);
	*/
	i = 8;
	for(i=1;i<10;i++){
		if(miconspan[i] != ""){
			//limg = mc.iconurl+miconspan[i];
			//var la=llayer.create(limg,17,17,miconspantx[i],miconspanty[i],1,false);
		
			//if(mc.expressmode == 1)
			//Condition modified by Paul Tam on 20080827
			if(mc.expressmode == 1 || mc.expressmode == 3)
			{
				if(i%2 == 0){
					this.mypanbutton[i]=this.createmapiconsdiv( mc.iconurl+miconspan[i], mc.iconurl+miconspan2[i],17,17,this.viewSize.width-70 + miconspantx[i],miconspanty[i],miconspant[i]);
					mysetCursor(this.mypanbutton[i],"pointer");
					if(i==1)myaddevent(this.mypanbutton[i],"click",function(b){g.panButtonPressed(1,b)});
					if(i==2)myaddevent(this.mypanbutton[i],"click",function(b){g.panButtonPressed(2,b)});
					if(i==3)myaddevent(this.mypanbutton[i],"click",function(b){g.panButtonPressed(3,b)});
					if(i==4)myaddevent(this.mypanbutton[i],"click",function(b){g.panButtonPressed(4,b)});
					if(i==5)myaddevent(this.mypanbutton[i],"click",function(b){g.panButtonPressed(5,b)});
					if(i==6)myaddevent(this.mypanbutton[i],"click",function(b){g.panButtonPressed(6,b)});
					if(i==7)myaddevent(this.mypanbutton[i],"click",function(b){g.panButtonPressed(7,b)});
					if(i==8)myaddevent(this.mypanbutton[i],"click",function(b){g.panButtonPressed(8,b)});
					if(i==9)myaddevent(this.mypanbutton[i],"click",function(b){g.panButtonPressed(9,b)});
					//this.mypanbutton[i].title=miconspant[i];
					E.appendChild(this.mypanbutton[i]);
				}
			}
			else{
					this.mypanbutton[i]=this.createmapiconsdiv( mc.iconurl+miconspan[i], mc.iconurl+miconspan2[i],17,17,this.viewSize.width-70 + miconspantx[i],miconspanty[i],miconspant[i]);
					//this.mypanbutton[i]=this.createmapiconsdiv( mc.iconurl+miconspan[i], mc.iconurl+miconspan2[i],17,17,this.viewSize.width-70 + miconspantx[i],miconspanty[i]+20,miconspant[i]);
					mysetCursor(this.mypanbutton[i],"pointer");
					if(i==1)myaddevent(this.mypanbutton[i],"click",function(b){g.panButtonPressed(1,b)});
					if(i==2)myaddevent(this.mypanbutton[i],"click",function(b){g.panButtonPressed(2,b)});
					if(i==3)myaddevent(this.mypanbutton[i],"click",function(b){g.panButtonPressed(3,b)});
					if(i==4)myaddevent(this.mypanbutton[i],"click",function(b){g.panButtonPressed(4,b)});
					if(i==5)myaddevent(this.mypanbutton[i],"click",function(b){g.panButtonPressed(5,b)});
					if(i==6)myaddevent(this.mypanbutton[i],"click",function(b){g.panButtonPressed(6,b)});
					if(i==7)myaddevent(this.mypanbutton[i],"click",function(b){g.panButtonPressed(7,b)});
					if(i==8)myaddevent(this.mypanbutton[i],"click",function(b){g.panButtonPressed(8,b)});
					if(i==9)myaddevent(this.mypanbutton[i],"click",function(b){g.panButtonPressed(9,b)});
					//this.mypanbutton[i].title=miconspant[i];
					E.appendChild(this.mypanbutton[i]);
			}
		}
	}
}

;mycmap.prototype.panButtonPressed=function(apanid,ab){
	
	if(apanid==5){
		this.ecrecenter(this.lastLatLng);
	}else{
		lpanx = miconspanactionx[apanid];
		lpany = miconspanactiony[apanid];
		
		if( mc.cango(this.loadinfourlcnt) ){
			this.pan(lpanx * Math.floor(this.viewSize.width*0.5), lpany * Math.floor(this.viewSize.height*0.5));
		}
	}
	;P(ab);
}



;mycmap.prototype.showCopyright=function(){
	var Ee=this.createCopyright("");
	Ee.style.left="3px";
	Ee.style.bottom="3px";
	this.container.appendChild(Ee);
	
	
	var ce=this.createCopyright("");
	
		
	// Modified by Paul Tam on 20081013	
	if(mc.expressmode ==3)
	{
			ce=this.createCopyright("<table cellpadding=0 cellspacing=0 bgcolor=#ffffff style='border:1px #a0a0a0 solid'><tr><td><font style=font-size:7px> (c) Survey and Mapping Office, Lands Department, Copyright reserved - reproduction by permission only.</font></td></tr></table>");
	}	
	else
	{
		//if (mc.lg == 'b5')
		//{
		//	ce=this.createCopyright("<table cellpadding=1 cellspacing=0 bgcolor=#ffffff style='border:1px #a0a0a0 solid'><tr><td><font style=font-size:14px> (c) 地圖版權屬香港特區政府，經地政總署署長准許複印。</font></td></tr></table>");
		//}
		//else
		//{
			ce=this.createCopyright("<table cellpadding=1 cellspacing=0 bgcolor=#ffffff style='border:1px #a0a0a0 solid'><tr><td><font style=font-size:10px> (c) The Government of the Hong Kong SAR. Map reproduced with permission of the Director of Lands.</font></td></tr></table>");
		//}
	}
			
	//////
	
	ce.style.right="3px";
	ce.style.bottom="3px";
	this.container.appendChild(ce);
}
;mycmap.prototype.createCopyright=function(aa){
	var j=document.createElement("div");
	j.style.position="absolute";
	j.style.zIndex="100";
	mysetCursor(j,"default");
	//mysetCursor(this.src,"http:\/\/localhost\/gm\/img\/hand4.cur");
	j.unselectable="on";
	j.onselectstart=freturnfalse;
	j.innerHTML=aa;
	j.style.fontSize="11px";
	j.style.fontFamily="Arial, sans serif";
	j.style.MozUserSelect="none";return j}
;
//c.dragobject
function mydrag(M,S,top,Y){
	this.src=M;
	this.container=Y;
	this.ondragstart=null;
	this.ondrag=null;
	this.ondragend=null;
	this.onmove=null;
	this.onclick=null;
	this.disabled=false;
	this.dragPoint=new myqpoint(0,0);
	this.clickStartPos=new myqpoint(0,0);
	this.src.style.position="absolute";
	this.moveTo(S,top);
	this.mouseDownHandler=this.eventHandler("onMouseDown");
	this.mouseMoveHandler=this.eventHandler("onMouseMove");
	this.mouseUpHandler=this.eventHandler("onMouseUp");
	if(mybrowser.mtype==2){
		myaddevent(window,"mouseout",this.eventHandler("onWindowMouseOut"))
	}
	this.eventSrc=this.src.setCapture?this.src:window;
	myaddevent(this.src,"mousedown",this.mouseDownHandler)

}
mydrag.prototype.moveTo=function(S,top){
	if(this.left!=S||this.top!=top){
		this.left=S;
		this.top=top;
		this.src.style.left=this.left+"px";
		this.src.style.top=this.top+"px";
		if(this.onmove){this.onmove()}
	}
}
;


mydrag.prototype.onMouseDown=function(b){

	if(b.cancelDrag){
		return
	}
	var fj=b.button==0||b.button==1;
	if(!mc.cango(0)){
		P(b);
		return false
	}
	if(this.disabled||!fj){
		P(b);
		return false
	}

	this.dragPoint.x=b.screenX;
	this.dragPoint.y=b.screenY;
	//alert(this.eventSrc.name);
	myaddevent(this.eventSrc,"mousemove",this.mouseMoveHandler);
	myaddevent(this.eventSrc,"mouseup",this.mouseUpHandler);
	if(this.src.setCapture){
		this.src.setCapture()
	}
	this.clickStartTime=(new Date()).getTime();
	this.clickStartPos.x=b.screenX;
	this.clickStartPos.y=b.screenY;
	if(this.ondragstart){
		this.ondragstart(b)
	}
	
	this.originalCursor=this.src.style.cursor;
	mysetCursor(this.src,"http:\/\/hk.centamap.com\/gm\/img\/hand_drag.cur");
	//mysetCursor(this.src,"http:\/\/www.centamap.com\/gm\/img\/hand_drag.cur"); //Louis modified on 2009-12-09
	P(b);
	
}
;



;mydrag.prototype.onMouseMove=function(b){
	if( mc.allowdrag!=1){
		return;
	}
	if(mybrowser.mos==1){
		if(b==null){return}
		if(this.dragDisabled){
			this.savedMove=new Object();
			this.savedMove.screenX=b.screenX;
			this.savedMove.screenY=b.screenY;
			return
		}
		this.setTimeout("this.dragDisabled = false; this.onMouseMove(this.savedMove)",30);
		this.dragDisabled=true;
		this.savedMove=null
	}
	var Ze=1;

	//if(mybrowser.mtype==3&&mybrowser.mversion==1){Ze=-1}
	var x=this.left+(b.screenX-this.dragPoint.x);
	var o=this.top+(b.screenY-this.dragPoint.y)*Ze;
	var Ga=0;
	var Ka=0;
	if(this.container){
		var hd=x;
		if(x<this.container.minX){
			hd=this.container.minX
		}else{
			var Hd=this.container.maxX-this.src.offsetWidth;
			if(x>Hd){hd=Hd}
		}
		Ga=hd-x;
		x=hd;
		var vd=o;
		if(o<this.container.minY){vd=this.container.minY}
		else{
			var md=this.container.maxY-this.src.offsetHeight;
			if(o>md)vd=md
		}
		Ka=vd-o;
		o=vd
	}
	
	this.moveTo(x,o);
	this.dragPoint.x=b.screenX+Ga;
	this.dragPoint.y=b.screenY+Ka;
	if(this.ondrag){
		this.ondrag(b)
	}
	
	
};


mydrag.prototype.onMouseUp=function(b){
	mydelevent(this.eventSrc,"mousemove",this.mouseMoveHandler);
	mydelevent(this.eventSrc,"mouseup",this.mouseUpHandler);
	mysetCursor(this.src,this.originalCursor);
	if(document.releaseCapture){
		document.releaseCapture()
	}
	
	if(this.ondragend){
		this.ondragend(b);
	}
	if(this.onclick){
		var mi=(new Date()).getTime();
		if(mi-this.clickStartTime<=500&&(Math.abs(this.clickStartPos.x-b.screenX)<=2&&Math.abs(this.clickStartPos.y-b.screenY)<=2)){
				this.onclick(b)
		}else{
			this.ondrag();
		}
	}
}
;mydrag.prototype.onWindowMouseOut=function(b){if(!b.relatedTarget){this.onMouseUp(b)}}
;mydrag.prototype.disable=function(){this.disabled=true}
;mydrag.prototype.enable=function(){this.disabled=false}
;




function myGrid(avw, avh, axcnt,aycnt,apath,azstep){
	this.gridArow = aycnt;
	this.gridAcol = axcnt;
	this.zstep = azstep;
	
	this.zstepflag = 0;
	if(azstep==null){

			this.zstep = -3;
	}
	this.vw = avw;
	this.vh = avh;
	this.gridA = new Array(this.gridArow);
	for(i=0; i < this.gridArow; i++){
		this.gridA[i] = new Array(this.gridAcol);
	}
	for(i=0;i<this.gridArow;i++)
	{
		for(j=0;j < this.gridAcol;j++)
		{
			this.gridA[i][j] = new myGridAI("","","","");
		}
	}
	this.gridMOx = -1;
	this.gridMOy = -1;
	this.gridMOcontent = "";
	this.gridMOobj = null;
	this.path = apath;
	this.myimg = this.path + "img/";
}
function ecjsGridInit(axcnt,aycnt,apath,azstep){
	_jsmapapp.map.mygrid = null;
	avw =_jsmapapp.map.viewSize.width;
	avh =_jsmapapp.map.viewSize.height;
	axcnt = parseInt(avw/70);
	aycnt = parseInt(avh/50);
	_jsmapapp.map.mygrid = new myGrid(avw, avh, axcnt,aycnt,apath,azstep);
}
function ecjsGridAdd(agridx, agridy, amsg, amsg1a, amsg1b,amsg1c){
	_jsmapapp.map.mygrid.addgrid(agridx, agridy, amsg, amsg1a, amsg1b,amsg1c);
}
function ecjsGridDraw(){
	_jsmapapp.map.mygrid.loading()
}

myGrid.prototype.addgrid=function(agridx, agridy, amsg, amsg1a, amsg1b,amsg1c){
	this.gridA[agridy][agridx].msg = amsg;
	this.gridA[agridy][agridx].msg1a = amsg1a;
	this.gridA[agridy][agridx].msg1b = amsg1b;
	this.gridA[agridy][agridx].msg1c = amsg1c;
}

myGrid.prototype.loading=function(){
	ecjsfLayerClearall();
				
	tdwidth = parseInt((this.vw)/this.gridAcol)-2;
	tdheight = parseInt((this.vh)/this.gridArow)-2;

	var lmouse = "";
	var rtn = "";
	//rtn += "<div>";
	
	rtn += "<table style=\"\" cellpadding=0 cellspacing=0 border=0 width="+this.vw+"px height="+this.vh+"px>";
	for(i=0;i<this.gridArow;i++)
	{
		rtn += "<tr>";
		for(j=0;j<this.gridAcol;j++)
		{
			if(this.gridA[i][j].msg != "")
			{
				//lmouse = " onmouseover=\""+this.myjsname+"gridMO("+i+","+j+",this)\" onmousedown=\"event.cancelBubble=true;ecjsOnClick2(event.x, event.y, -3);\" ";
				lmouse = " onmouseover=\"_jsmapapp.map.mygrid.gridMO("+i+","+j+",this)\" onmousedown=\"_jsmapapp.map.mygrid.zstepflag=1;\" ";
				//lmouse = " onmouseover=\"_jsmapapp.map.mygrid.gridMO("+i+","+j+",this)\" ";
								
				if(mybrowser.mtype==20){
					rtn += "<td align=\"right\" valign=\"bottom\" style=\"text-decoration:underline;font-weight:bold;font-size:11px;opacity:"+parseInt(this.gridA[i][j].msg1a)/100+";color:#FFFFFF;background-color:#800000;border:1px solid #a0a0a0;\"  width="+tdwidth+"px height="+tdheight+"px " + lmouse+ ">"+this.gridA[i][j].msg+"紀錄</td>";
				}
				else{
					//rtn += "<td align=\"right\" valign=\"bottom\" style=\"text-decoration:underline;font-weight:bold;font-size:11px;filter:alpha(opacity="+this.gridA[i][j].msg1a+");color:#FFFFFF;background-color:#800000;border:1px solid #a0a0a0;\"  width="+tdwidth+" height="+tdheight+" " + lmouse+ ">"+this.gridA[i][j].msg+"</td>";
					
					rtn += "<td title=\"Zoom In\" style=\"text-decoration:underline;color:#0000AA;font-weight:bold;font-size:16px;filter:alpha(opacity="+this.gridA[i][j].msg1a+");color:#FFFFFF;background-color:#A00000;border:1px solid #a0a0a0;\" align=\"center\" valign=\"middle\"  width="+tdwidth+" height="+tdheight+" " + lmouse+ ">"+this.gridA[i][j].msg+"紀錄</td>";
					//rtn += "<td><table style=\"filter:alpha(opacity="+this.gridA[i][j].msg1a+");\" cellpadding=\"0\" cellspacing=\"0\" width=\"65px\" height=\"100%\"><tr><td height=\"10%\">&nbsp;</td></tr><tr><td style=\"border:5px #FF0000 solid;background-color:#FFFFFF;\" align=\"center\" valign=\"middle\"  width=\"65px\" height=\"65px\">"+this.gridA[i][j].msg+"</td></tr><tr><td align=\"center\" ><img src=\""+mc.iconurl+"distpt.gif\"></td></tr></table></td>";
				}
			}
			else{
				lmouse = " onmouseover=\"_jsmapapp.map.mygrid.gridMOUT();\" ";
				rtn += "<td width="+tdwidth+"px height="+tdheight+"px "+lmouse+"></td>";
			}
		}
		rtn += "</tr>";
	}
	rtn += "</table>";
	//rtn += "</div>";
	
	
	ecjsfLayerSet('myLayer1',rtn);
	
	
}

function myGridAI(amsg, amsg1a, amsg1b,amsg1c){
	this.msg = amsg;
	this.msg1a = amsg1a;
	this.msg1b = amsg1b;
	this.msg1c = amsg1c;
}


myGrid.prototype.gridMO=function(ax, ay , aobj)
{
	
	aobj.onmouseover = "";
	if(this.gridMOobj != null){
		// clear the MO object
		//myaddevent(this.gridMOobj, "mouseover", Function("_jsmapapp.map.mygrid.gridMO("+this.gridMOx + "," + this.gridMOy+",this);P(b);"));
		this.gridMOobj.onmouseover = new Function("_jsmapapp.map.mygrid.gridMO("+this.gridMOx + "," + this.gridMOy+",this);");
		this.gridMOobj.innerHTML = this.gridA[this.gridMOx][this.gridMOy].msg + "紀錄";
		this.gridMOobj.style.border = '1px solid #a0a0a0';
		//this.gridMOobj.style.background = "#008000";
		this.gridMOobj.style.background = "#A00000";
		this.gridMOobj.style.color = "#FFFFFF";
		if(mybrowser.mtype==20){
			this.gridMOobj.style.opacity = 1*(this.gridA[this.gridMOx][this.gridMOy].msg1a)/100;
		}
		else{
			this.gridMOobj.filters.alpha.opacity = this.gridA[this.gridMOx][this.gridMOy].msg1a;
		}
		this.gridMOobj = null;
		this.gridMOx	= -1;
		this.gridMOy = -1;
	}
	
	this.gridMOobj = aobj;			
	this.gridMOx	= ax;
	this.gridMOy = ay;
	var lrtn = "";
	lrtn = this.gridA[ax][ay].msg + "紀錄" ;
	aobj.innerHTML = lrtn;
	/*
	aobj.style.background = '#d85977';
	aobj.style.border = '1px solid #FF0000';
	aobj.filters.alpha.opacity = 90;
	*/
	//aobj.style.background = '#6699CC';
	aobj.style.background = '#FF0000';
	aobj.style.border = '1px solid #FFFFFF';
	//aobj.style.color = "#d85977";
	aobj.style.color = "#FFFFFF";
	aobj.style.cursor = "hand";
	
	
	if(mybrowser.mtype==20){
		aobj.style.opacity = 0.9;
	}
	else{
		aobj.filters.alpha.opacity = 90;
	}

}

myGrid.prototype.gridMOUT=function()
{
	if(this.gridMOobj != null){
		// clear the MO object
		//myaddevent(this.gridMOobj, "mouseover", Function("_jsmapapp.map.mygrid.gridMO("+this.gridMOx + "," + this.gridMOy+",this);P(b);"));
		this.gridMOobj.onmouseover = new Function( "_jsmapapp.map.mygrid.gridMO("+this.gridMOx + "," + this.gridMOy+",this);");
		this.gridMOobj.innerHTML = this.gridA[this.gridMOx][this.gridMOy].msg + "紀錄" ;
		this.gridMOobj.style.border = '1px solid #a0a0a0';
		//this.gridMOobj.style.background = "#008000";
		this.gridMOobj.style.background = "#A00000";
		this.gridMOobj.style.color = "#FFFFFF";
		if(mybrowser.mtype==20){
			this.gridMOobj.style.opacity = 1*(this.gridA[this.gridMOx][this.gridMOy].msg1a)/100;
		}
		else{
			this.gridMOobj.filters.alpha.opacity = this.gridA[this.gridMOx][this.gridMOy].msg1a;
		}
			
		this.gridMOobj = null;
		this.gridMOx	= -1;
		this.gridMOy = -1;
	}
	
}
;

var qd = new myqpoint(836195,821952);

var Ca=new Array();
//	public double[] scale = {0,0.22,0.53,0.977,1.42,2.556,7.008,21.435,103.053};
var ta;
for(ta=0;ta<mc.zs.length;ta++){
//	Ca.push(new myqpoint(mc.zs[ta]*0.77162458338772,mc.zs[ta]))
	Ca.push(new myqpoint( mc.zs[ta], mc.zs[ta]))
}
//var ci=mc.iconurl+"transparent.gif";
function myimgbb(aimg){
	this.tileSize=128;
	this.tileSize=240;
	this.backgroundColor="#f2efe9";
	this.emptyTileURL=mc.iconurl+"transparent.gif";
	this.numZoomLevels=Ca.length;
	if(aimg){
		this.baseURL=aimg
	}else{
		this.baseURL="http://mt.xxxx.com/mt?";
		//this.baseURL="http://www.xxxxx.com?";
		if(window._tv&&window._tv.length>0){
			this.baseURL+="v="+encodeURIComponent(window._tv)+"&"
		}
	}
	//alert(this.baseURL);
	
}






var myimged=new myimgbb();
myimgbb.prototype.getBitmapCoordinate=function(mb,zb,R,e){
	if(!e)e=new myqpoint(0,0);
	var x=zb-qd.x;
	var o=qd.y-mb;
	e.x=Math.floor(x / Ca[R].x);
	e.y=Math.floor(o / Ca[R].y);
	//e.x += 260;
	//e.y += 260;
	//e.x=Math.floor(x);
	//e.y=Math.floor(o);
	return e
}
;
//spec.getlatlng
myimgbb.prototype.getLatLng=function(x,o,R,e){
	if(!e)e=new myqpoint(0,0);
	//x = x + 260;
	//o = o + 260;
	//alert(x + "," + o + ","+R+"," + Ca[R] + "," + qd.x);
	//alert(R);
	x= x * Ca[R].x ;
	o= o * Ca[R].y;
	e.x=x+qd.x;
	e.y=qd.y-o;
	return e
}
myimgbb.prototype.getTileURL=function(x,o,R){
	
	if(R>=0 && R<= mc.zs.length ){
		ls = mc.gmtileurl+"maptile/map.gif";
		lsr = "00" + (1.0 + R) ; lsr = lsr.substring(lsr.length-2,lsr.length)
		lsx = "00" + (5000.0 + x ) ; lsx = lsx.substring(lsx.length-4,lsx.length)
		lsy = "00" + (5000.0 + o)  ; lsy = lsy.substring(lsy.length-4,lsy.length)
		if(mc.mapmode == 0){	
			//ls = mc.gmtileurl+"maptile.aspx?ipcheck="+mc.checker+"&z="+R+"&x="+x+"&y="+o+"&iscensus="+mc.iscensus;
			ls = mc.gmtileurl+"maptile.aspx?z="+R+"&x="+x+"&y="+o+"&iscensus="+mc.iscensus;
			//ls = mc.gmtileurl+"maptile.aspx?z="+R+"&x="+x+"&y="+o;
			//alert(ls);
		}
		else if(mc.mapmode == 1){
			//ls = mc.gmtileurl+"aerialmaptile.aspx?ipcheck="+mc.checker+"&z="+R+"&x="+x+"&y="+o+"&iscensus="+mc.iscensus;
			ls = mc.gmtileurl+"aerialmaptile.aspx?z="+R+"&x="+x+"&y="+o+"&iscensus="+mc.iscensus;
		}
		else if(mc.mapmode == 2){
			//ls = mc.gmtileurl+"hybridmaptile.aspx?ipcheck="+mc.checker+"&z="+R+"&x="+x+"&y="+o+"&iscensus="+mc.iscensus;
			ls = mc.gmtileurl+"hybridmaptile.aspx?z="+R+"&x="+x+"&y="+o+"&iscensus="+mc.iscensus;
		}
		return ls;
	}else{
		alert("bb.prototype.gettileurl");
		return this.baseURL+"x="+x+"&y="+o+"&zoom="+R
	}

}



//Mapsapplication, _m
function mymapapp(ri,Yh){
	//map, panel, metapanel, linktopage, feedback, toggle
	this.map=null;
	this.mapContainer=ri;
	this.panel=Yh;
	myaddevent(window,"resize",this.eventHandler("resizeMapView"));
	if(mybrowser.mtype==4){
		document.body.style.overflow="hidden";
		this.panel.style.overflow="auto"
	}

	this.resizeMapView()

}
mymapapp.prototype.loadMap=function(){
	this.map=new mycmap(this.mapContainer,null,null,null,false,false,null);
	this.createMapControl();
	this.map.addStateListener(this);
	
};

function ecjsVersion(a){
	mc.lg = a;
	_jsmapapp.map.mapModeChange(-1);
};



mymapapp.prototype.loadMapx=function(We){
	var ia=null;
	if(We)ia=tb[We];
	if(!ia)ia=tb[0];
	this.map=new mycmap(this.mapContainer,ia,null,null,false,false,tb);
	//this.map.registerKeyHandlers(window.document);
	this.createMapControl();
	this.map.addStateListener(this);
	//if(tb.length>1){
	//	this.map.createSpecToggleLinks(this.specToggleArea)
	//}
};
mymapapp.prototype.createMapControl=function(){
	var Lc=this.map.createMapControl();
	Lc.style.position="absolute";
	Lc.style.left="8px";
	Lc.style.top="8px";
	//ad(Lc,"noprint");
	this.mapContainer.appendChild(Lc)
	
};
/*
mymapapp.prototype.onMapStateChanged=function(){
	try{if(this.vpageDoc){
		var G=this.map.getCenterLatLng();this.vpageDoc.getElementById(Ke).value=G.y;this.vpageDoc.getElementById(Le).value=G.x;this.vpageDoc.getElementById("zoom").value=this.map.zoomLevel}var ha=this.getPageURL();this.permalink.href=ha;this.feedbackLink.href="http://www.xxxxxx.com/support/maps/bin/request.py?url="+encodeURIComponent(ha)+"&ua="+encodeURIComponent(navigator.userAgent)}catch(b){}};
		*/
mymapapp.prototype.resizeMapView=function(){
		var Ni=this.getWindowSize();
		var Vf=myaddoffset(this.mapContainer);
		var fg=Ni.height-Vf.y-10;
		var fgx=Ni.width-Vf.x-10;
		var Pi=myaddoffset(this.panel);
		var oi=fg-(Pi.y-Vf.y);
		this.mapContainer.style.height=mysetpx(fg);
		if(document.body.style.overflow=="hidden"){
			this.panel.style.height=mysetpx(oi);
			this.panel.scrollTop=0
		}

		if(!top.head){
			this.mapContainer.style.width=mysetpx(fgx);
			this.mapContainer.style.width=mc.w + 'px';
			this.mapContainer.style.height=mc.h + 'px';
			if(document.body.style.overflow=="hidden"){
				this.panel.style.width=mysetpx(oi);
				this.panel.scrollTop=0
			}
		}
		
		// Modified by Paul Tam on 20081016 for dynamic view size
		if(mc.expressmode ==1){
			//this.mapContainer.style.width='882px'; // fixed width
			//this.mapContainer.style.height='200px'; // fixed height
			this.mapContainer.style.width=mc.w + 'px'; // dynamic width 
			this.mapContainer.style.height=mc.h + 'px'; // dynamic height
		}
		if(mc.expressmode ==2){
			//this.mapContainer.style.width='560px'; // fixed width
			//this.mapContainer.style.height='400px'; // fixed height
			this.mapContainer.style.width=mc.w + 'px'; // dynamic width
			this.mapContainer.style.height=mc.h + 'px'; // dynamic height
		}
		// Add by Paul Tam on 20080827
		if(mc.expressmode ==3){
			//this.mapContainer.style.width='300px'; // fixed width
			//this.mapContainer.style.height='300px'; // fixed height
			this.mapContainer.style.width=mc.w + 'px'; // dynamic width
			this.mapContainer.style.height=mc.h + 'px'; // dynamic height
		}
		////
	
	if(this.map){
		this.map.onResize()
	}
};

mymapapp.prototype.getWindowSize=function(e){
	if(!e)e=new mycasize(0,0);
	if(!mc.top.head){
		e.width=640;
		e.height=480;
		return e;
	}
	if(window.self&&self.innerWidth){
		e.width=self.innerWidth;
		e.height=self.innerHeight;
		return e
	}
	if(document.documentElement&&document.documentElement.clientHeight){
		e.width=document.documentElement.clientWidth;
		e.height=document.documentElement.clientHeight;
		return e
	}
	e.width=document.body.clientWidth;
	e.height=document.body.clientHeight;

	return e
};



var _Map=mycmap;
var _MapsApplication=mymapapp;



function _createMap() {
	_jsmapapp = new _MapsApplication(
		document.getElementById('map'),
		document.getElementById('panel')
	);
	_jsmapapp.loadMap();
	_jsmapapp.map.onmousedown = function() {
	};
	_jsmapapp.map.centerAtLatLng(new myqpoint(mc.x,mc.y));
	_jsmapapp.map.onStateChanged(); //add2
}
function ecjsfLayerSet(alyr, ahtml){
	if(alyr =='myLayer0'){
		_jsmapapp.map.mylayer0.innerHTML = ahtml;
	}
	if(alyr =='myLayer1'){
		_jsmapapp.map.mylayer1.innerHTML = ahtml;
	}
	if(alyr =='myLayer2'){
		_jsmapapp.map.mylayer2.innerHTML = ahtml;
	}
	if(alyr =='myLayer3'){
		_jsmapapp.map.mylayer3.innerHTML = ahtml;
	}
}
function ecjsfLayerMOut(toinfo,tomap){
	_jsmapapp.map.mylayer2.innerHTML = '';
	_jsmapapp.map.mylayer1.innerHTML = '';
	if(toinfo==1)if(mc.top.head)parent.info.myiw.close();
}

function ecjsfmapiscensus(mode){
	_jsmapapp.map.mapiscensus(mode);
}

function jbcreateajax(){
	var A=null;
	try{
		A=new ActiveXObject("Msxml2.XMLHTTP")
	}catch(e){
		try{
			A=new ActiveXObject("Microsoft.XMLHTTP")
		}
		catch(oc){
			A=null
		}
	}
	if(!A && typeof XMLHttpRequest!="undefined"){
		A=new XMLHttpRequest()
	}
	return A
}


function ecChecker(){ 
	if(majax && majax.readyState!=0){
		majax.abort()
	}
	majax=jbcreateajax(); 
	if(majax){ 
		ls1 = mc.gmurl+"maptilechecker.aspx?"+Math.random() ; 
		majax.open("GET",ls1,true); 
		majax.onreadystatechange=function(){ 
			if(majax.readyState==4 && majax.responseText){ 
				if(majax.responseText.charAt(0)==">"	){ majaxcnt-- }
				else{ eval(majax.responseText);}
			}
		}
	}
	 majax.send(null); 
} 


	  
function ecjsOnClick3(x,y,z){
	_jsmapapp.map.onClick3(new myqpoint(x,y),z);
}

function ecjsCenterAtLatLng(x,y,z){
//	this.centerAtLatLng(kd);
	if(z!=null){
		_jsmapapp.map.zoomLevel = z - 1;
	}
	_jsmapapp.map.centerAtLatLng(new myqpoint(x,y));

	_jsmapapp.map.scaleChanged();
	_jsmapapp.map.onStateChanged(); //add2
}



function ecjspan2(x,y){
	
	e = new myqpoint();
	_jsmapapp.map.getCenterLatLng(e);

	var tx = e.x - x;
	var ty = y - e.y;
	z = _jsmapapp.map.zoomLevel;
	tx =(1.0*tx)/mc.zs[z];
	ty = (1.0*ty)/mc.zs[z];
	
	if(tx < 200 && ty < 200 && tx>-200 && ty > -200){
		_jsmapapp.map.pan(tx,ty);
		_jsmapapp.map.onStateChanged();
	}
	else{
		 ecjsCenterAtLatLng(x, y, z);
		 _jsmapapp.map.onStateChanged();
	}

	try{
		parent.info.myinfo.infolayerMOT(0);
	}
	catch(e1){}


}


function ecjsfGetCenter(){
	//return _jsmapapp.map.lastLatLng;
	e = new myqpoint();
	_jsmapapp.map.getCenterLatLng(e);
	return e;
}
function ecjsfGetZoom(){ return _jsmapapp.map.zoomLevel + 1.0; }

function ecjsfLayerClearall(){
		_jsmapapp.map.mylayer0.innerHTML = "";
		_jsmapapp.map.mylayer0.innerHTML =" <DIV id=xxx style=\"POSITION:absolute; Z-INDEX:10; TOP:0px; LEFT:0px ; \" ><table border=0 width= " +_jsmapapp.map.viewSize.width + " height=" + _jsmapapp.map.viewSize.height + "><tr><td></td></tr></table></DIV>";
		_jsmapapp.map.mylayer1.innerHTML = "";
		_jsmapapp.map.mylayer2.innerHTML = "";
}

function ecjsfLayerClearTheme(){
		var a = _jsmapapp.map.mylayer2.document.getElementById('divtheme');
		if(a)
		{
			a.innerHTML = "";
		}
}

function ecjsCheckAction(){
	lxy =  ecjsfGetCenter();
	lb = true;
	if( lxy.x < 800000 || lxy.x > 880000 || lxy.y < 800000 || lxy.y > 860000 ){
		alert("out of boundary");
		if(lxy.x < 800000)lxy.x = 805000;
		if(lxy.y < 800000)lxy.y = 805000;
		if(lxy.x > 875000)lxy.x = 870000;
		if(lxy.y > 855000)lxy.y = 850000;
		ecjsCenterAtLatLng(lxy.x,lxy.y);
	}
	return lb;
}
function ecjsSetCounter(a){
	if(top.head){
		if(mybrowser.mtype == 20){
			var counter = getElementById1(top.head.document, "counter");
			counter.value = a;
			
		}
		else{
			//top.head.counter.value = a;
			top.head.document.getElementById("counter").innerHTML = a;
		}
	}
	_jsmapapp.map.mapcounter = a;
}

function getElementById1(aobj, id)
{
	var nodelist = aobj.childNodes;
	var bobj = null;
	for(var i=0;i<nodelist.length; i++)
	{
		if(nodelist[i].id == id){
			return nodelist[i];
		}
		else if(nodelist[i].childNodes){
			bobj = getElementById1(nodelist[i], id);
			if(bobj) return bobj;
		}
	}
	return null;
}


function getElementsByTagName1(aobj, tname)
{
	var nodelist = aobj.childNodes;
	var arrrtn = new Array();
	var arrcnt = 0;
	var bobj = null;
	
	for(var i=0;i<nodelist.length; i++)
	{
		if(nodelist[i].nodeName == tname){
			arrrtn[arrcnt] = nodelist[i];
			arrcnt++;
		}
		if(nodelist[i].childNodes){
			bobj = getElementsByTagName1(nodelist[i], tname);
			if(bobj && bobj.length > 0){
				for(var j=0; j<bobj.length;j++){
					arrrtn[arrcnt] = bobj[j];
					arrcnt++;
				}
			}
		}
	}
	
	return arrrtn;
}



if (!_myissupport) { alert("fail");}
if (_myissupport) { 
	document.write('<div id="map" ></div>');
	_createMap(); 
} else {
	document.write('cannot run in this browser');
}


mc.lck = 'gbase';



 