google.load("maps", "2");
google.setOnLoadCallback(initialize);

var isMSIE = /*@cc_on!@*/false; 
var gmapInfomations = new Array();

function PlaceIndicator(info) {
	this._info		= info;
	this._color		= info.color ? info.color : "red";
	this._center	= info.latlng;
	this._div		= document.createElement("div");  this._div.className		= "gmapIndicator";
	this._label		= document.createElement("span"); this._label.className		= "gmapIndicatorLabel";
	
		this._label.innerHTML			= info.html;
		//this._label.style.width			= (this._label.innerText.length * 1.2) + "em";
		this._label.style.height		= "20px";
		this._label.style.borderColor	= this._color;
	this._div.appendChild(this._label);
}

function initialize() {
	window.onunload = google.maps.Unload;
	
	PlaceIndicator.prototype = new google.maps.Overlay();
	PlaceIndicator.prototype.initialize = function(map) {
		this._map = map;
		var streamline			= new google.maps.Icon();
		streamline.image		= "/files/style/images/map/stl_" + this._color + ".gif";
		streamline.iconSize		= new GSize(9, 30);
		streamline.iconAnchor	= new GPoint(4, 24);
		
		var marker = new GMarker(this._center, { icon:streamline });
		this._map.addOverlay(marker);
		this._map.getPane(G_MAP_FLOAT_PANE).appendChild(this._div);
		
		this._marker = null;
		this.drawIndicator();
	}
	PlaceIndicator.prototype.redraw = function(force) {
		this.drawIndicator();
	}
	PlaceIndicator.prototype.drawIndicator = function(topleft){
		var topleft = this._map.fromLatLngToDivPixel(this._center);
		topleft.y -= 20;
		this._div.style.left = (topleft.x - 500) + "px";
		this._div.style.top  = (topleft.y - 27) + "px";
	}
	
	if(GBrowserIsCompatible()){
		for (var i = 0; i < gmapInfomations.length; i++) { createNewMap(gmapInfomations[i]); }
	}
}

function ll(lat, lng) { return new google.maps.LatLng(lat, lng); }

function mapInfo(divid, lat, lng, zoom) {
	var result = new Object();
	gmapInfomations.push(result);
	
	result.mapDivisionID = divid;
	result.center = ll(lat, lng);
	result.zoom   = zoom;
	
	result.indicators = new Array();
	return result;
}

function createNewMap(info) {
	var map = new google.maps.Map2(document.getElementById(info.mapDivisionID));
	map.setCenter(info.center, info.zoom);
	map.addControl(new google.maps.LargeMapControl());
	
	for (var i = 0; i < info.indicators.length; i++) {
		map.addOverlay(new PlaceIndicator(info.indicators[i]));
	}
}
