Hootenanny = window.Hootenanny || {};

Hootenanny.Contact = function() {
	var _locale = 'local';
	var _map = null;
	var _center_point = null;

	function _init_live_map() {
		if (GBrowserIsCompatible()) {
			_map = new GMap2(document.getElementById('map-live'), { size: new GSize(482, 376) });

			_center_point = new GLatLng(41.892838, -87.622472);

			_map.setCenter(_center_point, 16);
			_map.addControl(new GSmallMapControl());

			var icon = new GIcon();
			icon.image = '/images/google_icon.png';
			icon.iconSize = new GSize(42, 42);
			icon.iconAnchor = new GPoint(0, 38);

			var marker = new GMarker(_center_point, { icon: icon });
			_map.addOverlay(marker);

			$('body:first').unload(function() {
				alert('unloading google maps');
				GUnload();
			})
		}
	}

	function _init_map_tabs() {
		$('#map-link-standard').click(function() {
			$('#map-static').css('display', 'block');
			$('#map-live').css('display', 'none');
			$(this).addClass('selected');
			$('#map-link-live').removeClass('selected');

			return false;
		});

		$('#map-link-live').click(function() {
			$('#map-static').css('display', 'none');
			$('#map-live').css('display', 'block');
			$(this).addClass('selected');
			$('#map-link-standard').removeClass('selected');

			// make sure the map is set correctly (fixes display: none bug)
			_map.checkResize();
			_map.setCenter(_center_point);

			return false;
		});
	}

	return {
		init: function() {
			_init_live_map();
			_init_map_tabs();
		}
	}
}();