var gmap;
var gLatLong = new Array();
var gBalloon = new Array();
var gIcons = new Array();

//markers
gLatLong['jaarbeursplein'] = new GLatLng(52.089415, 5.109190);
gLatLong['cs'] = new GLatLng(52.090995, 5.111037);
gBalloon['cs'] = '<h3>Utrecht Centraal</h3><p>Train station &#8216;Utrecht Centraal&#8217;<br />Shopping centre &#8216;Hoog Catharijne&#8217;</p>';
gLatLong['dom'] = new GLatLng(52.090680, 5.121640);
gBalloon['dom'] = '<h3>Domtoren</h3><p>Domplein 21, Utrecht</p>';
gLatLong['hotel1'] = new GLatLng(52.091450, 5.106491);
gBalloon['hotel1'] = '<h3>Park Plaza Utrecht</h3><p><em>Hotel, 4 stars</em><br />Westplein 50<br />Utrecht</p>';
gLatLong['hotel2'] = new GLatLng(52.090175, 5.106288);
gBalloon['hotel2'] = '<h3>NH Utrecht</h3><p><em>Hotel, 4 stars</em><br />Jaarbeursplein 24<br />Utrecht</p>';
gLatLong['hotel3'] = new GLatLng(52.088743, 5.122643);
gBalloon['hotel3'] = '<h3>Court Hotel</h3><p><em>Hotel, 4 stars</em><br />Korte Nieuwstraat 14<br />Utrecht</p>';
gLatLong['hotel4'] = new GLatLng(52.091782, 5.122612);
gBalloon['hotel4'] = '<h3>NH Centre Utrecht Hotel</h3><p><em>Hotel, 3 stars</em><br />Janskerkhof 10 <br />Utrecht</p>';
gLatLong['hotel5'] = new GLatLng(52.078036, 5.114962);
gBalloon['hotel5'] = '<h3>Beurshotel</h3><p><em>Hotel, 2 stars</em><br />Balijelaan 1<br />Utrecht</p>';
gLatLong['hotel6'] = new GLatLng(52.077620, 5.114179);
gBalloon['hotel6'] = '<h3>Little Siam Hotel</h3><p><em>Hotel, 2 stars</em><br />Balijelaan 17<br />Utrecht</p>';
gLatLong['hotel7'] = new GLatLng(52.099533, 5.139027);
gBalloon['hotel7'] = '<h3>Hotel de Admiraal</h3><p><em>Hotel, 2 stars</em><br />Admiraal van Gentstraat 11<br />Utrecht</p>';
gLatLong['hotel8'] = new GLatLng(52.094200, 5.137130);
gBalloon['hotel8'] = '<h3>Malie Hotel Hampshire Classic</h3><p><em>Hotel, 4 stars</em><br />Maliestraat 2<br />Utrecht</p>';
gLatLong['mediaplaza'] = new GLatLng(52.087549, 5.104437);
gBalloon['mediaplaza'] = '<h3><img src="/2008/images/logo-dxf.gif" alt="Design by Fire conference" /><br />Media Plaza</h3><p>Jaarbeurs Hal 6, Croeselaan 6<br />Utrecht</p>';
gLatLong['springweg'] = new GLatLng(52.088782, 5.1195);
gBalloon['springweg'] = '<h3>Parking</h3><p>Springweg/Strosteeg<br />Utrecht</p>';
gLatLong['ylab'] = new GLatLng(52.085387, 5.125251);
gBalloon['ylab'] = '<h3>Ylab</h3><p><em>design for interactive media</em><br />Lange Nieuwstraat 78<br />3512 PM  Utrecht</p>';
gLatLong['ixda'] = new GLatLng(52.085387, 5.125251);
gBalloon['ixda'] = '<h3>IxDA Nederland</h3><p><em>Dutch Interaction Design Association</em><br />Lange Nieuwstraat 78<br />3512 PM  Utrecht</p>';
gLatLong['spoorwegmuseum'] = new GLatLng(52.088289, 5.130711);
gBalloon['spoorwegmuseum'] = '<h3><img src="/2008/images/logo-dxf.gif" alt="Design by Fire conference" /><br />Spoorwegmuseum</h3><p>Maliebaanstation 16<br />Utrecht</p>';
gLatLong['maliebaan'] = new GLatLng(52.091400, 5.132284);
gBalloon['maliebaan'] = '<p>Maliebaan bus stop</p>';
gLatLong['hofman'] = new GLatLng(52.093957, 5.121131);
gBalloon['hofman'] = '<h3>Hofman Cafe</h3><p>Janskerkhof 17a<br />3512BM Utrecht<br />Telefoon: 030-230<br /><a href="http://www.hofman-cafe.nl/">www.hofman-cafe.nl</a></p>';
gLatLong['cafemidi'] =   new GLatLng(52.081590, 5.112054);
gBalloon['cafemidi'] = '<p>Design by Fire Caf&eacute; #001</p><h3>Caf&eacute; Midi</h3><p>Croeselaan 140<br />Utrecht</p>';

