var gmap;
var Gmap = Class.create  (
{
	initialize:function(obj, store)
	{
		if(store == 'aupark')
		{
			var latlng = new google.maps.LatLng(48.13298609209864, 17.1071720123291);
		}
		if(store == 'eurovea')
		{
			var latlng = new google.maps.LatLng(48.14090495832415, 17.12091565132141);
		}
		if(store == 'centrala')
		{
			var latlng = new google.maps.LatLng(48.151284985115076, 17.116506099700928);
		}
		var mapOptions = {
		  zoom: 16,
		  center: latlng,
		  mapTypeControl: false,
		  scrollwheel: false,
		  mapTypeId: google.maps.MapTypeId.ROADMAP
		}
		this.map = new google.maps.Map(obj, mapOptions);
		this.setMarker(latlng, store);
	},
	
	//umiestnenie spendlika na mape
	setMarker: function(position, store)
	{
		if(store == 'aupark')
		{
			this.createAuparkInfoWindow();
		}
		if(store == 'eurovea')
		{
			this.createEuroveaInfoWindow();
		}
		if(store == 'centrala')
		{
			this.createCentralaInfoWindow();
		}
		
		var markerOptions = {
			map: this.map, 
			position: position, 
			clickable: false, 
			draggable: false
		};
		this.marker = new google.maps.Marker(markerOptions);
		this.infoWindow.open(this.map, this.marker);
		
	},
	
	createAuparkInfoWindow: function()
	{
		var contentString = 
		  '<div class="mapBubble">' +
			  '<div class="image"><img src="/images/mzone-logo-map.jpg" alt="" width="130"></div>'+
			  '<div class="info">' +
			  	'<div class="row">Prízemie vľavo od hlavného vchodu</div>' +
			  	'<div class="row"><strong>Aupark,</strong> Einsteinova 18, 851 01 Bratislava</div>' +
			  '</div>' +
		  '</div>';
		this.infoWindow = new google.maps.InfoWindow({content: contentString});
	},
	
	createEuroveaInfoWindow: function()
	{
		var contentString = 
		  '<div class="mapBubble">' +
			  '<div class="image"><img src="/images/mzone-logo-map.jpg" alt="" width="130"></div>'+
			  '<div class="info">' +
			  	'<div class="row">Prvé poschodie v budove pri kinách</div>' +
			  	'<div class="row"><strong>Eurovea Galleria,</strong> Pribinova 8, 811 09 Bratislava</div>' +
			  '</div>' +
		  '</div>';
		this.infoWindow = new google.maps.InfoWindow({content: contentString});
	},
	
	createCentralaInfoWindow: function()
	{
		var contentString = 
		  '<div class="mapBubble">' +
			  '<div class="image"><img src="/images/mzone-logo-map.jpg" alt="" width="130"></div>'+
			  '<div class="info">' +
			  	'<div class="row"><strong>m:zone centrála,</strong> Radlinského 26, 811 07 Bratislava</div>' +
			  '</div>' +
		  '</div>';
		this.infoWindow = new google.maps.InfoWindow({content: contentString});
	}
});
  
function restoreGmap(lat, lng, zoom)
{
	if(gmap)
	{
		gmap.restorePosition(lat, lng, zoom);
	}
	else
	{
		setTimeout(restoreGmap.bind(null, lat, lng, zoom), 100);
	}
}


