(function(){

var activeTab = 'info',
	map = null,
	marker = null,
	markerHtml = null;

function tabHover(e) {
	var tabId = this.id.replace(/htl[-]/, '');

	$('htl-'+activeTab).className = "";
	dom.hide(activeTab+'-area');
	dom.show(tabId+'-area');
	$('htl-'+tabId).className = "selected";
	activeTab = tabId;
}

Queue.add(function(){
	Event.on($$('li', 'tabs'), 'click', tabHover);
	dom.show('info-area');
	
	if ( $('google-map') && window.GBrowserIsCompatible && GBrowserIsCompatible() ) {
		Event.on(window, 'unload', GUnload);

		map = new GMap2($('google-map'));
		map.setMapType(G_HYBRID_MAP);
		map.addControl(new GMapTypeControl());
		map.addControl(new GLargeMapControl());
		map.setCenter(new GLatLng(geoData.latitude, geoData.longitude), 14);

		marker = new GMarker(new GLatLng(geoData.latitude, geoData.longitude));
		map.addOverlay(marker);
		
		markerHtml = '<h2>'+geoData.title+'</h2><p>';
		if ( geoData.address.trim().length ) {
			markerHtml += geoData.address + '<br/>';
		}
		markerHtml += geoData.location + ', ' + geoData.country + '</p>';

		GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml(markerHtml);
        });
	}
});

})();