/**
 * @version MyMap.js version 2.0
 * @author Nathan Meurrens < nathan@meurrens.org >
 * @author Marc Meurrens < marc@meurrens.org >
 * @copyright Brussels, July 23, 2007 15:13
 * @license LGPL http://creativecommons.org/licenses/LGPL/2.1/
 * @requires ooTools.js (ooTools.extend used by MyMarker.js)
 * @requires MyGLatLng.js (proper extensions of GLatLng used by MyMarker.js)
 * @requires MyMarker.js (an extension of Gmarker used below)
*/

/*************************************************************
 Implementation comment:

(last error number [23] in version 1.2 ; 984 lines)

MyMap
=====

1. CT :

function MyMap( szMapNodeId , szError? , szWarning? )

2. eventually ...

myMap.disableMapDragging() ; // do not confuse with marker dragging
myMap.setView(uView?) ; // 0 map, 1 satellite, 2 hybrid
myMap.addTypeControl() ; // allows uView modif
myMap.setZoomLevel(uZoomLevel?) ; // 1 world to 17 very detailled
myMap.setLargeZoomControl(z?) ; // add a large widget to modify the zoom
myMap.setNodeSize(uW?, uH?) ;
myMap.setColors(szBorderStyle? , szImg? , opacity?) ;
myMap.setDemoColors() ;
myMap.setLabel(szMarkerLabel?,szLabLab?) ;
myMap.setAlertMessages(szError?,szWarning?)

myMapDragLatLng.setPositionCallBack(fns?) ; // **************
myMap.setShowNodeCallBack(fns?) ;
myMap.setInfoPlaceMarkersCallBack(fns?) ;
myMap.setZoomEndCallBack(fns)
myMap.setViewChangedCallBack(fns)

2.bis syntax of the callbacks

fnsPositionCallBack(fLat,fLng,objGLatLng) ;
fnsShowNodeCallBack(zShowOrHide) ;
fnsInfoPlaceMarkersCallBack(array of JSON's) ;
fnsZoomEndCallBack(zOldZoom,uNewZoom)
fnsViewChangedCallBack(uView)

3. either ...

myMap.loadInfoAddress(szAddress) ;
myMap.loadAddress(szAddress) ;
myMap.loadLatLng(lat,lng) ;

4. at page unload

MyMap.UnLoadMap() ;

***************************************************************/

// 1. create an object MyMap
// 1.1. CT : (constructor)

function MyMap(szMapNodeId , szError , szWarning )
{
	// a few IV's are initialized here :
	this.szError = szError || MyMap.MsgError ;
	if (szMapNodeId)
	{
		if (GBrowserIsCompatible())
		{
			this.domMapNode = document.getElementById(szMapNodeId)
			?document.getElementById(szMapNodeId)
			:false;
			if (this.domMapNode)
			{
				this.szWarning = szWarning || MyMap.MsgWarning ;

				// IV's to be initialized by setters :
				this.objGMap = null ;
				this.objMyMarker = null ;
				this.objGLatLng = null ;
				this.szMarkerLabel = "" ;
				this.szLabelTitle = MyMap.MsgDefInfoTitle ;
				this.uZoomLevel = MyMap.DefZoomLevel ;
				this.uWidth = MyMap.DefNodeWidth ;
				this.uHeight = MyMap.DefNodeHeight ;
				this.szBorderStyle = "" ;
				this.urlTileImg = "" ;
				this.fzOpacity = MyMap.DefOpacity ;
				this.zDisableMapDragging = false ;
				this.zTypeControl = false ;
				this.uView = 0 ;

				// 4 or 5 callback functions to be defined by setters
				// this.fnsPositionCallBack = null ; // used only by derived class MyMapDragLatLng
				this.fnsShowNodeCallBack = null ;
				this.fnsZoomEndCallBack = null ;
				this.fnsViewChangedCallBack = null ;
				this.fnsPlaceMarkersCallBack = null ;

				// other IV's to manage google geocoding output
				this.szPrettyAddress =  false ; // arrPlacemarks[0].address ;
				this.a2CountryNameCode = false ; //   arrPlacemarks[0].AddressDetails.Country.CountryNameCode ;
				this.uAccuracy = 0 ;
				this.szAccuracy = "" ;
			}
			else
			this._alert(MyMap.MsgNoNode,1) ;
		}
		else
		this._alert(MyMap.MsgOldBrowser,2) ;
	}
	else
	this._alert(MyMap.MsgNoNodeId,3) ;
}

