
function getElementById(id) {
	if (document.all) {
		return document.all[id];
	
	} else if (document.layers) {
		return document.layers[id];
	
	} else if (document.getElementById) {
		return document.getElementById(id);
		
	}
}

function unloadMaps() {
	GUnload();
}

// POINTS AND MARKERS

function createMarker(point,html, icon, propId) { 
	var marker = new GMarker(point, icon);
	
	if (propId != '' && propId != undefined) {
		var propElm = 'prop_' + propId;
		html += ""; 
		
		GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml(html);
		});
		
		GEvent.addListener(marker,"click", function() {
			marker.openInfoWindowHtml(html);									
		});  
		
/*		GEvent.addListener(marker, "mouseout", function() {
			getElementById(propElm).style.background = "#ffffff";
		});
*/		
	}      
	
	return marker;
}

function createMarkerFromLongLat(icon, lon, lat, html, propId) {
	var point = new GPoint(lon,lat);
	var marker = createMarker(point,html, icon, propId);
	
	return marker;
}

function createMarkeFromPoint(icon, point) {
	var marker = new GMarker(point, icon);
	
	return marker;
}

function createMarkerFromAddress(icon, address, map, html, propId) {
	var geocoder = new GClientGeocoder();

	geocoder.getLatLng(
	    address,
	    function(point) {
	      if (!point) {
	        // do nothing
	      } else {
	      	var marker = createMarker(point,html, icon, propId);      
	        map.addOverlay(marker);
	      }
	    }
	  );
}

function createCenterFromAddress (address, map) {
	var geocoder = new GClientGeocoder();
	
	geocoder.getLatLng(
		address,
		function (point) {
			if (!point) {
			 	document.getElementById('googleMap').style.display = 'none';
			} else {
				map.setCenter(point, 11);
			} 
		}
	);	

}

// LOAD MAP
function loadFirstMap (loadMap) {
		loadPropertyMap('propertyMap');
}
