MapsvrCtrl.prototype.showContents=function(){
	for(var i=0;i<this.icon.length;i++){
		window.clearTimeout(this.itimer[i]);
	}
	this.itimer.clear();
	this.icon.clear();
	if(!this.contents.length) return this.removeCanvas();
	this.clearCanvas();
	var shapeCount=0;
	for(var i=0;i<this.contents.length;i++){
		var cnt=this.contents[i];
		if(cnt.type!=Mapsvr.POI){
			shapeCount++;
			continue;
		}
		if(!this.categoryMap[cnt.cat]) continue;
		var icon=document.createElement("img");
		icon.src=this.categoryMap[cnt.cat].iconImage[cnt.status];
		icon.onmouseover=this.expandIcon(i);
		icon.onmouseout=this.deflateIcon(i);
		icon.onclick=this.onClick(i);
		var size=this.categoryMap[cnt.cat].iconSize[cnt.status];
		icon.width=size;
		icon.height=size;
		icon.style.position="absolute";
		icon.style.display='none';
		icon.style.zIndex=0;
		var order=this.resultProperty["order"];
		if(order=="reverse"){
			this.canvas.insertBefore(icon,this.canvas.firstChild);
		}
		else if(order=="random"){
			var nl=this.canvas.childNodes;
			var index=Math.floor(Math.random()*nl.length);
			this.canvas.insertBefore(icon,nl[index]);
		}
		else{
			if(document.getElementById("canvas")) document.getElementById("canvas").appendChild(icon);
			else this.canvas.appendChild(icon);
		}
		this.icon[i]=icon;
		this.dispIcon(i);
	}
	if(shapeCount){
		this.dispShape();
	}
	else if(this.background){
		this.background.style.filter="";
		this.background.style.backgroundImage="";
	}
};

MapsvrCtrl.prototype.dispIcon=function(index){
	if(!this.map)return;
	var c=this.contents[index];
	if(!c) return;

	if(c.type!=Mapsvr.POI) return;
	var p=this.map.latLon2Log(c.pos);
	var icon=this.icon[index];
	if(_bi.type==1){
		icon.style.filter='alpha(opacity='+this.opacity+')';
	}
	else{
		icon.style.opacity=this.opacity/100.0;
		icon.style.MozOpacity=this.opacity/100.0;
	}
	icon.style.visibility="hidden";
	if(p.x>0&&p.x<this.width&&p.y>0&&p.y<this.height){
		icon.style.display='block';
	}
	else{
		icon.style.display='none';
	}
	var d=this.categoryMap[c.cat].iconDiff[c.status]||new Point(0,0);
	var cp=this.canvasPos?this.map.latLon2Log(this.canvasPos):new Point(0,0);
	if(this.expand&&this.categoryMap[c.cat].expandSize[c.status]){
		icon.style.left=Math.floor(p.x-cp.x-icon.width/2+d.x)+"px";
		icon.style.top=Math.floor(p.y-cp.y-icon.height/2+d.y)+"px";
	}
	else{
		var hs=(this.categoryMap[c.cat].iconSize[c.status]||16)/2;
		icon.style.left=Math.floor(p.x-cp.x-hs+d.x)+"px";
		icon.style.top=Math.floor(p.y-cp.y-hs+d.y)+"px";
	}
	icon.style.visibility="visible";
//debug.print(icon.style.display);
};
MapsvrCtrl.prototype.moveContents=function(){
	if(this.background&&this.backgroundPos){
		var p=this.map.latLon2Log(this.backgroundPos);
		this.background.style.width=this.width+"px";
		this.background.style.height=this.height+"px";
		this.background.style.left=Math.floor(p.x)+"px";
		this.background.style.top=Math.floor(p.y)+"px";
	}
	if(this.canvas&&this.canvasPos){
		var p=this.map.latLon2Log(this.canvasPos);
		this.canvas.style.left=Math.floor(p.x)+"px";
		this.canvas.style.top=Math.floor(p.y)+"px";
		if(document.getElementById("canvas")){
			document.getElementById("canvas").style.left=Math.floor(p.x)+"px";
			document.getElementById("canvas").style.top=Math.floor(p.y)+"px";
		}
	}
};
MapsvrCtrl.prototype.resizeCanvas=function(){
	if(this.canvas){
		this.canvas.style.width=this.width+"px";
		this.canvas.style.height=this.height+"px";
		this.canvas.style.left="0px";
		this.canvas.style.top="0px";
		this.canvasPos=this.map.log2LatLon(new Point(0,0));
	}
	if(document.getElementById("canvas")){
		var cad=document.getElementById("canvas");
		cad.style.width=this.width+"px";
		cad.style.height=this.height+"px";
		cad.style.left="0px";
		cad.style.top="0px";
	}
};
MapsvrCtrl.prototype.createCanvas=function(){
	this.removeCanvas();
	this.background=document.createElement("div");
	this.background.style.position="absolute";
	this.background.style.display="block";
	this.map.getContainer().appendChild(this.background);
	this.canvas=document.createElement("div");
	this.canvas.style.position="absolute";
	this.canvas.style.display="none";
	if(!document.getElementById("canvas")){
		var canvas = document.createElement("div");
		canvas.id="canvas";
		canvas.style.position="absolute";
		canvas.style.display="block";
		canvas.style.zIndex="10";
		this.map.getContainer().appendChild(canvas);
	}
	this.map.getContainer().insertBefore(this.canvas,document.getElementById("canvas"));
};
MapsvrCtrl.prototype.clearCanvas=function(){
	if(!this.canvas) this.createCanvas();
	while(this.canvas.hasChildNodes()){
		this.canvas.removeChild(this.canvas.firstChild);
	}
	this.resizeCanvas();
};
MapsvrCtrl.prototype.removeCanvas=function(){
	if(this.background) this.map.getContainer().removeChild(this.background);
	this.background=null;
	if(this.canvas) this.map.getContainer().removeChild(this.canvas);
	this.canvas=null;
};

