
/************************************************** 
 * 
 * (C) Alexander Trofimov (kolimarfey@gmail.com)
 *
 * You can NOT redistribute it and/or modify without permission of Alexander Trofimov 
 *
 **************************************************/


	function GoogleMapsShowLocation(sErrMsg, id, sAddressZip, sAddress, iZoom, iMapType, iMapControl, isTypeControl, isScaleControl, isOverviewControl) 
	{
		if (GBrowserIsCompatible()) 
		{
			var geocoder = new GClientGeocoder();			
			
			var sText = sAddressZip;						

			var h = function (r)
			{
				if (603 == r.Status.code) 
				{					
					return;
				}

				if (sText == sAddressZip && (!r || r.Status.code != 200)) 
				{
					sText = sAddress;
					geocoder.getLocations(sText, h);
				}
				else
				if (!r || r.Status.code != 200) 
				{
					GoogleMapsShowError(id, sErrMsg);
				} 
				else 
				{            
					var i = 0;					                
					var place = r.Placemark[i];
					GoogleMapsDisplayMarker(id, iZoom, iMapType, iMapControl, isTypeControl, isScaleControl, isOverviewControl, new GLatLng(parseFloat(place.Point.coordinates[1]), parseFloat(place.Point.coordinates[0])));
				}
			}			
	
			if ('lat_lng' == sAddress)
			{
				var aPoint = sAddressZip.split('x');
				if (parseFloat(aPoint[0]) || parseFloat(aPoint[1]))
					GoogleMapsDisplayMarker(id, iZoom, iMapType, iMapControl, isTypeControl, isScaleControl, isOverviewControl, new GLatLng(parseFloat(aPoint[0]), aPoint[1]));
				else
					GoogleMapsShowError(id, sErrMsg);
			}
			else
			{
				geocoder.getLocations(sText, h);		    				
			}

		}
	}


	function GoogleMapsShowError(id, sErrMsg)
	{
		if (sErrMsg.length) document.getElementById(id).innerHTML = sErrMsg;
		document.getElementById(id).style.height = 'auto';
	}

	function GoogleMapsDisplayMarker(id, iZoom, iMapType, iMapControl, isTypeControl, isScaleControl, isOverviewControl, point)
	{			
		glMap = new GMap2(document.getElementById(id));	
		glMap.setCenter (point, iZoom);
		glMap.addOverlay(new GMarker(point));

		switch (iMapControl)
		{
			case 2: glMap.addControl(new GLargeMapControl()); break;
			case 1: glMap.addControl(new GSmallMapControl()); break;
		}
		
		if (isTypeControl) glMap.addControl(new GMapTypeControl());
		if (isScaleControl) glMap.addControl(new GScaleControl());
		if (isOverviewControl) glMap.addControl(new GOverviewMapControl ());
		
		glMap.enableContinuousZoom ();

		switch (iMapType)
		{
			case 1: glMap.setMapType(G_SATELLITE_MAP); break;
			case 2: glMap.setMapType(G_HYBRID_MAP); break;
			default: glMap.setMapType(G_NORMAL_MAP); break;
		}
	}