//////  0, 1 , 2 , 3 , 4
// 0 no access (No)
// 1 receive coord on click (Min)
// 2 receive coord if already a label (Std)
// 3 receive coord even if not already a label (Max)
// 4 may drag the marker (Drag)

// 0 // function MyMapNoLatLng(szMapNodeId , szError , szWarning)

// 1 // function MyMapMinLatLng(szMapNodeId , szError , szWarning)

// 2 : is directly MyMap

// 3 // function MyMapMaxLatLng(szMapNodeId , szError , szWarning)

// 4 // function MyMapDragLatLng(szMapNodeId , szError , szWarning)


///// 5.2. CV (class variables):
///////////////

// 5.2.1 misc

MyMap.DemoBorderStyle = "dotted 1px #040639" ;
MyMap.DemoImg = "http://test.banlieues.be/myMap/skin/img/040639@32x32.png" ;
MyMap.DefNodeWidth = 400 ;
MyMap.DefNodeHeight = 400 ;
MyMap.DefZoomLevel = 15 ;
MyMap.DefOpacity = 0.5 ;
MyMap.InfoTableWidth = 200 ;

MyMap.Accuracies = [
"unknown" , // 0
"country" , // 1
"region" , // 2
"sub-region" , // 3
"town" , // 4
"postal code" , // 5
"street" , // 6
"intersection" , // 7
"address" // 8
] ;

// 5.2.2 Messages
MyMap.MsgError = "MyMap Error" ;
MyMap.MsgWarning = "MyMap Warning" ;
MyMap.MsgLatLng = "LatLng" ;
MyMap.MsgDefInfoTitle = "?" ;
MyMap.MsgOldBrowser = "[1] your browser is not compatible" ;
MyMap.MsgNoNodeId = "[2] no dom node id" ;
MyMap.MsgNoNode = "[3] no dom node" ;
MyMap.MsgNoAddress = "[4] no address" ;
MyMap.MsgNoGeocoder =  "[5] no objGClientGeocoder found" ;
MyMap.MsgNoGeocoding =  "[6] enable to geocode that address" ;
MyMap.MsgAddressNotFound = "[7] address not found" ;
MyMap.MsgList10Places = "[8] the 10 first placemarks found will now be listed" ;
MyMap.MsgFirst0 = "[9] the first of the " ;
MyMap.MsgFirst1 = " placemarks will now be displayed" ;
MyMap.MsgInvalidCoord = "[10] invalid coordinates" ;
MyMap.MsgCannotDisplay = "[11] cannot display google map" ;

// 5.3. IV's :
// see the CT

// 5.4. PUBLIC STATIC FUNCTION
// 5.4.1. Unload

MyMap.UnloadMap = function()
{
	GUnload(); //Avoid Internet Explorer memory leaks
}

// 5.4.2. Geocoding

MyMap.GeoCoder = function(szAddress,fnsCallBack) // fnsCallBack(lat,lng,objGLatLng)
{
	if (GBrowserIsCompatible())
	{
		var objGClientGeocoder = new GClientGeocoder();
		if(objGClientGeocoder)
		{
			objGClientGeocoder.getLatLng(szAddress,function(objGLatLng){
				fnsCallBack(objGLatLng.lat(),objGLatLng.lng(),objGLatLng) ;
			});
		}
		else alert("[4] " + MyMap.MsgNoGeocoder ) ;
	}
	else
	alert("[5] " + MyMap.MsgOldBrowser ) ;
}

MyMap.GeoCoderInfo = function(szAddress,fnsCallBack) // fnsCallBack(lat,lng,objGLatLng,arrPlaceMarks)
{
	if (GBrowserIsCompatible())
	{
		var objGClientGeocoder = new GClientGeocoder();
		if(objGClientGeocoder)
		{
			objGClientGeocoder.getLocations(szAddress,function(jsonResponse){
				if(!jsonResponse || jsonResponse.Status.code != 200)
				{
					alert("[6] " + MyMap.MsgNoGeocoding ) ;
				}
				else
				{
					var arrPlacemarks = jsonResponse.Placemark ;
					var jsonFirstPlacemark = arrPlacemarks[0] ;
					var pp = jsonFirstPlacemark.Point ;
					var fLat = parseFloat(pp.coordinates[1]) ;
					var fLng = parseFloat(pp.coordinates[0]) ;
					fnsCallBack(fLat,fLng,(new GLatLng(fLat,fLng)),arrPlacemarks)
				}
			});
		}
		else alert("[7] " + MyMap.MsgNoGeocoder ) ;
	}
	else alert("[8] " + MyMap.MsgOldBrowser  ) ;
}

