/* /static/js/stays_list.js */ /* UTF8 COOKIE éà */


function	staysListClass(pageStays)
{
	this.pageStays = pageStays;
	this.popupGmap = null;

	this.popupGmapPins = [];
}



staysListClass.prototype.onGmapOpenClick = function(idx)
{
	var	el = vkDom.el('GMAPS_POPUP');

	if(el && GBrowserIsCompatible() && idx >= 0 && idx <= this.pageStays.length)
	{
		var	i, stay, hotel;
		var	minTop = 440;	// Avoid displaying the map over the flash player

		stay = this.pageStays[idx];

		vkDom.setText('GMAPS_TITLE', stay.STAY_NAME);

		if(this.popupGmap == null)
		{
			this.popupGmap = new GMap2(vkDom.el('GMAPS_MAP'), { mapTypes: [ G_PHYSICAL_MAP, G_NORMAL_MAP, G_SATELLITE_MAP ] });
			this.popupGmap.addControl(new GLargeMapControl());
			this.popupGmap.addControl(new GMapTypeControl());
			this.popupGmap.enableDoubleClickZoom();
			this.popupGmap.enableContinuousZoom();
		}

		this.popupGmap.setCenter(new GLatLng(stay.STAY_GMAP_BOUND_LAT, stay.STAY_GMAP_BOUND_LNG), parseInt(stay.STAY_GMAP_BOUND_ZOOM));

		// Remove existing pins from the map
		for(i = 0; i < this.popupGmapPins.length; i++)
			this.popupGmap.removeOverlay(this.popupGmapPins[i]);

		this.popupGmapPins = [];

		// Loop on stay hotels
		for(i = 0; i < stay.HOTELS.length; i++)
		{
			var	icon;

			hotel = stay.HOTELS[i];
			icon = new GIcon();
			icon.image = '/static/img/gpins/'+(i+1)+'.gif';
			icon.iconSize = new GSize(22, 23);
			icon.iconAnchor = new GPoint(5, 23);

			this.popupGmap.addOverlay(
				this.popupGmapPins[i] = new GMarker(
					new GLatLng(hotel.HOTEL_GMAP_LAT, hotel.HOTEL_GMAP_LNG),
					{ 'icon' : icon, 'title': hotel.HOTEL_NAME, 'draggable' : false }
				)
			);
		}

		el.style.left = (Math.max(document.documentElement.scrollLeft, document.body.scrollLeft) + ((document.documentElement.clientWidth-el.clientWidth)>>1))+'px';
		el.style.top = Math.max(minTop, (Math.max(document.documentElement.scrollTop, document.body.scrollTop) + ((document.documentElement.clientHeight-el.clientHeight)>>1)))+'px';

		el.style.visibility = 'visible';
	}

	return false;
}

staysListClass.prototype.onGmapCloseClick = function()
{
	var	el = vkDom.el('GMAPS_POPUP');

	if(el)
		el.style.visibility = 'hidden';

	return false;
}

