var map = null;
var places = new Array();

var setVisible = new Array();

setVisible[0] = false;
setVisible[1] = false;
setVisible[2] = false;


function initMap(i) {
	
	places[0] = new place("<h3>Finlandia-talo</h3><p>Mannerheimintie 13 E<br/>00100 Helsinki<br/>Puh. 09 40241<br/><a href='http://www.finlandiatalo.fi/' target='_blank'>Verkkosivut</a></p>", 60.17583075799645, 24.933407306671143, 15, 0);
	places[1] = new place("<h3>Kansallisooppera</h3><p>Helsinginkatu 58<br/>PL 176<br/>00251 HELSINKI<br/>Puh. 09 4030 21<br/><a href='http://www.ooppera.fi/etusivu.asp?kieli=1' target='_blank'>Verkkosivut</a></p>", 60.18159300179186, 24.92825746536255,15, 0);
	places[2] = new place("<h3>Kansallismuseo</h3><p>Mannerheimintie 34<br/>PL 913<br/>00101 HELSINKI<br/>Puh. 09 4050 9544<br/><a href='http://www.nba.fi/fi/skm' target='_blank'>Verkkosivut</a></p>", 60.17426197211013, 24.932270050048828, 15, 0);
	places[3] = new place("<h3>Musiikkitalo</h3><p>Katariinankatu 1<br/>00170 HELSINKI<br/>Puh. 0400 703 179<br/><a href='http://www.musiikkitalo.fi/' target='_blank'>Verkkosivut</a></p>", 60.17333347169895, 24.935145378112793, 15, 0);
	places[4] = new place("<h3>Kiasma</h3><p>Mannerheiminaukio 2<br/>00100 HELSINKI<br/>Puh. 09 1733 6501<br/><a href='http://typo.kiasma.fi/index.php?id=11&FL=1&L=0' target='_blank'>Verkkosivut</a></p>", 60.17129494770263, 24.9364972114563, 15, 0);
	places[5] = new place("<h3>Kaupunginteatteri</h3><p>El&auml;intarhantie 5<br/>00530 HELSINKI<br/>Puh. 09 394 022<br/><a href='http://www.hkt.fi/' target='_blank'>Verkkosivut</a></p>", 60.182, 24.943, 15, 0);
	places[6] = new place("<h3>Hakasalmen huvila</h3><p><strong>Helsingin kaupunginmuseo</strong><br/>Karamzininkatu 2<br/>00100 Helsinki<br/>Puh. 09 169 3444<br/><a href='http://www.hel.fi/wps/portal/Kaupunginmuseo/' target='_blank'>Verkkosivut</a></p>", 60.17420861072835, 24.93422269821167, 15, 0);
	places[7] = new place("<h3>Talvipuutarha</h3><p>Hammarskj&ouml;ldintie 1 A<br/>00250 HELSINKI<br/>Puh. 09 3103 9985<br/><a href='http://www.hel.fi/wps/portal/Rakennusvirasto/Viheralueet?WCM_GLOBAL_CONTEXT=/fi/Rakennusvirasto/Viheralueet/Talvipuutarha' target='_blank'>Verkkosivut</a></p>", 60.18574172482943, 24.932312965393066, 15, 0);
	places[8] = new place("<h3>Kirjasto 10</h3><p>Elielinaukio 2 G<br/>PL 4200<br/>00099 HELSINKI<br/>Puh. 09 3108 5703 (neuvonta ja tietopalvelu)<br/><a href='http://www.lib.hel.fi/kirjasto10' target='_blank'>Verkkosivut</a></p><h3>Postitalo</h3><p>Elielinaukio 2F<br/>00100 HELSINKI<br/>Puh. 0200 71 000<br/><a href='http://www.paapostitalo.fi/' target='_blank'>Verkkosivut</a></p>", 60.171087619490855, 24.937763214111328, 15, 0);
	
	places[9] = new place("<h3>Eduskuntatalo</h3><p>Mannerheimintie 13e<br/>00100 HELSINKI<br/><a href='http://web.eduskunta.fi/' target='_blank'>Verkkosivut</a></p>", 60.17254636019765, 24.933289289474487, 15, 0);
	places[10] = new place("<h3>Rautatieasema</h3><p>Asema-aukio<br/>00100 HELSINKI<br/><a href='http://www.vr.fi/heo/asemat/asemat.htm' target='_blank'>Verkkosivut</a></p>", 60.1703, 24.9406, 15, 0);
	places[11] = new place("<h3>Sanomatalo</h3><p>T&ouml;&ouml;l&ouml;nlahdenkatu 2<br/>PL 18<br/>00089 SANOMA<br/>Puh. 09 1221<br/><a href='http://www.sanoma.fi/Content.aspx?f=2218' target='_blank'>Verkkosivut</a></p>", 60.17237292641364, 24.938149452209473, 15, 0);
	places[12] = new place("<h3>Linnunlaulun huvilat</h3><p>Linnunlauluntie 11<br/>00530 HELSINKI<br/>09 753 5128</p>", 60.1818063988133, 24.936368465423584, 15, 0);
	places[13] = new place("<h3>Kansallisteatteri</h3><p>L&auml;ntinen Teatterikuja 1<br/>00100 Helsinki<br/>Puh. (09) 173 311<br/>Liput (09) 1733 1331<br/><a href='http://www.kansallisteatteri.fi/' target='_blank'>Verkkosivut</a></p>", 60.17247271760576, 24.943320751190186, 15, 0);
	//places[14] = new place("<h3>Kaupunginteatteri</h3><p>Ensi linja 2, 00530 HELSINKI<br/>Puh. (09) 39401<br/>Liput (09) 3940 22<br/><a href='http://www.hkt.fi/' target='_blank'>Verkkosivut</a></p>", 60.18231587851285, 24.943116903305054, 15, 0);
	places[27] = new place("<h3>Kasvitieteellinen puutarha</h3><p>PL 7 (Kaisaniemenranta 2)<br/>00014 Helsingin yliopisto<br/><a href='http://www.fmnh.helsinki.fi/nayttelyt/ktp/' target='_blank'>Verkkosivut</a></p>", 60.176400, 24.944801, 15, 0);
	
	places[15] = new place("<h3>Ravintola T&ouml;&ouml;l&ouml;nranta</h3><p>Helsinginkatu 56<br/>00250 HELSINKI<br/>09 6128 5700<br/><a href='http://www.royalravintolat.com/toolonranta/' target='_blank'>Verkkosivut</a></p>", 60.182595955734904, 24.93096113204956, 15, 1);
	places[16] = new place("<h3>Oopperan ravintola</h3><p>Helsinginkatu 58<br/>PL 176<br/>00251 HELSINKI<br/>Puh. 09 4030 21<br/><a href='http://www.kanresta.fi/kansallisooppera/' target='_blank'>Verkkosivut</a></p>", 60.18159300179186, 24.92825746536255, 15, 1);
	places[17] = new place("<h3>Ravintola Kaisaniemi</h3><p>Kaisaniementie 6<br/>00100 HELSINKI<br/>09 632 223<br/><a href='http://www.ravintolakaisaniemi.fi/kaisanie/kaisanie.htm' target='_blank'>Verkkosivut</a></p>", 60.175121878790506, 24.942312240600586, 15, 1);
	places[18] = new place("<h3>Sport Club Chelsea, Verde (Holiday Inn)</h3><p>Elielinaukio 5<br/>00100 HELSINKI<br/><a href='http://www.chelsea.fi/' target='_blank'>Sport Club Chelsea</a><br/><a href='http://www.restel.fi/holidayinn/view.cfm?page=restaurant.2' target='_blank'>Verde</a></p>", 60.17232036239798, 24.939061403274536, 15, 1);
	places[19] = new place("<h3>Painobaari, Namaskaar & Wok it</h3><p>Alvar Aallon Kuja 2<br/>00100 HELSINKI<br/>09 622 2007<br/><a href='http://www.painobaari.fi/' target='_blank'>Painobaari</a><br/><a href='http://www.n-w.cc/' target='_blank'>Namaskaar & Wok it</a></p></p>", 60.17237292641364, 24.938149452209473, 15, 1);
	
	places[20] = new place("<h3>Linnunlaulun Sinisen Huvilan Kahvila</h3><p>Linnunlauluntie 11<br/>00530 HELSINKI<br/>09 753 5128</p>", 60.1818063988133, 24.936368465423584, 15, 2);
	places[21] = new place("<h3>Talvipuutarhan kahvila</h3><p>Hammarskj&ouml;ldintie 1<br/>00250 HELSINKI<br/>09 399 985<br/><a href='http://www.hel.fi/wps/portal/Rakennusvirasto/Viheralueet?WCM_GLOBAL_CONTEXT=/hkr/fi/Viheralueet/Talvipuutarha/Vuokraus' target='_blank'>Verkkosivut</a></p>", 60.18574172482943, 24.932312965393066, 15, 2);
	places[22] = new place("<h3>Kansallismuseon kahvila</h3><p>Mannerheimintie 34<br/>PL 913<br/>00101 HELSINKI<br/>Puh. 09 4050 9544<br/><a href='http://www.nba.fi/fi/skm_kahvila' target='_blank'>Verkkosivut</a></p>", 60.17426197211013, 24.932270050048828, 15, 2);
	places[23] = new place("<h3>Cafe Kiasma</h3><p>Mannerheiminaukio 2<br/>00100 HELSINKI<br/>09 1733 6501</p>", 60.17129494770263, 24.9364972114563, 15, 2);
	places[24] = new place("<h3>Wayne's Coffee</h3><p>Alvar Aallon Kuja 2<br/>00100 HELSINKI<br/>09 622 2007<br/><a href='http://www.waynescoffee.fi/index.php' target='_blank'>Verkkosivut</a></p>", 60.17237292641364, 24.938149452209473, 15, 2);
	places[25] = new place("<h3>Cafe Caramelle</h3><p>Karamzininkatu 2,<br/>00100 HELSINKI<br/>p. 09  441 072</p>", 60.17420861072835, 24.93422269821167, 15, 2);
	places[26] = new place("<h3>Viola - kes&auml;kahvila ja juhlaravintola</h3><p>Kaisaniemenranta 2<br/>00100 HELSINKI<br/>p. 09 191 24468<br/><a href='http://www.juhlaravintolat.fi/index.php?option=com_content&task=view&id=184&Itemid=71' target='_blank'>Verkkosivut</a></p>", 60.17587718001317, 24.946796894073486, 15, 2);
	

	map = new GMap2(document.getElementById("mapcanvas"));

	map.addControl(new GLargeMapControl());
	
	if(i >= 0) {
		map.setCenter(new GLatLng(places[i].lat,places[i].lon), places[i].zoom);
		setMarker(places[i].lat, places[i].lon, places[i].string, 0);
	} else if(i == -2) {
		map.setCenter(new GLatLng(60.179,	24.9339), 14);
		for(var k=9; k<16; k++) {
			setMarker(places[k].lat, places[k].lon, places[k].string, 0);
		}
		setMarker(places[27].lat, places[27].lon, places[27].string, 0);
	} else {
		map.setCenter(new GLatLng(60.179,	24.9339), 14);
		
		var placeType = 0;
		if(window.location.hash == '#restaurant') placeType = 1;
		if(window.location.hash == '#cafe') placeType = 2;
		
		setVisible[placeType] = true;
		document.getElementById("mapControl" + (placeType+1)).className = "active";
		
		for(var k=0; k<places.length; k++) {
			if(places[k].type == placeType) {
				setMarker(places[k].lat, places[k].lon, places[k].string, 0);
			}
		}
	}
}