// 5.4.3 Demo's : see MyMapDemo.js
// 5.5. MAIN PUBLIC INSTANCE METHODS
// 5.5.1. loading

MyMap.prototype.loadAddress = function(szAddress)
{
	this.szPrettyAddress =  false ; // arrPlacemarks[0].address ;
	this.a2CountryNameCode = false ; //   arrPlacemarks[0].AddressDetails.Country.CountryNameCode ;
	this.uAccuracy = 0 ;
	if(this.domMapNode)
	{
		if(szAddress)
		{
			this._hideNode();
			var objGClientGeocoder = new GClientGeocoder();
			if(objGClientGeocoder)
			{
				var me = this ;
				objGClientGeocoder.getLatLng(szAddress,function(objGLatLng){
					me._proceedLatLng(objGLatLng);
				});
				/**
				* Map should be setted here as getLatLng depends on
				* an http request that may be not fast enough.
				** */
			}
			else this._alert(MyMap.MsgNoGeocoder,9) ;
		}
		else this._alert(MyMap.MsgNoAddress,10) ;
	}
	else this._alert(MyMap.MsgNoNode,11) ;
}


MyMap.prototype.loadInfoAddress = function(szAddress)
{
	this.szPrettyAddress =  false ; //  arrPlacemarks[0].address ;
	this.a2CountryNameCode = false ; // arrPlacemarks[0].AddressDetails.Country.CountryNameCode ;
	this.uAccuracy = 0 ;
	if(this.domMapNode)
	{
		if(szAddress)
		{
			this._hideNode();
			var objGClientGeocoder = new GClientGeocoder();
			if(objGClientGeocoder)
			{
				var me = this ;
				objGClientGeocoder.getLocations(szAddress,function(jsonResponse){
					me._proceedLocations(jsonResponse);
				});
				/**
				* Map should be setted here as getLatLng depends on
				* an http request that may be not fast enough.
				** */
			}
			else this._alert(MyMap.MsgNoGeocoder,12) ;
		}
		else this._alert(MyMap.MsgNoAddress,13) ;
	}
	else this._alert(MyMap.MsgNoNode,14) ;
}

MyMap.prototype.loadLatLng = function(fLat,fLng)
{
	this.szPrettyAddress =  false ; //  arrPlacemarks[0].address ;
	this.a2CountryNameCode = false ; // arrPlacemarks[0].AddressDetails.Country.CountryNameCode ;
	this.uAccuracy = 0 ;
	this._hideNode();
	if(this.domMapNode)
	{
		this.objGLatLng = new GLatLng(fLat,fLng) ;
		this._showMapByCoordinates() ;
	}
	else this._alert(MyMap.MsgNoNode,15) ;

}

///// 5.5.2. GETTERS

MyMap.prototype.getLat = function()
{
	return this.objMyMarker ? this.objMyMarker.getPoint().lat() : false ;
}

MyMap.prototype.getRoundLat = function()
{
	return this.objMyMarker ? this.objMyMarker.getRoundLat() : false ;
}

MyMap.prototype.getLng = function()
{
	return this.objMyMarker ? this.objMyMarker.getPoint().lng() : false ;
}

MyMap.prototype.getRoundLng = function()
{
	return this.objMyMarker ? this.objMyMarker.getRoundLng() : false ;
}

///// 5.5.3. SETTERS


MyMap.prototype.setAlertMessages = function(szError,szWarning)
{
	this.szError = szError || MyMap.MsgError ;
	this.szWarning = szWarning || MyMap.MsgWarning ;
}

MyMap.prototype.setLargeZoomControl = function(zLargeZoom)
{
	this.zLargeZoomControl = zLargeZoom ? true : false ;
}

MyMap.prototype.setShowNodeCallBack = function(fnsCallBack)
{
	this.fnsShowNodeCallBack = fnsCallBack ;
}

MyMap.prototype.setZoomEndCallBack = function(fnsCallBack)
{
	this.fnsZoomEndCallBack = fnsCallBack ;
}

MyMap.prototype.setViewChangedCallBack = function(fnsCallBack)
{
	this.fnsViewChangedCallBack = fnsCallBack ;
}

MyMap.prototype.setInfoPlaceMarkersCallBack = function(fnsPlaceMarkersCallBack)
{
	this.fnsPlaceMarkersCallBack = fnsPlaceMarkersCallBack ;
}

