var centerLatitude = 42.55522997925517;
var centerLongitude = -82.8837776184082;
var description = "<b>Aadvanced Machinery</b><br /><i>Quality & Service First</i><br />35044 Automation Drive<br />Clinton Township, MI 48035 USA<br />(586) 790-1717 | Fax: (586) 790-1871<br />Email: service@aadvancedmach.com";
var startZoom = 12;
var createMapManager = false;
var mapManager = null;
var map = null;

function addMarker( latitude, longitude, description ) {
	createMarker( latitude, longitude, description, null );
}

function createMarker( latitude_IN, longitude_IN, description_IN, icon_IN )
{
    // return reference
    var marker_OUT = null;
    
    if ( ( icon_IN != null ) && ( icon_IN != "" ) )
	{
		// look up the icon in the iconHash
		var icon = iconHash[ icon_IN ]
		//alert ( "icon_IN = " + icon_IN + ", icon URL = " + icon.image );
	   	marker_OUT = new GMarker( new GLatLng( latitude_IN, longitude_IN ), icon );
    }
	else
	{
    	marker_OUT = new GMarker(new GLatLng(latitude_IN, longitude_IN));
    }

    GEvent.addListener(marker_OUT, 'click',
        function() {
            marker_OUT.openInfoWindowHtml(description_IN);
        }
    );

	if ( mapManager != null )
	{
		mapManager.addMarker( marker_OUT, 1 );
	}
	else
	{
		map.addOverlay( marker_OUT );
	}
    
    return marker_OUT;
} //-- end function createMarker() --//

function loadMapManager() {}

function load()
{
    if (GBrowserIsCompatible()) {	
        map = new GMap2(document.getElementById("map"));
        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(centerLatitude, centerLongitude), startZoom);

		if ( createMapManager == true )
		{
			mapManager = new GMarkerManager( map );
			loadMapManager();
			
		    GEvent.addListener( map, 'moveend',
		        function() {
		            mapManager.refresh();
		        }
		    );
		    
		    GEvent.addListener( map, 'zoomend',
		        function( oldLevel_IN, newLevel_IN ) {
		            mapManager.refresh();
		        }
		    );
		}

        if ( ( description != null ) && ( description != "" ) )
        {
        	addMarker(centerLatitude, centerLongitude, description);
       	}
    }
}

addLoadEvent( load );