window.addEvent('load', function() {
  if (GBrowserIsCompatible()) {
	var map = new GMap2(document.getElementById("map_canvas"));
	map.setCenter(new GLatLng(1.3319722944135322, 103.8153076171875), 13);
	map.setZoom(11);				
	map.addControl(new GLargeMapControl());
	map.addControl(new GMapTypeControl());

	// Create a base icon for all of our markers that specifies the
	// shadow, icon dimensions, etc.
	var baseIcon = new GIcon();
	baseIcon.shadow = "images/markers/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);

	// Creates a marker whose info window displays the letter corresponding
	// to the given index.
	function createMarker(point, description, id) {
	  // Create a lettered icon for this point using our icon class
	  letter = "D";
	  var letteredIcon = new GIcon(baseIcon);
	  letteredIcon.image = "images/markers/marker" + letter + ".png";

	  // Set up our GMarkerOptions object
	  markerOptions = { icon:letteredIcon };
	  var marker = new GMarker(point, markerOptions);

	  GEvent.addListener(marker, "click", function() {
		map.panTo(marker.getPoint(), 1000);								   
	  	var dlink = 'index.php?option=com_content&amp;task=view&amp;Itemid=35&amp;id=' + id;
		var message = '<span style="font-size: 8px; line-height: 9px;">' + description + '<br /><a href="' + dlink + '">Click to see more details.</a></span>';
		marker.openInfoWindowHtml(message);
	  });
	  
	  GEvent.addListener(marker, "infowindowclose", function() {
		map.panTo(new GLatLng(1.3319722944135322, 103.8153076171875), 1000);
	  });	  	  
	  
	  return marker;
	}

	// Add 10 markers to the map at random locations
	var dcoor = new Array(
	'1.374962,103.888602',
	'1.384009,103.843472',
	'1.37800758130457, 103.84371757507324',
	'1.441222,103.789274',
	'1.435128,103.792224',
	'1.432048,103.839072',
	'1.354673,103.889856',
	'1.326825,103.855051',
	'1.351189,103.872838',
	'1.316381,103.895239',
	'1.321118,103.881782',
	'1.324679,103.935236',
	'1.364571,103.961613',
	'1.342337,103.95134',
	'1.3152758,103.8738215',
	'1.346647,103.938573',
	'1.349252,103.748151',
	'1.314189,103.785739',
	'1.377838,103.77401',
	'1.316868,103.766782',
	'1.350365,103.717361',
	'1.3467,103.699321',
	'1.379691,103.751627',
	' 1.369425,103.858142');
	
var ddescription = new Array(
'NKF Hougang-Punggol Dialysis Centre<br />628 Hougang Ave 8<br />#01-108 S530628',
'Japan Airlines<br />NKF Dialysis Centre<br />17 Ang Mo Kio Ave 9 #03-01<br />Ang Mo Kio Hospital Ltd S569766',
'Western Digital<br />NKF Dialysis Centre<br />633 Ang Mo Kio Ave 6 #01-5155 S560633',
'Thong Teck Sian Tong Lian Sin Sia<br />NKF Dialysis Centre<br />Blk 825 Woodlands Street 81<br />#01-30 Singapore 730825',
'NKF Dialysis Centre<br />365 Woodlands Avenue 5<br />#01-490 Singapore 730365',
'Toa Payoh Seu Teck Sean Tong<br />NKF Dialysis Centre<br />Blk 203 Yishun St 21 #01-239<br />Singapore 760203',
'Singapore Buddhist Welfare Services<br />NKF Dialysis Centre<br />Blk 114 Hougang Ave 1 #01-1298<br />Singapore 530114',
'Tay Choon Hye<br />NKF Dialysis Centre<br />81 Kim Keat Road Singapore 328836',
'Insurance and Financial Practitioners <br />Association of Singapore (IFPAS)<br />NKF Dialysis Centre<br />Blk 201 Serangoon Central #01-30 Singapore 550201',
'Singapore Airlines<br />NKF Dialysis Centre<br />Blk 225 Toa Payoh Lor 8 #01-54 Singapore 310225',
'Hong Leong<br />NKF Dialysis Centre<br />Blk 102 Aljunied Cres #01-265 Singapore 380102',
'Singapore Pools<br />NKF Dialysis Centre<br />Blk 27 New Upper Changi Road<br />#01-694 Singapore 460027',
'Tampines Chinese Temple<br />NKF Dialysis Centre<br />Blk 180 Pasir Ris Street 11 #01-06<br />Singapore 510180',
'Kwan Im Thong Hood Cho Temple<br />NKF Dialysis Centre<br />101 Simei St 1 #01-892 S520101',
'Sakyadhita<br />NKF Dialysis Centre<br />Blk 19 Upper Boon Keng Road<br />#01-1220 Singapore 380019',
'National Trade Union Congress/Singapore Pools<br />NKF Dialysis Centre<br />Blk 935 Tampines St 91 #01-333 Singapore 520935',
'NTUC Income<br />NKF Dialysis Centre<br />Blk 103 Bukit Batok Central #01-237 Singpore 650103',
'Bukit Merah Woh-Hup-NKF Dialysis Centre<br />Blk 1 Ghim Moh Road,#01-358, Singapore 270001',
'New Creation Church<br />NKF Dialysis Centre<br />Blk 274 Bangkit Rd #01-54 Singapore 670274',
'Singapore Armed Forces<br />NKF Dialysis Centre<br />Blk 326 Clementi Ave 5 #01-175 Singapore 120326',
'Singapore Armed Forces<br />NKF Dialysis Centre<br />Blk 536 Jurong West St 52 #01-497 Singapore 640536',
'Sheng Hong Temple<br />NKF Dialysis Centre<br />Blk 744 Jurong West St 73 #01-19 Singapore 640744',
'Leong Hwa Chan Si Temple<br />NKF Dialysis Centre<br />Blk 113 Teck Whye Lane #01-666 Singapore 680113',
'Pei Hwa Foundation-NKF Dialysis Centre (Ang Mo Kio)<br />NKF Dialysis Centre<br />Blk 565 Ang Mo Kio Avenue 3 #01-3401 Singapore 560565');

var did = new Array(239,124,123,122,121,120,119,118,117,116,115,114,113,112,111,110,109,108,107,106,105,104,103,237);

	for (var i = 0; i < dcoor.length; i++) {
	  eval('var point = new GLatLng(' + dcoor[i] + ');');
	  map.addOverlay(createMarker(point, ddescription[i], did[i]));
	}
  }
}
);