//icons
gIcons['std'] = new GIcon();
gIcons['std'].image = '/2008/images/mm_20_maroon.png';
gIcons['std'].shadow = '/2008/images/mm_20_shadow.png';
gIcons['std'].iconSize = new GSize(12, 20);
gIcons['std'].shadowSize = new GSize(22, 20);
gIcons['std'].iconAnchor = new GPoint(6, 20);
gIcons['std'].infoWindowAnchor = new GPoint(5, 1);

gIcons['fav'] = new GIcon(gIcons['std']);
gIcons['fav'].image = '/2008/images/mm_20_gray.png';

gIcons['dom'] = new GIcon(gIcons['std']);
gIcons['dom'].image = '/2008/images/mm_20_dom.png';
gIcons['dom'].shadow = '/2008/images/mm_20_domshadow.png';
gIcons['dom'].iconSize = new GSize(10, 28);
gIcons['dom'].shadowSize = new GSize(23, 28);
gIcons['dom'].iconAnchor = new GPoint(5, 28);

gIcons['htl'] = new GIcon(gIcons['std']);
gIcons['htl'].image = '/2008/images/mm_20_hotel.png';
gIcons['htl'].shadow = '/2008/images/mm_20_hotelshadow.png';
gIcons['htl'].iconSize = new GSize(17, 20);
gIcons['htl'].shadowSize = new GSize(24, 20);
gIcons['htl'].iconAnchor = new GPoint(10, 20);

gIcons['dxf'] = new GIcon();
gIcons['dxf'].image = '/2008/images/logo-dxf.png';
gIcons['dxf'].iconSize = new GSize(160, 60);
gIcons['dxf'].iconAnchor = new GPoint(80, 60);


function loadGM() {
	if (GBrowserIsCompatible()){
		gmap = new GMap2(document.getElementById('map'));
		gmap.addControl(new GLargeMapControl());
		gmap.setCenter(gLatLong['spoorwegmuseum'], 15);

		//add markers to the map during load
		addMarker(gLatLong['dom'], gIcons['dom'], gBalloon['dom'], false);
		addMarker(gLatLong['spoorwegmuseum'], gIcons['std'], gBalloon['spoorwegmuseum'], false);
		addMarker(gLatLong['cs'], gIcons['fav'], gBalloon['cs'], false);
		addMarker(gLatLong['ixda'], gIcons['fav'], gBalloon['ixda'], false);
		addMarker(gLatLong['maliebaan'], gIcons['fav'], gBalloon['maliebaan'], false);
		addMarker(gLatLong['hofman'], gIcons['fav'], gBalloon['hofman'], false);

		addMarker(gLatLong['hotel1'], gIcons['htl'], gBalloon['hotel1'], false);
		addMarker(gLatLong['hotel2'], gIcons['htl'], gBalloon['hotel2'], false);
		addMarker(gLatLong['hotel3'], gIcons['htl'], gBalloon['hotel3'], false);
		addMarker(gLatLong['hotel4'], gIcons['htl'], gBalloon['hotel4'], false);
		addMarker(gLatLong['hotel7'], gIcons['htl'], gBalloon['hotel7'], false);
		addMarker(gLatLong['hotel8'], gIcons['htl'], gBalloon['hotel8'], false);

		GEvent.addListener(gmap, "click", function(overlay, point){
			if (point) {
				msg = point.lat() + ', ' + point.lng();
				//for finding coordinates by clicking on the map
				//document.getElementById('maphelper').innerHTML = msg;
			}
		});

		window.onunload = function() {GUnload();}
	}
}

function goAndShow(m){
	//move map to marker and show the balloon
	if(!gmap){
		loadGM();
	}else{
		document.getElementById('map').scrollIntoView();
	}
	gmap.panTo(gLatLong[m]);
	gmap.openInfoWindowHtml(gLatLong[m],gBalloon[m]);
	return false;
}

function addMarker(loc, icon, html, bOpen){
	var marker = new GMarker(loc, icon);
	gmap.addOverlay(marker);
	attachInfo(marker, html, bOpen);
}

function attachInfo(marker, infohtml, bOpen){
	if(marker && infohtml){
		GEvent.addListener(marker, 'click', function() {
			marker.openInfoWindowHtml(infohtml);
		});
		if(bOpen){
			marker.openInfoWindowHtml(infohtml);
		}
	}
}