/**
 * @author Pascal MARTIN
 * 
 * Copyright (c) 2008 Pascal MARTIN
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

var init = function ()
{
    google.load("maps", "2");
    google.setOnLoadCallback(initMap);
}; // init


var initMap = function ()
{
    var map = new google.maps.Map2(document.getElementById('map'));
    map.addControl(new GSmallMapControl());  // Contrôle de zoom, déplacement sur la carte
    
    var adresse = 'place bellecour, Lyon, france';
    var geocoder = new google.maps.ClientGeocoder();
    geocoder.getLatLng(adresse, function (coord) {
        map.setCenter(coord, 13);  // Centrage sur le point dont on a obtenu les coordonnées depuis l'adresse
        map.setMapType(G_HYBRID_MAP);  // Vue satellite + informations cartographiques
        
        // Ajout d'un marqueur sur la carte :
        var marker = new GMarker(coord);  // Création d'un marqueur localisé sur ce point
        
        var window = function() {
            var tabs = [
                    new GInfoWindowTab('Infos',
                            '<strong>Place Bellecour</strong>' +
                            '<br /><img src="images/place-bellecour-miniature.jpg" alt="" />' +
                            '<br /><a href="http://fr.wikipedia.org/wiki/Place_Bellecour">Voir l\'article sur Wikipedia (fr)</a>'
					   ),
					new GInfoWindowTab('Metro', 
                            'Metro A' +
							'<br />Metro D'
					   )
                ];
            
			marker.openInfoWindowTabsHtml(tabs);
        };
        GEvent.addListener(marker, "click", window);
        
        map.addOverlay(marker);  // Et ajout du marqueur à la carte
        
    });
    
}; // initMap
