var map;

function addMarker (lat, lng, mapIconPath, name) {
    var latlng = new google.maps.LatLng(lat, lng);
	setMarker(latlng, mapIconPath, name);
}

function buildMap (lat, lng, zoom, maptype, show_marker, infowindow_content) {
	var latlng = new google.maps.LatLng(lat, lng);
	var maptypeid = null;
    var myOptions = {
        zoom: zoom,
        center: latlng,
        mapTypeId: google.maps.MapTypeId[maptype.toUpperCase()] || google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById("map"), myOptions);
	if(show_marker) setMarker(latlng, '', show_marker);
	if(infowindow_content) openInfoWindow(latlng, infowindow_content);
}
function openInfoWindow (latlng, content) {
    var infowindow = new google.maps.InfoWindow({
        content: content,
        position: latlng
    });
    infowindow.open(map);
}

function setMarker (latlng, mapIconPath, name) {
    var marker = new google.maps.Marker({
      position: latlng,
      map: map,
      icon: mapIconPath,
      title:name
    });
}

function googleMapsV3Initialize(lat, lng, zoom, maptype, name, content) {
	buildMap(lat, lng, zoom, maptype, name, content)
}
