//<![CDATA[
window.onload = onPageLoad;
// JavaScript 2005 Peter Jones, PixelDevelopment.com

var map;
var pointTitle = [];
var pointDetail = [];
var pointInfo = [];
var pointLat = [];
var pointLon = [];

pointTitle[0]= 'Xag&#295;ra';
pointDetail[0]= '<div style="margin 0 auto; text-align:center"><div style="margin 0 auto; text-align:center"><a href="http://www.justice.gov.mt/" target="_blank">Xag&#295;ra<br \/><img src="img/icons/xaghra.png" height="80px" width="72px" \/><br \/><\/a><\/div><\/div><div style="clear:both;"><\/div><div style="clear:both;"><\/div>';
pointInfo[0]= '';
pointLat[0]= 36.054303;
pointLon[0]= 14.274759;

pointTitle[1]= 'G&#295;arb';
pointDetail[1]= '<div style="margin 0 auto; text-align:center"><div style="margin 0 auto; text-align:center"><a href="http://www.justice.gov.mt/" target="_blank">G&#295;arb<br \/><img src="img/icons/gharb.png" height="80px" width="72px" \/><br \/><\/a><\/div><\/div><div style="clear:both;"><\/div>';
pointInfo[1]= '';
pointLat[1]= 36.066862;
pointLon[1]= 14.198456;

pointTitle[2]= 'G&#295;anjsielem';
pointDetail[2]= '<div style="margin 0 auto; text-align:center"><div style="margin 0 auto; text-align:center"><a href="http://www.ghajnsielem.com/" target="_blank">G&#295;anjsielem<br \/><img src="img/icons/ghajnsielem.png" height="80px" width="72px" \/><br \/><\/a><\/div><\/div><div style="clear:both;"><\/div>';
pointInfo[2]= '';
pointLat[2]= 36.029401;
pointLon[2]= 14.280566;

pointTitle[3]= 'Xewkija';
pointDetail[3]= '<div style="margin 0 auto; text-align:center"><div style="margin 0 auto; text-align:center"><a href="http://www.xewkija.gov.mt/" target="_blank">Xewkija<br \/><img src="img/icons/Xewkija.png" height="80px" width="72px" \/><br \/><\/a><\/div><\/div><div style="clear:both;"><\/div>';
pointInfo[3]= '';
pointLat[3]= 36.035219;
pointLon[3]= 14.277334;

pointTitle[4]= 'M&#289;arr';
pointDetail[4]= '<div style="margin 0 auto; text-align:center"><div style="margin 0 auto; text-align:center"><a href="http://www.mgarr.gov.mt/" target="_blank">M&#289;arr<br \/><img src="img/icons/mgarr.png" height="80px" width="72px" \/><br \/><\/a><\/div><\/div><div style="clear:both;"><\/div>';
pointInfo[4]= '';
pointLat[4]= 35.906401;
pointLon[4]= 14.362026;

pointTitle[5]= 'Pembroke';
pointDetail[5]= '<div style="margin 0 auto; text-align:center"><div style="margin 0 auto; text-align:center"><a href="http://www.pembroke.gov.mt/" target="_blank">Pembroke<br \/><img src="img/icons/pembroke.png" height="80px" width="72px" \/><br \/><\/a><\/div><\/div><div style="clear:both;"><\/div>';
pointInfo[5]= '';
pointLat[5]= 35.934403;
pointLon[5]= 14.475242;

pointTitle[6]= 'G&#295;arg&#295;ur';
pointDetail[6]= '<div style="margin 0 auto; text-align:center"><div style="margin 0 auto; text-align:center"><a href="http://www.gharghur.gov.mt/" target="_blank">G&#295;arg&#295;ur<br \/><img src="img/icons/gharghur.png" height="80px" width="72px" \/><br \/><\/a><\/div><\/div><div style="clear:both;"><\/div>';
pointInfo[6]= '';
pointLat[6]= 35.921258;
pointLon[6]= 14.451951;