MyMap.prototype.setView = function(uView,zNow)
{
	this.uView = uView || 0 ; // 0/null/other = normal , 1 satellite, 2 hybrid
	if(zNow && this.objGMap)
	{
		switch(this.uView)
		{
			case 1 : this.objGMap.setMapType(G_SATELLITE_MAP) ; break ;
			case 2 : this.objGMap.setMapType(G_HYBRID_MAP) ; break ;
			default : this.objGMap.setMapType(G_NORMAL_MAP) ; break ;
		}
	}
}

MyMap.prototype.setLabel = function(szMarkerLabel,szLabLab)
{
	this.szMarkerLabel = szMarkerLabel ;
	this.szLabelTitle = szLabLab || MyMap.MsgDefInfoTitle ;
}

MyMap.prototype.disableMapDragging = function(zNow)
{
	this.zDisableMapDragging = true ;
	if(zNow && this.objGMap) this.objGMap.disableDragging() ;
}

MyMap.prototype.addTypeControl = function(zNow)
{
	this.zTypeControl = true ;
	if(zNow && this.objGMap) this.objGMap.addControl(new GMapTypeControl());
}

MyMap.prototype.setZoomLevel = function(uZoomLevel,zNow)
{
	this.uZoomLevel = uZoomLevel || MyMap.DefZoomLevel ;
	if(zNow && this.objGMap) this.objGMap.setCenter(this.objGLatLng,this.uZoomLevel) ;
}

MyMap.prototype.setNodeSize = function(uW,uH,zNow)
{
	this.uWidth = uW || MyMap.DefNodeWidth ; // 400
	this.uHeight = uH || MyMap.DefNodeHeight ; // 400
	if(zNow)
	{
		if(this.domMapNode) this._proceedNodeSize() ;
		if(this.objGMap) this.objGMap.setCenter(this.objGLatLng,this.uZoomLevel);
	}
}

MyMap.prototype.setColors = function(szBS , szImg , opacity)
{
	this.szBorderStyle = szBS ;
	this.urlTileImg = szImg ;
	this.fzOpacity = opacity || MyMap.DefOpacity ;
}

MyMap.prototype.setDemoColors = function()
{
	/*
	MyMap.DemoBorderStyle = "dotted 1px #51056d" ;
	MyMap.DemoImg = "http://www.babelwiki.org/googlemap/skin/img/51056d@32x32.png" ;
	*/
	this.szBorderStyle = MyMap.DemoBorderStyle ;
	this.urlTileImg = MyMap.DemoImg ;
	this.fzOpacity = MyMap.DefOpacity ;
}

////// SETTER FOR  MyMapDragLatLng

// MyMapDragLatLng.prototype.setPositionCallBack = function(fnsCallBack)

///// 5.6.1 MAIN INTERNAL INSTANCE METHODS

MyMap.prototype._alert = function(szText,uNumero,zWarning)
{
	var szMsg = zWarning ? this.szWarning : this.szError ;
	alert(szMsg + " :\n[" + uNumero + "] " + szText ) ;
}

MyMap.prototype._proceedLatLng = function(objGLatLng)
{
	if(this.domMapNode)
	{
		if(objGLatLng)
		{
			this.objGLatLng = objGLatLng ;
			this._showMapByCoordinates() ;
		}
		else this._alert(MyMap.MsgAddressNotFound,16) ;
	}
	else this._alert(MyMap.MsgNoNode,17) ;
}

