function createMap(map_id, lat, lng, zoom, map, type, scale, overview, map_type) {
    if(lat == undefined) {
	lat = 0.0;
    }
    if(lng == undefined) {
	lng = 0.0;
    }
    if(zoom == undefined) {
	zoom = 0;
    }
    if(map == undefined) {
	map = 'small';
    }
    if(type == undefined) {
	type = 'small';
    }
    if(scale == undefined) {
	scale = false;
    }
    if(overview == undefined) {
	overview = false;
    }
    if(map_type == undefined || map_type == 'map') {
	map_type = G_NORMAL_MAP;
    }
    else if(map_type == 'satellite') {
	map_type = G_SATELLITE_MAP;
    }

    // Create map
    var gmap = new GMap2(document.getElementById(map_id));
    // set center
    gmap.setCenter(new GLatLng(lat, lng), zoom, map_type);
    // map control
    if (map == 'large') {
	gmap.addControl(new GLargeMapControl());
    }
    else if (map == 'small') {
	gmap.addControl(new GSmallMapControl());
    }
    else if (map == 'zoom') {
	gmap.addControl(new GSmallZoomControl());
    }
    // map type control
    if (type == 'small') {
	gmap.addControl(new GMapTypeControl(true));
    }
    else if (type) {
	gmap.addControl(new GMapTypeControl());
    }
    // scale control
    if (scale) {
	gmap.addControl(new GScaleControl());
    }
    // overview control
    if (overview) {
	gmap.addControl(new GOverviewMapControl());
    }
    return gmap;
}

url = "http://www.amherstida.com"
// Create marker icon
var icon = new GIcon();
icon.image = url + "/flex-marker.png";
icon.shadow = url + "/gmap_shadow.png";
icon.iconSize = new GSize(20, 34);
icon.shadowSize = new GSize(37, 34);
icon.iconAnchor = new GPoint(9, 34);
icon.infoWindowAnchor = new GPoint(9, 2);

var iconMixed = new GIcon();
iconMixed.image = url + "/mixed-marker.png";
iconMixed.shadow = url + "/gmap_shadow.png";
iconMixed.iconSize = new GSize(20, 34);
iconMixed.shadowSize = new GSize(37, 34);
iconMixed.iconAnchor = new GPoint(9, 34);
iconMixed.infoWindowAnchor = new GPoint(9, 2);

var iconOffice = new GIcon();
iconOffice.image = url + "/office-marker.png";
iconOffice.shadow = url + "/gmap_shadow.png";
iconOffice.iconSize = new GSize(20, 34);
iconOffice.shadowSize = new GSize(37, 34);
iconOffice.iconAnchor = new GPoint(9, 34);
iconOffice.infoWindowAnchor = new GPoint(9, 2);

// Create center marker icon
var center_icon = new GIcon();
center_icon.image = url + "/centermarker.png";
center_icon.shadow = url + "/centermarker_shadow.png";
center_icon.iconSize = new GSize( 23 , 23 );
center_icon.shadowSize = new GSize( 29 , 29 );
center_icon.iconAnchor = new GPoint( 11 , 11 );

// Create markers and events
function createMarker(map, lat, lng) {
    var point = new GLatLng(lat, lng);
    var marker = new GMarker(point, icon);
    map.addOverlay(marker);
    return marker;
}

var markers = new Array();

function addMarker(map, marker_id, lat, lng, propType) {
    var marker;
    var point = new GLatLng(lat, lng);

    if (propType == 'Flex Use')
      marker = new GMarker(point, icon);
    else if (propType == 'Mixed Use')
      marker = new GMarker(point, iconMixed);
    else if (propType == 'Office Use')
      marker = new GMarker(point, iconOffice);

    map.addOverlay(marker);

    var f = function(){
		marker.openInfoWindowHtml(document.getElementById('marker_html_' + marker_id).innerHTML);
    };

    GEvent.addListener(marker, 'click', f);

	markers[marker_id] = marker;
}

function chooseProperty(proplist) {
	var property = proplist.value;
	markers[property].openInfoWindowHtml(document.getElementById('marker_html_' + property).innerHTML);
	showProperty(property);
}

function showProperty(id) {
	var size = markers.length;
	for (i = 0; i < size; i++) {
		document.getElementById('address_html_' + i).style.display = 'none';
	}
	document.getElementById('address_html_' + id).style.display = 'block';
}

function addCenterMarker(map) {
    var center_marker = new GMarker(map.getCenter(), center_icon);
    map.addOverlay(center_marker);

    GEvent.addListener(map , "moveend" , function() {
    map.removeOverlay(center_marker);
        center_marker = new GMarker(map.getCenter(), center_icon);
        map.addOverlay(center_marker);
    });
}