function setMarker(lat, lon, myHtml,i) {
	var marker = new GMarker(new GLatLng(lat, lon));
	GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml(myHtml);
	});
	map.addOverlay(marker);
}

function showMarkers() {
	
	map.clearOverlays();
	
	if(setVisible[0]) {
		for(var k=0; k<places.length; k++) {
			if(places[k].type == 0) {
				setMarker(places[k].lat, places[k].lon, places[k].string, 0);
			}
		}
	}
	
	if(setVisible[1]) {
		for(var k=0; k<places.length; k++) {
			if(places[k].type == 1) {
				setMarker(places[k].lat, places[k].lon, places[k].string, 1);
			}
		}
	}
	
	if(setVisible[2]) {
		for(var k=0; k<places.length; k++) {
			if(places[k].type == 2) {
				setMarker(places[k].lat, places[k].lon, places[k].string, 2);
			}
		}
	}
}

function togglePlaces(e) {
	document.getElementById("mapControl1").className = "active";
	document.getElementById("mapControl2").className = "normal";
	document.getElementById("mapControl3").className = "normal";
	setVisible[0] = true;
	setVisible[1] = false;
	setVisible[2] = false;
	showMarkers();

}

function toggleRestaurants(e) {
	document.getElementById("mapControl1").className = "normal";
	document.getElementById("mapControl2").className = "active";
	document.getElementById("mapControl3").className = "normal";
	setVisible[0] = false;
	setVisible[1] = true;
	setVisible[2] = false;
	showMarkers();
}

function toggleCafes(e) {
	document.getElementById("mapControl1").className = "normal";
	document.getElementById("mapControl2").className = "normal";
	document.getElementById("mapControl3").className = "active";
	setVisible[0] = false;
	setVisible[1] = false;
	setVisible[2] = true;
	showMarkers();
}

function place(string, lat, lon, zoom, type) {
	this.string = string;
	this.lat = lat;
	this.lon = lon;
	this.zoom = zoom;
	this.type = type;
}