﻿var infowindow = null;

function initialize()
{
	var latlng = new google.maps.LatLng(49.62549, 6.1083);
	var myOptions = {
		zoom: 10,
		center: latlng,
		mapTypeId: google.maps.MapTypeId.ROADMAP,
		streetViewControl: false
	};
	 
	//place  map on  canvas
	var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
	 
	//Set all markers
	setMarkers(map, items);
	infowindow = new google.maps.InfoWindow({
	content: "holding..."
	});
}

// array of  markers
var items = [
	['Garage M. Losch - Bonnevoie', 49.593960, 6.137849, 1, '<div><h1><a href="http://www.losch.lu/gmll/default.htm">Garage M. Losch – Bonnevoie</a></h1><p>78-90, route de Thionville<br />L-2610 Luxembourg<br />Tél: 40 07 07 - 1<br />E-mail: <a href="mailto:secretariat@gmll.lu">secretariat@gmll.lu</a></P><p><a href="http://www.losch.lu/gmll/default.htm">Plus d\'infos</a> | <a href="http://maps.google.com/maps?daddr=49.593960,6.137849&hl=fr" target="_blank">Itinéraire</a></p></div>'],
	['Porsche Zenter Lëtzebuerg - Howald', 49.576153, 6.138922, 2, '<div><h1><a href="http://www.porsche.lu/accessoriesandservice/porscheservice/centreporsche.htm">Porsche Zenter Lëtzebuerg – Howald</a></h1><p>5, rue Peternelchen<br />L-2370 Howald<br />Tél: 26 36 31 - 1<br />E-mail: <a href="mailto:info@porsche.lu">info@porsche.lu</a></p><p><a href="http://www.porsche.lu/accessoriesandservice/porscheservice/centreporsche.htm">Plus d\'infos</a> | <a href="http://maps.google.com/maps?daddr=49.576153,6.138922&hl=fr" target="_blank">Itinéraire</a></p></div>'],
	['Garage M. Losch - Bereldange', 49.653801, 6.129100, 3, '<div><h1><a href="http://www.losch.lu/gmlb/default.htm">Garage M. Losch – Bereldange</a></h1><p>6, Cité Grand-Duc Jean<br />L-7233 Bereldange<br />Tél: 26 33 55 - 1<br />E-mail: <a href="mailto:info@gmlb.lu">info@gmlb.lu</a></p><p><a href="http://www.losch.lu/gmlb/default.htm">Plus d\'infos</a> | <a href="http://maps.google.com/maps?daddr=49.653801,6.129100&hl=fr" target="_blank">Itinéraire</a></p></div>'],
	['Garage M. Losch - Esch-sur-Alzette', 49.495705, 5.967464, 4, '<div><h1><a href="http://www.losch.lu/gmle/default.htm">Garage M. Losch – Esch/Alzette</a></h1><p>1-2, an der Schmelz<br />L-4328 Esch-sur-Alzette<br />Tél: 55 53 12 - 1<br />E-mail: <a href="mailto:info@gmle.lu">info@gmle.lu</a></p><p><a href="http://www.losch.lu/gmle/default.htm">Plus d\'infos</a> | <a href="http://maps.google.com/maps?daddr=49.495705,5.967464&hl=fr" target="_blank">Itinéraire</a></p></div>'],
	['Garage Losch & Cie - Junglinster', 49.704445, 6.249644, 5, '<div><h1><a href="http://www.loschcie.lu/">Garage Losch & Cie – Junglinster</a></h1><p>2-4, rue Nicolas Glesener<br />L-6131 Junglinster<br />Tél: 78 94 93 - 1<br />E-mail: <a href="mailto:info@loschcie.lu">info@loschcie.lu</a></p><p><a href="http://www.loschcie.lu/">Plus d\'infos</a> | <a href="http://maps.google.com/maps?daddr=49.704445,6.249644&hl=fr" target="_blank">Itinéraire</a></p></div>']
];

var image = new google.maps.MarkerImage(
	'images/marker-images/image.png',
	new google.maps.Size(32,37),
	new google.maps.Point(0,0),
	new google.maps.Point(16,37)
);

var imageporsche = new google.maps.MarkerImage(
	'images/marker-images/image-porsche-grey.png',
	new google.maps.Size(32,37),
	new google.maps.Point(0,0),
	new google.maps.Point(16,37)
);

var shadow = new google.maps.MarkerImage(
	'images/marker-images/shadow.png',
	new google.maps.Size(54,37),
	new google.maps.Point(0,0),
	new google.maps.Point(16,37)
);

var shape = {
	coord: [29,0,30,1,31,2,31,3,31,4,31,5,31,6,31,7,31,8,31,9,31,10,31,11,31,12,31,13,31,14,31,15,31,16,31,17,31,18,31,19,31,20,31,21,31,22,31,23,31,24,31,25,31,26,31,27,31,28,31,29,30,30,29,31,23,32,22,33,21,34,20,35,19,36,12,36,11,35,10,34,9,33,8,32,2,31,1,30,0,29,0,28,0,27,0,26,0,25,0,24,0,23,0,22,0,21,0,20,0,19,0,18,0,17,0,16,0,15,0,14,0,13,0,12,0,11,0,10,0,9,0,8,0,7,0,6,0,5,0,4,0,3,0,2,1,1,2,0,29,0],
	type: 'poly'
};

//function to actually put the markers on the map
function setMarkers(map, markers)
{
	//loop through and place markers
	for (var i = 0; i < markers.length; i++)
	{
		//porsche special icon
		if (i == 1){
			var iconx = imageporsche;
		} else {
			var iconx = image
		};
		
		var sites = markers[i];
		var siteLatLng = new google.maps.LatLng(sites[1], sites[2]);
		var marker = new google.maps.Marker({
			position: siteLatLng,
			map: map,
			icon: iconx,
			shadow: shadow,
			shape: shape,
			title: sites[0],
			zIndex: sites[3],
			html: sites[4]
		});

		//initial content string
		var contentString = "Some content";

		//attach infowindow on click
		google.maps.event.addListener(marker, "click", function ()
		{
			infowindow.setContent(this.html);
			infowindow.open(map, this);
		});
	}
}

google.maps.event.addDomListener(window, 'load', initialize);

