// var center_latitude = 33.6;
// var center_longitude = -117.1;

var start_zoom = 13;
var map;


function addMarker( latitude, longitude, i ) 
{
    var marker = new GMarker( new GLatLng( latitude, longitude ) );

    if ( document.getElementById( 'photo_tab-' + i ) )
    { 
	var photo_html = document.getElementById( 'photo_tab-' + i );
    }

    var species_html = document.getElementById( 'details_tab-' + i );

    if ( photo_html )
    {
	var tabs = 
	[
		new GInfoWindowTab( 'Photo', photo_html ),
		new GInfoWindowTab( 'Species List', species_html ),
	];
    }
    else
    {
	var tabs = 
	[
		new GInfoWindowTab( 'Species List', species_html ),
	];
    }

    marker.bindInfoWindowTabs( tabs, { maxWidth: 350 } );
    map.addOverlay( marker );
}


function init() 
{
    // var map_div = jQuery( '#gmap' );
    var map_div = document.getElementById( 'gmap' );

    if( GBrowserIsCompatible() )
    {
        map = new GMap2( map_div, 
	{
		mapTypes: [ G_NORMAL_MAP, G_SATELLITE_MAP, G_HYBRID_MAP, G_PHYSICAL_MAP, G_SATELLITE_3D_MAP ]  
	});

        map.addControl( new GSmallMapControl() );
        map.addControl( new GMapTypeControl() );
        map.setCenter( new GLatLng( center_latitude, center_longitude ), start_zoom, G_PHYSICAL_MAP );

        for( i in markers )
        {
            addMarker( markers[ i ].latitude, markers[ i ].longitude, i );
        }
    }
}


window.onload = init;
window.onunload = GUnload;