pointTitle[7]= 'Naxxar';
pointDetail[7]= '<div style="margin 0 auto; text-align:center"><div style="margin 0 auto; text-align:center"><a href="http://www.naxxar.com/" target="_blank">Naxxar<br \/><img src="img/icons/naxxar.png" height="80px" width="72px" \/><br \/><\/a><\/div><\/div><div style="clear:both;"><\/div>';
pointInfo[7]= '';
pointLat[7]= 35.916657;
pointLon[7]= 14.453402;

pointTitle[8]= 'Msida';
pointDetail[8]= '<div style="margin 0 auto; text-align:center"><div style="margin 0 auto; text-align:center"><a href="http://www.imsida.gov.mt/" target="_blank">Msida<br \/><img src="img/icons/msida.png" height="80px" width="72px" \/><br \/><\/a><\/div><\/div><div style="clear:both;"><\/div>';
pointInfo[8]= '';
pointLat[8]= 35.896907;
pointLon[8]= 14.487619;

pointTitle[9]= 'Floriana';
pointDetail[9]= '<div style="margin 0 auto; text-align:center"><div style="margin 0 auto; text-align:center"><a href="http://www.florianalocalcouncil.com/" target="_blank">Floriana<br \/><img src="img/icons/floriana.png" height="80px" width="72px" \/><br \/><\/a><\/div><\/div><div style="clear:both;"><\/div>';
pointInfo[9]= '';
pointLat[9]= 35.89217913973105;
pointLon[9]= 14.504613876342773;

pointTitle[10]= 'Birkirkara';
pointDetail[10]= '<div style="margin 0 auto; text-align:center"><div style="margin 0 auto; text-align:center"><a href="http://www.visitbirkirkara.com/" target="_blank">Birkirkara<br \/><img src="img/icons/birkirkara.png" height="80px" width="72px" \/><br \/><\/a><\/div><\/div><div style="clear:both;"><\/div>';
pointInfo[10]= '';
pointLat[10]= 35.897781;
pointLon[10]= 14.469419;

pointTitle[11]= 'Mosta';
pointDetail[11]= '<div style="margin 0 auto; text-align:center"><div style="margin 0 auto; text-align:center"><a href="http://www.mosta.gov.mt/" target="_blank">Mosta<br \/><img src="img/icons/mosta.png" height="80px" width="72px" \/><br \/><\/a><\/div><\/div><div style="clear:both;"><\/div>';
pointInfo[11]= '';
pointLat[11]= 35.911020;
pointLon[11]= 14.429340;

pointTitle[12]= 'Birgu';
pointDetail[12]= '<div style="margin 0 auto; text-align:center"><div style="margin 0 auto; text-align:center"><a href="http://www.birgu.gov.mt/" target="_blank">Birgu<br \/><img src="img/icons/birgu.png" height="80px" width="62px" \/><br \/><\/a><\/div><\/div><div style="clear:both;"><\/div>';
pointInfo[12]= '';
pointLat[12]= 35.887194;
pointLon[12]= 14.523255;

pointTitle[13]= 'Bormla';
pointDetail[13]= '<div style="margin 0 auto; text-align:center"><div style="margin 0 auto; text-align:center"><a href="http://www.justice.gov.mt/" target="_blank">Bormla<br \/><img src="img/icons/bormla.png" height="80px" width="62px" \/><br \/><\/a><\/div><\/div><div style="clear:both;"><\/div>';
pointInfo[13]= '';
pointLat[13]= 35.880762;
pointLon[13]= 14.522091;

pointTitle[14]= 'Mqabba';
pointDetail[14]= '<div style="margin 0 auto; text-align:center"><div style="margin 0 auto; text-align:center"><a href="http://www.mqabba.gov.mt/" target="_blank">Mqabba<br \/><img src="img/icons/mqabba.png" height="80px" width="72px" \/><br \/><\/a><\/div><\/div><div style="clear:both;"><\/div>';
pointInfo[14]= '';
pointLat[14]= 35.850309;
pointLon[14]= 14.467192;

pointTitle[15]= 'Qormi';
pointDetail[15]= '<div style="margin 0 auto; text-align:center"><div style="margin 0 auto; text-align:center"><a href="http://www.qormi.gov.mt/" target="_blank">Qormi<br \/><img src="img/icons/qormi.png" height="80px" width="62px" \/><br \/><\/a><\/div><\/div><div style="clear:both;"><\/div>';
pointInfo[15]= '';
pointLat[15]= 35.88366;
pointLon[15]= 14.478723;