MyMap.prototype._proceedLocations = function(jsonResponse)
{
	if(this.domMapNode)
	{
		if( !jsonResponse || (jsonResponse.Status.code != 200) )
		{
			this._alert(MyMap.MsgNoGeocoding,18) ;
		}
		else
		{
			var arrPlacemarks = jsonResponse.Placemark ;
			if(arrPlacemarks.length == 10)
			{
				this._alert(MyMap.MsgList10Places,19,true) ; // warning
			}
			if(arrPlacemarks.length >= 2)
			{
				var sz = "" ;
				var i = 0 ;
				for(i=0;i<arrPlacemarks.length;i++)
				{
					// sz += (arrPlacemarks[i].address + " ["+parseInt(arrPlacemarks[i].AddressDetails.Accuracy)+"] ?\n") ;
					sz += (arrPlacemarks[i].address + " ?\n") ;
				}
				alert(sz) ;
				this._alert(MyMap.MsgFirst0 + arrPlacemarks.length + MyMap.MsgFirst1,20,true) ; // warning
			}
			var jsonFirstPlacemark = arrPlacemarks[0] ;
			var pp = jsonFirstPlacemark.Point ;
			var fLat = parseFloat(pp.coordinates[1]) ;
			var fLng = parseFloat(pp.coordinates[0]) ;
			this.objGLatLng = new GLatLng(fLat,fLng) ;
			this.szPrettyAddress =  jsonFirstPlacemark.address ;
			this.a2CountryNameCode =  jsonFirstPlacemark.AddressDetails.Country.CountryNameCode ;
			this.uAccuracy = parseInt(jsonFirstPlacemark.AddressDetails.Accuracy) ;
			this.szAccuracy = MyMap.Accuracies[this.uAccuracy] ;
			if(jsonFirstPlacemark.AddressDetails.Country.AdministrativeArea)
			{
				this.szPrettyMore = '' ;
				if(jsonFirstPlacemark.AddressDetails.Country.AdministrativeArea.AdministrativeAreaName)
				{
					this.szPrettyMore = (' (' + jsonFirstPlacemark.AddressDetails.Country.AdministrativeArea.AdministrativeAreaName + ') ') ;
				}
				if(jsonFirstPlacemark.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea)
				{
					if(jsonFirstPlacemark.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.SubAdministrativeAreaName)
					{
						this.szPrettyMore += (' (' + jsonFirstPlacemark.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.SubAdministrativeAreaName + ') ') ;
					}
				}
				this.szPrettyAddress += ('<br/><em>' + this.szPrettyMore + '</em>') ;
			}
			this._showMapByCoordinates() ;
			if(this.fnsPlaceMarkersCallBack) this.fnsPlaceMarkersCallBack(arrPlacemarks) ;
		}
	}
	else this._alert(MyMap.MsgNoNode,21) ;
}

MyMap.prototype._showMapByCoordinates = function()
{
	if(this.objGLatLng)
	{
		this._proceedNodeProperties() ;
		this._showNode();
		this.objGMap = new GMap2(this.domMapNode);
		if(this.objGMap)
		{
			if(this.zDisableMapDragging) this.objGMap.disableDragging() ;
			this.objGMap.setCenter(this.objGLatLng,this.uZoomLevel);
			switch(this.uView)
			{
				case 1 : this.objGMap.setMapType(G_SATELLITE_MAP) ; break ;
				case 2 : this.objGMap.setMapType(G_HYBRID_MAP) ; break ;
				default : this.objGMap.setMapType(G_NORMAL_MAP) ; break ;
			}
			this._proceedMapProperties();
			if(this.fnsZoomEndCallBack)
			{
				GEvent.addListener(this.objGMap,"zoomend",this.fnsZoomEndCallBack) ;
			}
			if(this.fnsViewChangedCallBack)
			{
				var me = this ;
				GEvent.addListener(this.objGMap,"maptypechanged",function(){
					var cmt = me.objGMap.getCurrentMapType() ;
					var uCmt = 0 ;
					if(cmt == G_SATELLITE_MAP) uCmt = 1 ;
					else if(cmt == G_HYBRID_MAP) uCmt = 2 ;
					me.fnsViewChangedCallBack(uCmt) ;
				}) ;
			}
			this._addMarker();
		}
		else
		{
			this._alert(MyMap.MsgCannotDisplay,22) ;
			this._hideNode() ;
		}
	}
	else this._alert(MyMap.MsgInvalidCoord,23) ;
}

///// 5.6.2. OTHER INTERNAL INSTANCE METHODS

MyMap.prototype._hideNode = function()
{
	this.domMapNode.style.display="none";
	if(this.fnsShowNodeCallBack) this.fnsShowNodeCallBack(false) ;
}

MyMap.prototype._showNode = function()
{
	this.domMapNode.style.display="block";
	if(this.fnsShowNodeCallBack) this.fnsShowNodeCallBack(true) ;
}

/***********************************************
the behaviour of _addMarker depends upon (0 to 4)
// 0 no access
// 1 receive coord on click
// 2 receive coord if already a label
// 3 receive coord even if not already a label
// 4 may drag the marker
************************************************/

// 2. (Standard)

