var oMap;

function mapLoad() {
	if (GBrowserIsCompatible()) {
		oMap = new GMap2(document.getElementById("map"));
		var oCenter = new GLatLng(54, -4.5);
		oMap.addControl(new GSmallMapControl());
		oMap.setCenter(oCenter, 5);
		oMap.enableScrollWheelZoom();
		
		// Add projects
		addProject(51.494927, 0.014741, "Greenwich Millennium Village", "gmv.jpg", "With over 1100 homes occupied, we have gained real hands-on experience of sustainable development over the last 10 years.", "/projects/gmv.html");
		addProject(53.473520, -2.240991, "Macintosh Village - Green Building", "macintosh_village.jpg", "A test bed for low and zero carbon technologies in an innovative apartment block.", "/projects/macintosh.html");
		addProject(52.086389, -0.473571, "Wixams", "wixams.jpg", "A 4500 dwelling mixed use development for which planning consent was successfully obtained.", "/projects/wixams.html");
		addProject(51.528584,-0.379972, "Grand Union Village", "guv.jpg", "An 850 dwelling phased mixed use development incorporating a wide range of sustainability measures.", "/projects/guv.html");
		addProject(51.403757, 0.539789, "Chatham Maritime", "chatham.jpg", "Successfully secured EcoHomes certification on development phases over an eight year period.", "/projects/chatham.html");
		addProject(53.742848, -1.364622, "Allerton Bywater", "allerton.jpg", "Exacting HCA Millennium Community Standards were achieved on this former coalfield site.", "/projects/allerton.html");
		addProject(50.735844, -3.383617, "East Devon New Community", "eastdevon.jpg", "This successful planning application included one of the first schemes in the UK to use the Code for Sustainable Homes.", "/projects/east_devon.html");
		addProject(50.833657, -0.279765, "Ropetackle", "ropetackle.jpg", "EcoHomes Excellent was achieved for all dwellings on this high quality residential mixed tenure development.", "/projects/ropetackle.html");
		addProject(52.742437, 0.401902, "South Lynn Millennium Community", "southlynn.jpg", "Worked through the early design process to cost effectively achieve EcoHomes Excellent on completion.", "/projects/south_lynn.html");
		addProject(52.696397, -2.475094, "Telford Millennium Community", "telford.jpg", "Our fourth Millennium Community project met exacting HCA standards for all dwellings.", "/projects/telford.html");
	}
}

function addProject(fLat, fLong, sTitle, sImg, sDesc, sURL) {
	var oMarker = new GMarker(new GLatLng(fLat, fLong));
	GEvent.addListener(oMarker, "click", function() {
		windowOptions = { maxWidth: 200 };
		oMarker.openInfoWindowHtml('<div class="projtitle">' + sTitle + '</div><p class="projdesc"><img src="/_common/images/map/' + sImg + '" width="120" height="120" alt="' + sTitle + '" title="' + sTitle + '" class="projimg" />' + sDesc + '<a href="' + sURL + '">Read more ></a></p>', windowOptions);
	});
	oMap.addOverlay(oMarker);
}