//Google maps script by Дамян Станчев created on 11:53 28 Юли 2010 г.
//Добавен showAddressGC от Дамян Станчев на 09:32 08 Септември 2010 г.

var map = null;
var geocoder = null;
var _mMapCopy = "Map data \x26#169;2008 ";
var _mSatelliteCopy = "Imagery \x26#169;2008 ";  

if(document.getElementById('wrapper') == 'null')
{
	document.getElementById('wrapper').style.display='none';
	document.getElementById('wrapper').style.visibility='hidden';
}

if(document.getElementById('map_outer') == 'null')
{
	document.getElementById('map_outer').style.display='none';
}

GLoadMapsScript();

function load()
{
	if (GBrowserIsCompatible())
	{
		if(!document.getElementById("map"))
		{
			return;
		}
		map = new GMap2(document.getElementById("map"));
		map.setMapType(G_NORMAL_MAP);
		//map.setCenter(new GLatLng(42.6976262, 23.3222839),13);
		geocoder = new GClientGeocoder();
		map.addControl(new GSmallZoomControl());
	}
}

function showAddress(address)
{
	if (geocoder)
	{
		geocoder.getLatLng
		(
			address,
			function(point)
			{
				if (!point)
				{
					document.getElementById('map').style.display='none';
					$('#tmpl_googlemap h2').css('display','none');
					//load();
				}
				else
				{
					if(point.x==23.3222839 && point.y==42.6976262)
					{
						map.checkResize();
						map.setCenter(point,13);
						//map.setCenter(point,13);
						return;
					}
					$('#map').css('display','block');
					$('#map_outer').css('display','block');
					$('#map_outer').css('padding','2px');
					if(ie)
					{
						$('#map_outer').css('width','auto');
					}
					else
					{
						$('#map_outer').css('width','202px');
					}
					$('#map_outer').css('height','202px');
					$('#map_outer').css('background','#ffffff');
					$('#map_outer').css('borderWidth','2px');
					$('#map_outer').css('borderColor','#46427F');
					$('#wrapper').css('display','block');
					$('#wrapper').css('width','242px');
					$('#wrapper').css('padding','0px');
					//Logics...
					map.checkResize();
					map.setCenter(point,17);
					var marker = new GMarker(point);
					map.addOverlay(marker);
					//marker.openInfoWindowHtml(address);
				}
			}
		);
	}
}

function showAddressGC(lat,lng)
{
	if (geocoder)
	{
		var point = new GLatLng(lat,lng);
		$('#map').css('display','block');
		$('#map_outer').css('display','block');
		$('#map_outer').css('padding','2px');
		if(ie)
		{
			$('#map_outer').css('width','auto');
		}
		else
		{
			$('#map_outer').css('width','202px');
		}
		$('#map_outer').css('height','202px');
		$('#map_outer').css('background','#ffffff');
		$('#map_outer').css('borderWidth','2px');
		$('#map_outer').css('borderColor','#46427F');
		$('#wrapper').css('display','block');
		$('#wrapper').css('width','242px');
		$('#wrapper').css('padding','0px');
		map.checkResize();
		map.setCenter(point,17);
		var marker = new GMarker(point);
		map.addOverlay(marker);
	}
}