MyMap.prototype._addMarker = function()
{
	// not draggable except in case 4
	var objMyMarker = new MyMarker(this.objGLatLng, {draggable: false});
	objMyMarker.clearInfoArray() ;
	this.objMyMarker = objMyMarker ;
	var curMap = this.objGMap ;
	if(objMyMarker)
	{
		// if label
		GEvent.addListener(objMyMarker, "click", function() {
			objMyMarker.openInfoWindowLatLng(false) ;
		});

		this.objGMap.addOverlay(objMyMarker);
		var szLatLngHtmlInfo = objMyMarker.getLatLngHtmlInfo() ;
		/*
		this.szPrettyAddress =  arrPlacemarks[0].address ;
		this.a2CountryNameCode =  arrPlacemarks[0].AddressDetails.Country.CountryNameCode ;
		*/
		if(this.uAccuracy)
		{
			this.szMarkerLabel += ("<br /><i>["+this.uAccuracy+": "+this.szAccuracy+"]</i>") ;

		}
		if(this.szMarkerLabel)
		{
			var szMarkerLabel = "<fieldset style='width:" + MyMap.InfoTableWidth + "px' ><small>"
			+ this.szMarkerLabel + "</small></fieldset>" ;
			if(this.szPrettyAddress)
			{
				/* var szPretty = "<table width='" + MyMap.InfoTableWidth + "px' border='0'><tr><td><small>"
				+ this.szPrettyAddress + "</small></td></tr></table>" ; */
			var szPretty = "<fieldset style='width:" + MyMap.InfoTableWidth + "px' ><small>"
			+ this.szPrettyAddress + "</small></fieldset>" ;
				objMyMarker.openInfoWindowTabsHtml(objMyMarker.arrInfo = [
				new GInfoWindowTab(this.a2CountryNameCode, szPretty),
				new GInfoWindowTab(this.szLabelTitle,  szMarkerLabel),
				new GInfoWindowTab(MyMap.MsgLatLng, szLatLngHtmlInfo)
				]);
				// this.szPrettyAddress = false ;
			}
			else
			{
				objMyMarker.openInfoWindowTabsHtml(objMyMarker.arrInfo = [
				new GInfoWindowTab(this.szLabelTitle,  szMarkerLabel),
				new GInfoWindowTab(MyMap.MsgLatLng, szLatLngHtmlInfo)
				]);
			}
		}
	}
}

/**************************************************************/

MyMap.prototype._proceedNodeProperties = function()
{
	this._proceedNodeSize() ;
	this._proceedNodeColor() ;
}

MyMap.prototype._proceedNodeSize = function()
{
	if(this.domMapNode)
	{
		this.domMapNode.style.height = this.uHeight + "px" ;
		this.domMapNode.style.width = this.uWidth + "px" ;
	}
}

MyMap.prototype._proceedNodeColor = function()
{
	if(this.szBorderStyle && this.domMapNode) this.domMapNode.style.border= this.szBorderStyle ;
}

MyMap.prototype._proceedMapProperties = function()
{
	if(this.objGMap)
	{
		this._proceedMapControl();
		this._proceedMapColor();
	}
}

MyMap.prototype._proceedMapControl = function()
{
	/*
	* @method addControl
	* @param GLargeMapControl , GSmallMapControl , GSmallZoomControl , GMapTypeControl , GOverviewMapControl
	* @param GControlPosition
	*/
	if(this.objGMap)
	{
		if(this.zDisableMapDragging)
		{
			this.objGMap.addControl(new GSmallZoomControl());
		}
		else
		{
			if(this.zLargeZoomControl)
			this.objGMap.addControl(new GLargeMapControl());
			else
			this.objGMap.addControl(new GSmallMapControl());
		}
		if(this.zTypeControl) this.objGMap.addControl(new GMapTypeControl());
		// this.objGMap.addControl(new GScaleControl());
	}
}

/*
Konqueror 3.5.2
BUG 
run the demo.php script to see the error
*/

MyMap.prototype._proceedMapColor = function()
{
	if(this.urlTileImg && this.objGMap)
	{
		var objGTileLayer = new GTileLayer(new GCopyrightCollection(), 0, 17);
		if(objGTileLayer)
		{
			/*
			objGTileLayer.getTileUrl = function(tile, zoom)
			{
			return "skin/img/51056d@32x32.png";
			};
			*/
			eval("objGTileLayer.getTileUrl=function(tile,zoom){return \"" + this.urlTileImg + "\"};") ;
			/*
			objGTileLayer.getOpacity = function() {return 0.5 ;}
			*/
			eval("objGTileLayer.getOpacity=function(){return " + this.fzOpacity + ";};") ;

			this.objGMap.addOverlay(new GTileLayerOverlay(objGTileLayer));
		}
	}
}

// THE END // EoF