pointTitle[16]= 'Dingli';
pointDetail[16]= '<div style="margin 0 auto; text-align:center"><div style="margin 0 auto; text-align:center"><a href="http://www.dingli.gov.mt/" target="_blank">Dingli<br \/><img src="img/icons/dingli.png" height="80px" width="72px" \/><br \/><\/a><\/div><\/div><div style="clear:both;"><\/div>';
pointInfo[16]= '';
pointLat[16]= 35.864486;
pointLon[16]= 14.381292;

pointTitle[17]= 'Zebbug';
pointDetail[17]= '<div style="margin 0 auto; text-align:center"><div style="margin 0 auto; text-align:center"><a href="#" target="_blank">&#379;ebbug<br \/><img src="img/icons/zebbug.png" height="80px" width="52px" \/><br \/><\/a><\/div><\/div><div style="clear:both;"><\/div>';
pointInfo[17]= '';
pointLat[17]= 35.873056;
pointLon[17]= 14.441944;

var baseIcon = new GIcon();
//baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
baseIcon.shadow = "img/shadow50.png";
baseIcon.iconSize = new GSize(20, 34);
baseIcon.shadowSize = new GSize(37, 34);
baseIcon.iconAnchor = new GPoint(9, 34);
baseIcon.infoWindowAnchor = new GPoint(9, 2);
baseIcon.infoShadowAnchor = new GPoint(18, 25);

function createMarker(i, point, html) {
	var marker;
	var icon = new GIcon(baseIcon);
	var letter = String.fromCharCode("A".charCodeAt(0) + i);
	//icon.image = "http://www.google.com/intl/en_ALL/mapfiles/marker.png";
	icon.image = "img/marker.png";

	if (false) // i == 0)
		marker = new PdMarker(point);
	else
		marker = new PdMarker(point, icon);

	//if (pointTitle[i].length > 0)
		//marker.setTooltip(pointTitle[i]);

	//if (pointDetail[i].length > 0)
			//marker.setDetailWinHTML(pointDetail[i]);
	

	
	//marker.setHoverImage("http://www.google.com/mapfiles/dd-start.png");
	marker.setCursor("pointer"); // http://www.quirksmode.org/css/cursor.html
	//marker.setTitle(pointTitle[i]);
	GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml(pointDetail[i]);
	});
	

	return marker;
}

function onPageLoad() {
	map = new GMap2(document.getElementById("map"));
	map.setCenter(new GLatLng(35.937496,14.375416), 10);
//	map.setMapType(map.getMapTypes()[0]);
	map.addControl(new GSmallMapControl());
	map.addControl(new GMapTypeControl());

	for (i=0; i<pointTitle.length; i++)
	{
		var marker = createMarker(i, new GPoint(pointLon[i],pointLat[i]), pointTitle[i] + '<br/>' + pointInfo[i]);
		map.addOverlay(marker);
	}

	
	insertVersionIntoPage();
}

function insertVersionIntoPage() {
	var obj = document.getElementById("pdmarkerrevisions");
	if (obj)
		obj.innerHTML = getPdMarkerRevisionInfo();

	obj = document.getElementById("pdmarkerversion");
	if (obj)
		obj.innerHTML = getPdMarkerVersion() + " (Google Maps JS version: " + getGoogleMapsVersion() + ")";
}

function loadLotsOfMarkers(count, isPd) {
	var bounds = map.getBoundsLatLng();
	var width = bounds.maxX - bounds.minX;
	var height = bounds.maxY - bounds.minY;
	for (var i = 0; i < count; i++)
	{
		var point = new GPoint(bounds.minX + width * Math.random(),
						bounds.minY + height * Math.random());
		var marker;
		if (isPd)
			marker = new PdMarker(point);
		else
			marker = new GMarker(point);
		map.addOverlay(marker);
	}
}

function removeMarkers() {
	map.clearOverlays();
}


//]]>
