function returnto() { map.returnToSavedPosition(); }
var map, cluster;

function myOnLoad() {
	if (GBrowserIsCompatible()) {
		map=new GMap2(document.getElementById('map'));
		map.setCenter(new GLatLng(0, 0), 0, G_NORMAL_MAP);
		
		map.addControl(new GMapTypeControl(), new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, 7)));
		map.addControl(new GLargeMapControl(), new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, 28)));
		
		var marker, markersArray=[];
		
		/*	json data already loaded from marker_data_01.php by using
			<script type="text/javascript" src="marker_data_01.php"></script>
			on simple.php page
		*/
		
		for (var i=0; i<json.length; i++) {
			marker=newMarker(new GLatLng(json[i].lat, json[i].lng), json[i].id, json[i].thumb, json[i].quick, json[i].address, json[i].county, json[i].size, json[i].price, json[i].watermark2, json[i].name);
			markersArray.push(marker);
		}
		
		cluster=new ClusterMarker(map, { markers:markersArray } );
		cluster.fitMapToMarkers();
		
		map.savePosition();	//	enables the large map control centre button to return the map to initial view
		
		//	add an HtmlControl to enable toggling of the ClusterMarker cluster function
		//	see http://googlemapsapi.martinpearman.co.uk/htmlcontrol for more info on HtmlControl
		//var html='<div class="htmlControl" style="padding:0px 3px 3px 3px">Enable clustering: <input type="checkbox" checked="checked" onclick="toggleClustering()" /></div>';
		//var control=new HtmlControl(html);
		//map.addControl(control, new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(7,7)));
	}
}

function newMarker(markerLocation, markerId, markerThumb, markerQuick, markerAddress, markerCounty, markerSize, markerPrice, markerWatermark2, markerName) {
	var marker=new GMarker(markerLocation, {title:''+markerName+''});
	GEvent.addListener(marker, 'click', function() {
		marker.openInfoWindowHtml('<table width=470><tr><td><a href=http://www.ohiolandconnection.com/property1.php?category_id='+markerId+'><div id=watermark_box><img src=http://www.ohiolandconnection.com/'+markerThumb+' height=110 border=0/><img src=http://www.ohiolandconnection.com/photos/'+markerWatermark2+' class=watermark height=110/></div></a></td><td valign=top><table cellpadding=0 cellspacing=0 border=0><tr><td valign=top><a href=http://www.ohiolandconnection.com/property1.php?category_id='+markerId+'><h2><font color=#a15a2c>'+markerName+'</font></h2></a></td></tr><tr><td width=210><b>'+markerQuick+'</b>  <a href=http://www.ohiolandconnection.com/property1.php?category_id='+markerId+'>MORE</a></td></tr><tr><td valign=bottom><table width=250><tr><td bgcolor=#CCCCCC>Address:</td><td bgcolor=#EEEEEE width=200>'+markerAddress+'</td></tr><tr><td bgcolor=#CCCCCC>County:</td><td bgcolor=#EEEEEE>'+markerCounty+'</td></tr><tr><td bgcolor=#CCCCCC>Size:</td><td bgcolor=#EEEEEE>'+markerSize+'</td></tr><tr><td bgcolor=#CCCCCC>Price:</td><td bgcolor=#EEEEEE>'+markerPrice+'</td></tr></table></td></tr></table></td></tr></table>');
				
	});
	return marker;
}

function toggleClustering() {
	cluster.clusteringEnabled=!cluster.clusteringEnabled;
	cluster.refresh(true);	//	true required to force a full update of the markers - otherwise the update would occur next time that the map is zoomed or the active markers change
}

