window.onload = initialize;
var map;
var coords;
var markers;
var contentString;
var infowindow;
 function initialize() {
	try {
		var myOptions = {
			zoom: 8,
			center: new google.maps.LatLng(35.00, 33.28),
			mapTypeId: google.maps.MapTypeId.ROADMAP
		}
		map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);



		var image = 'assets/templates/toronto/img/icon-map.jpg';
		
		coords = [
				new google.maps.LatLng(35.15866, 33.356319),
				new google.maps.LatLng(35.152427, 33.367937),
				new google.maps.LatLng(35.157244, 33.385295),
				new google.maps.LatLng(35.171345, 33.333532),
				new google.maps.LatLng(35.112151, 33.381572),
				
				new google.maps.LatLng(35.117717, 33.314169),
				new google.maps.LatLng(35.177351, 33.380671),
				new google.maps.LatLng(35.148177, 33.194115),
				new google.maps.LatLng(35.136212, 33.352392),
				new google.maps.LatLng(35.087678, 33.284272),
				
				new google.maps.LatLng(35.143645, 33.310647),
				new google.maps.LatLng(35.087678, 33.284272),
				new google.maps.LatLng(34.695152, 33.033837),
				new google.maps.LatLng(35.031971, 33.980756)
			];
					
		markers = [ 
				new google.maps.Marker({ title: "ΑΓΙΟΙ ΟΜΟΛΟΓΗΤΕΣ",  position: coords[0], map: map, icon: image}),
				new google.maps.Marker({ title: "ΑΚΡΟΠΟΛΗ",  position: coords[1], map: map, icon: image}),
				new google.maps.Marker({ title: "ΑΓΛΑΝΤΖΙΑ",  position: coords[2], map: map, icon: image}),
				new google.maps.Marker({ title: "ΑΓΙΟΣ ΔΟΜΕΤΙΟΣ",  position: coords[3], map: map, icon: image}),
				new google.maps.Marker({ title: "ΛΑΤΣΙΑ",  position: coords[4], map: map, icon: image}),
				
				new google.maps.Marker({ title: "ΛΑΚΑΤΑΜΙΑ",  position: coords[5], map: map, icon: image}),
				new google.maps.Marker({ title: "ΠΑΛΛΟΥΡΙΩΤΙΣΣΑ",  position: coords[6], map: map, icon: image}),
				new google.maps.Marker({ title: "ΚΟΚΚΙΝΟΤΡΙΜΙΘΙΑ",  position: coords[7], map: map, icon: image}),
				new google.maps.Marker({ title: "ΣΤΑΥΡΟΣ (Στρόβολος)",  position: coords[8], map: map, icon: image}),
				new google.maps.Marker({ title: "ΤΣΕΡΙ", position: coords[9], map: map, icon: image}),
				
				new google.maps.Marker({ title: "ΜΑΚΕΔΟΝΙΤΙΣΣΑ", position: coords[10], map: map, icon: image}),
				new google.maps.Marker({ title: "ΚΑΤΩ ΔΕΥΤΕΡΑ", position: coords[11], map: map, icon: image}),
				new google.maps.Marker({ title: "ΚΑΨΑΛΟΣ", position: coords[12], map: map, icon: image}),
				new google.maps.Marker({ title: "ΠΑΡΑΛΙΜΝΙ", position: coords[13], map: map, icon: image})
		];

 		contentString = [
				'<span class="map-descr">ΑΓΙΟΙ ΟΜΟΛΟΓΗΤΕΣ<br />Κάσου 14<br />Τ: 22 317 021</span>',
				'<span class="map-descr">ΑΚΡΟΠΟΛΗ<br />Αρμενίας 45<br />Τ: 22 316 777</span>',
				'<span class="map-descr">ΑΓΛΑΝΤΖΙΑ<br />Λεωφ. Αγλαντζιάς 67<br />Τ: 22 337 000</span>',
				'<span class="map-descr">ΑΓΙΟΣ ΔΟΜΕΤΙΟΣ<br />Γρηγόρη Αυξεντίου 107<br />Τ: 22 772 630</span>',
				'<span class="map-descr">ΛΑΤΣΙΑ<br />Λεωφ. Μακαρίου 40<br />Τ: 22 488 077</span>',
				'<span class="map-descr">ΛΑΚΑΤΑΜΙΑ<br />Παντελή Κατελάρη 5</br />Τ: 22 371 444</span>',
				'<span class="map-descr">ΠΑΛΛΟΥΡΙΩΤΙΣΣΑ<br />Αγίου Ανδρέου 46<br />Τ: 22 344 199</span>',
				'<span class="map-descr">ΚΟΚΚΙΝΟΤΡΙΜΙΘΙΑ<br />Αρχ. Μακαρίου Γ’ 25<br />Τ: 22 834 888</span>',
				'<span class="map-descr">ΣΤΑΥΡΟΣ (Στρόβολος)<br />Λεωφ. Σταυρού 50<br />Τ: 22 450 111</span>',
				'<span class="map-descr">ΤΣΕΡΙ<br />Λεωφ. Στροβόλου 39<br />Τ: 22 386 555</span>',
				'<span class="map-descr">ΜΑΚΕΔΟΝΙΤΙΣΣΑ<br />Λυκαβητού 53 Γ-Δ<br />Τ: 22 464 888</span>',
				'<span class="map-descr">ΚΑΤΩ ΔΕΥΤΕΡΑ<br />Αναστάση Λεβέντη 3<br />Τ: 22 455 111</span>',
				'<span class="map-descr">ΚΑΨΑΛΟΣ<br />Λεωφ. Αγίας Φυλάξεως 105Β<br />Τ: 25 870 222</span>',
				'<span class="map-descr">ΠΑΡΑΛΙΜΝΙ<br />1ης Απριλίου 28<br />Τ: 23 821 888</span>'
	    ];

        infowindow = [
                new google.maps.InfoWindow({content: contentString[0]}),
                new google.maps.InfoWindow({content: contentString[1]}),
	            new google.maps.InfoWindow({content: contentString[2]}),
	            new google.maps.InfoWindow({content: contentString[3]}),
	            new google.maps.InfoWindow({content: contentString[4]}),

	            new google.maps.InfoWindow({content: contentString[5]}),
	            new google.maps.InfoWindow({content: contentString[6]}),
	            new google.maps.InfoWindow({content: contentString[7]}),
	            new google.maps.InfoWindow({content: contentString[8]}),
	            new google.maps.InfoWindow({content: contentString[9]}),

	            new google.maps.InfoWindow({content: contentString[10]}),
	            new google.maps.InfoWindow({content: contentString[11]}),
	            new google.maps.InfoWindow({content: contentString[12]}),
	            new google.maps.InfoWindow({content: contentString[13]})
		];

		google.maps.event.addListener(markers[0], 'click', function() { markerPopup(0) });
		google.maps.event.addListener(markers[1], 'click', function() { markerPopup(1) });
		google.maps.event.addListener(markers[2], 'click', function() { markerPopup(2) });
		google.maps.event.addListener(markers[3], 'click', function() { markerPopup(3) });
		google.maps.event.addListener(markers[4], 'click', function() { markerPopup(4) });

		google.maps.event.addListener(markers[5], 'click', function() { markerPopup(5) });
		google.maps.event.addListener(markers[6], 'click', function() { markerPopup(6) });
		google.maps.event.addListener(markers[7], 'click', function() { markerPopup(7) });
		google.maps.event.addListener(markers[8], 'click', function() { markerPopup(8) });
		google.maps.event.addListener(markers[9], 'click', function() { markerPopup(9) });

		google.maps.event.addListener(markers[10], 'click', function() { markerPopup(10) });
		google.maps.event.addListener(markers[11], 'click', function() { markerPopup(11) });
		google.maps.event.addListener(markers[12], 'click', function() { markerPopup(12) });
		google.maps.event.addListener(markers[13], 'click', function() { markerPopup(13) });

	}catch(err){
		if (console) console.log("Google Maps not defined");
	} 
}

function markerPopup(i){
	for (var j=0;j<13;j++) infowindow[j].close();
	infowindow[i].open(map,markers[i]);
}

