window.onload=initialize;

// initialisation de certaines variables
var map = null;
var infobox = null;




// cette fonction crée un marker sur la carte	
function createMarker(latlng, name, html,icone) {
	    var contentString = html;
	    var marker = new google.maps.Marker({
	        position: latlng,
	        map: map,
	        zIndex: Math.round(latlng.lat()*-100000)<<5,
	        icon:icone
	        });
	
	    google.maps.event.addListener(marker, 'click', function() {
	        infobox.setContent(contentString); 
	        infobox.open(map,marker);
	        });
	    
} 



// cette fonction est lancée sur window.onload
function initialize()
{
        // initialisation de la bulle
        //infowindow = new google.maps.InfoWindow();
        infobox = new InfoBox({
             content: document.getElementById("infobox"),
             disableAutoPan: false,
             maxWidth: 500,
             pixelOffset: new google.maps.Size(-18, -48),
             alignBottom: true,
             boxStyle: {
                opacity: 1,
                width: "350px"
            },
            zIndex: null,
            closeBoxMargin: "0px",
            closeBoxURL: "http://www.google.com/intl/en_us/mapfiles/close.gif",
            infoBoxClearance: new google.maps.Size(1, 1)
        });
        
        // le centre de la carte avant le fitBounds
	var _center = new google.maps.LatLng(44.798661, 1.203961);
          
	// création d'une icone publiman (url,size,origin,hotspot)
	var publimanIcon = new google.maps.MarkerImage("xprod/images/map-marker.png",new google.maps.Size(39, 48),new google.maps.Point(0,0),new google.maps.Point(18, 31));
        // initialisation des options de la carte
	var myOptions = {
            zoom:7,
	    center: _center,
	    mapTypeControl: true,
	    mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
	    navigationControl: true,
	    mapTypeId: google.maps.MapTypeId.TERRAIN
	}
        // création de la carte
	map = new google.maps.Map(document.getElementById("map"),myOptions);
        // écouteur pour la fermeture de la bulle
	google.maps.event.addListener(map, 'click', function() {
        infobox.close();
	});
        
                    
		  // préparation du contenu HTML à afficher dans la bulle
                  //////////////////////////////////////////////////////////////////// ce HTML sera stylé dans snippets.css
		  var html='<div id="htmlBulle">'+
		  			'<img class="left" src="xprod/images/thumb-printer.png" alt="visuel imprimante"/>'+
					  	'<ul class="left">'+
					  			'<li class="rose">SAEC <strong>PUBLIMAN</strong></li>'+
					  			'<li>ZAE de Pech Mercier</li>'+
					  			'<li>24250 CENAC</li>'+
					  			'<li>FRANCE</li>'+
					  			'<li>tel. 0033 540 161 267</li>'+
					  			'<li>fax 0033 553 590 413</li>'+
					  			'<li>email - <a href="mailto:info@publiman.fr" class="rose">info@publiman.fr</a></li>'+
					  	'</ul>'+
					'</div>';
		  // création du marker
		  var marker = createMarker(new google.maps.LatLng(44.798661, 1.203961),"Publiman",html,publimanIcon);

}

