	function setMainPropCoord(lat, lng, isMain) {
		nCntMkr +=1;  //Increment counter - when reaches total, then show Map
		if (isMain || !isPortfolio) {
			mainLat = lat;
			mainLng = lng;
		}
		if (nCntMkr == nNumProps) loadMap();
	}

function loadMap(){
    if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("divMap"));
		map.addControl(new GSmallMapControl());
		//Set center as main property
		if (!isPortfolio) {
			map.setCenter(new GLatLng(mainLat, mainLng), nZoomLevel);				
		}
		else
			map.setCenter(new GLatLng(0,0), 0);
		var mgr = new GMarkerManager(map);  
		if (aPoints && aPoints.length > 0) {
			var bounds = new GLatLngBounds();
			for(var i=0; i < aPoints.length; i++) { //Loop and add the markers
				map.addOverlay(aPoints[i]);
				//Each time a point is read, extend the bounds to include that point. 
				if (isPortfolio) bounds.extend(aPoints[i].getPoint());
			}

			if (isPortfolio) {
				//When all the points have been processed, the zoom level can be set to fit the points. 
				map.setZoom(map.getBoundsZoomLevel(bounds));
				//The centre can be calculated by taking the average latitude and longitude from opposite corners of the bounds. 
				var clat = (bounds.getNorthEast().lat() + bounds.getSouthWest().lat()) /2;
				var clng = (bounds.getNorthEast().lng() + bounds.getSouthWest().lng()) /2;
				//document.getElementById("hdnLat").value = clat;
				//document.getElementById("hdnLon").value = clng;					
				map.setCenter(new GLatLng(clat, clng));	
			}
			//if(map.isLoaded()){
			//	document.getElementById('adv').disabled = false;
			//	document.getElementById('progress').style.display = 'none';
			//	window.status = 'Loaded '+ arr.length + ' markers.';
			//}						
			map.savePosition();
			mgr.addMarkers(aPoints);				
			mgr.refresh();	
		}
		else {
			document.getElementById("divNoMap").style.display = "";
			document.getElementById("divMap").style.display = "none";
		}
	} 
	else {
		document.getElementById("divNoMap").style.display = "";
		document.getElementById("divMap").style.display = "none";
	}
}

