// JavaScript Document
function travelMap(id, center_latitude, center_longitude, zoom)
{
	this.reset = function()
	{
		this.map.closeInfoWindow();
		this.map.setCenter(new GLatLng(this.center_latitude, this.center_longitude), 11);
	}

	this.addHotel = function(hotel)
	{
		hotel.html = '';

		hotel.html += '	<div class="main_container">';
		hotel.html += '		<span class="hotel_name">' + hotel.name + '</span><br />';
		hotel.html += '		<span>' + hotel.address + '</span><br />';
		hotel.html += '		<span> ' + hotel.booknow  + '</span>' ;
		hotel.html += '	</div>';

		hotel.marker = this.pointMarker(hotel.longitude, hotel.latitude, hotel.html, "../images/attraction.html");

		this.hotels[hotel.ID] = hotel;

	}


	this.viewHotel = function(ID)
	{
    this.hotels[ID].marker.openInfoWindowHtml(this.hotels[ID].html);
	}

	this.addAmenity = function(longitude, latitude, name)
	{

		var amenity = { // da esportare
			name: name,
			latitude: latitude,
			longitude: longitude
		};

		amenity.html = '';
		amenity.html += '<div style="font-family:verdana; font-size:10px; width:120px;">'+name+'</div>';

		amenity.marker = this.pointMarker(amenity.longitude, amenity.latitude, amenity.html, "../images/attraction.html");

		this.amenities.push(amenity);
	}


	this.pointMarker = function(longitude, latitude, html, icon)
	{
		var marker = new GMarker(new GLatLng(latitude, longitude), new GIcon(G_DEFAULT_ICON, icon));
		GEvent.addListener(marker, 'click', function()
			{
				this.openInfoWindowHtml(html);
			}
		);
		this.map.addOverlay(marker);
		return marker;
	}


	this.addArea = function(area)
	{
		var Garea = Array();
		for(var i = 0; i < area.length; i++)
		{
			Garea[i] = new GLatLng(area[i].latitude, area[i].longitude);
		}

		Garea[Garea.length] = Garea[0];

		var polyline = new GPolyline(Garea, "#ff0000", 2);

		this.map.addOverlay(polyline);

	}


	this.hotelCenter = function(ID)
	{
	  var hotel = this.hotels[ID];
		if(''+hotel+'' != 'undefined')
		{
		  this.center_latitude = hotel.latitude;
		  this.center_longitude = hotel.longitude;
		  this.reset();
		  hotel.marker.openInfoWindowHtml(hotel.html);
		}
	}

	this.map = new GMap2(document.getElementById(id));
	this.center_latitude = center_latitude;
	this.center_longitude = center_longitude;

	this.hotels = Array();
	this.amenities = Array();

	this.map.addControl(new GLargeMapControl());
	this.map.addControl(new GMapTypeControl());

	this.reset();

}

document.write('<style type="text/css"> v\:* { behavior:url(#default#VML); } </style>');


var map;


