var tabImgGalerie = new Array();
var nbImg		  = 0;
var idImg		  = 0;

function initialize(lat,lng,contenu_bulle) {

	if (GBrowserIsCompatible()) {
      // define the crosshair tile layer and its required functions
      var crossLayer = new GTileLayer(new GCopyrightCollection(""), 0, 15);
      crossLayer.getTileUrl =  function(tile, zoom) {
        return "./include/tile_crosshairs.png";
      }
      crossLayer.isPng = function() {return true;}

      // Create a new map type incorporating the tile layer
      var layerTerCross = [ G_PHYSICAL_MAP.getTileLayers()[0],
                            crossLayer ];
      var mtTerCross = new GMapType(layerTerCross,
                                    G_PHYSICAL_MAP.getProjection(), "Ter+");

      var map = new GMap2(document.getElementById("carte"),
          { size: new GSize(468,468) } );
      map.addMapType(G_PHYSICAL_MAP);
	  map.setMapType(G_SATELLITE_MAP);
      map.addMapType(mtTerCross);
	  var point = new GLatLng(lat, lng);
      map.setCenter(point, 16);
	  var marker = new GMarker(point);
	  map.addOverlay(marker);

	  marker.openInfoWindowHtml(contenu_bulle);
      map.addControl(new GLargeMapControl())

      var mapControl = new GHierarchicalMapTypeControl();

      // Set up map type menu relationships
      mapControl.clearRelationships();
      mapControl.addRelationship(G_SATELLITE_MAP, G_HYBRID_MAP, "Labels", false);
      mapControl.addRelationship(G_PHYSICAL_MAP, mtTerCross, "Crosshairs");

      // Add control after you've specified the relationships
      map.addControl(mapControl);

    }
}

function preloadImages() {
var d=document; if(d.images){ if(!d.p) d.p=new Array();
var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}

function affichage_popup(nom_de_la_page, nom_interne_de_la_fenetre)
{
window.open (nom_de_la_page, nom_interne_de_la_fenetre, config='height=374, width=499, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no')
}

function insertSWF(fichier,w,h) {
	document.write('<object type="application/x-shockwave-flash" width="'+w+'" height="'+h+'" data="'+fichier+'">\n');
	document.write('<param name="movie" value="'+fichier+'" />\n');
	document.write('<param name="wmode" value="transparent" />');
	document.write('</object>\n');
}

function setTabImgGalerie(tab){
	if(tab.length > 0){
		nbImg = tab.length;
		tabImgGalerie = tab;
		if(document.getElementById('fade-example-1-zoom')){
			document.getElementById('fade-example-1-zoom').href = tabImgGalerie[0];
		}
	}
}

function nextImg(){
	if(idImg == eval(nbImg-1)){
		idImg = 0;
	}else{
		idImg = idImg + 1;
	}
	if(document.getElementById('fade-example-1-zoom')){
		document.getElementById('fade-example-1-zoom').href = tabImgGalerie[idImg];
	}
}

function previousImg(){
	if(idImg == 0){
		idImg = eval(nbImg-1);
	}else{
		idImg = idImg - 1;
	}
	if(document.getElementById('fade-example-1-zoom')){
		document.getElementById('fade-example-1-zoom').href = tabImgGalerie[idImg];
	}
}
