

 var map;
 var geocoder;
 var infowindowShared;
 
 var markerTab = new Array();


//  var infowindowTab = new Array();   UNUSED
 
 var cat100 = new Array();
 var cat101 = new Array();
 var cat102 = new Array();
 var cat103 = new Array();
  
  var cat = new Array();
  
  cat[100] = cat100;
  cat[101] = cat101;
  cat[102] = cat102;
  cat[103] = cat103;
  
 var nMarker = 0;
   
function initializev3(mapID,centerLat,centerLng,InitzoomLevel) {

//alert(centerLat+','+centerLng);
 geocoder = new google.maps.Geocoder();


var myLatlng = new google.maps.LatLng(centerLat, centerLng);
var myOptions = {
  zoom: InitzoomLevel,
  center: myLatlng,
  mapTypeId: google.maps.MapTypeId.ROADMAP
};

var tmpmap = new google.maps.Map(document.getElementById(mapID),myOptions);
    

      
     //codeAddress("27 rue wurtz 91260 JUVISY, FRANCE");
infowindowShared = new google.maps.InfoWindow({
    content: 'nil'
}); 
  
map = tmpmap;
return;
    
}
 // ------------------------------------------------------------------------------------------------------------------


function show(tabid) {
      /*                    code pour ouvrir plusieurs infowindows
      alert(tabid);
      
      for(x in tabid) { 
             
        id = tabid[x];
      //   alert(id);
        if (id!=0) {infowindowTab[id].open(map,markerTab[id]);}
      }
      
      */
      var tmp="";
    for(x in markerTab) { 
            markerTab[x].setVisible(false);     // on efface tout
            tmp=tmp + ";" + x;
     }
      
      // alert(tmp);
            
       stat("clicinliste",tabid[1]);     
            
      for(x in tabid) {           
        id = tabid[x];
        //alert(id);
        if (id!=0) {markerTab[id].setVisible(true); }
      }
      
     infowindowShared.close();
      
      //infowindowShared.content="coucou";
      //alert("ok");
      //alert(n);
       //var data = $('#data' + n).html();
       //alert(data);
      // infowindowShared.content = data;
    //  infowindowShared.open(map,markerTab[n]); 
    /*
    infowindowTab[160].open(map,markerTab[160]);
    infowindowTab[159].open(map,markerTab[159]);
    infowindowTab[152].open(map,markerTab[152]);
    
    alert(infowindowTab[152].getContent());  
    alert(infowindowTab[159].getContent());    
    alert(infowindowTab[160].getContent());
    
    for(x in infowindowTab) {
      alert(x + "-->" + infowindowTab[x]);
    }
    
    return;
      */
      //alert(tabid);

     // alert(cat[cat1][n]); 
}
function OpenBulle(aMarker,aId) {
    var data = $('#data' + aId).html();
    infowindowShared.content = data;
    infowindowShared.open(map,markerTab[aId]);
    stat("openbulle",aId);
}

 // ------------------------------------------------------------------------------------------------------------------
      
 function selectcatmarker(categorie) {
                  // var :  markerTab[id_sql] => Object(marker)
                  //  if (cat1!=0) {cat[cat1][id]=1;}       cat[id_categorie][id_sql] = 1 ou 0 
    //alert(cat[categorie]);
          /*
         for(x in markerTab) {          //  x est donc un id_sql
          alert("markerTab : " + x + "-->" + markerTab[x]);
         }
         */
         
     for(x in markerTab) { 
        //alert(categorie + "-->" + x + "-" + cat[categorie][x]); 
        if (cat[categorie][x]==1) {   // l'objet 'x' est bien de type 'categorie'
            markerTab[x].setVisible(true);
        }
        else
        {
            markerTab[x].setVisible(false);
        }
     }
}      


 // ------------------------------------------------------------------------------------------------------------------
  function codeAddress(address,id) {

    geocoder.geocode( { 'address': address}, function(results, status) {
      if (status == google.maps.GeocoderStatus.OK) {
        map.setCenter(results[0].geometry.location);
        var pt = results[0].geometry.location ;
          updateurl="geocodeme.php?id=" + id + "&lat="+pt.lat()+"&lng="+pt.lng();
          ajax_go_generic_v3('UpdateBack', 0,updateurl);
          //alert(pt);
      } else {
        //alert("Geocode was not successful for the following reason: " + status);
        
      }
    });
  }
// ------------------------------------------------------------------------------------------------------------------

  function UpdateBack(xhrRetour,param) {
      //alert(xhrRetour);
  }
// ------------------------------------------------------------------------------------------------------------------
function FastAddMarkerv3(tmplat,tmplng,mytitle,htmlDATA,options,typemarker,id,cat1,cat2) {
 var point = new google.maps.LatLng(tmplat, tmplng);
  // var point = new GLatLng(x,y);

//    map.addOverlay(new GMarker(point));
   
   //a = htmlDATA;  // on récup&egrave;re ce qu'il faut afficher dans la box
  // a='texte';
	//aTmpMarker = createMarker(map,point,options,a);
var image = 'iconRed.png';

if (typemarker==1) {image = 'iconPort.png';}
if (typemarker==2) {image = 'iconAccastillage.png';}
if (typemarker==3) {image = 'iconJaune.png';}
if (typemarker==4) {image = 'iconGreen.png';}
if (typemarker==5) {image = 'iconRed.png';}
if (typemarker==6) {image = 'iconRed.png';}
if (typemarker==7) {image = 'iconRed.png';}
if (typemarker==8) {image = 'iconPhare.png';}
       
       image = "/markerimg/" + image;                                  
 	var marker = new google.maps.Marker({
      position: point, 
      map: map, 
      title:mytitle,
      icon: image
  }); 
               
  markerTab[id]=marker;
 
 cat[100][id]=0;
 cat[101][id]=0;
 cat[102][id]=0;
 cat[103][id]=0;
 
 if (cat1!=0)  {cat[cat1][id]=1;}
 if (cat2!=0)  {cat[cat2][id]=1;}
  

  
  
 //alert(id);

if (htmlDATA=="nil"){htmlDATA = $("#data"+id).html();} 

//alert(id);
/*
tmp = new google.maps.InfoWindow({
    content: htmlDATA
}); 
*/
 //infowindowTab[id] = tmp;
 
 //alert("id : " + tmp); 

google.maps.event.addListener(marker, 'click', function() {
  OpenBulle(marker,id);
  //tmp.open(map,marker);
});
      
//imagePourMarqueur='/img/marker/contour.png';
//imagePourMarqueur='/img/marker/markerNormal.gif';
     
      
//aTmpMarker.setImage(imagePourMarqueur);
//tmpSize = new GSize(592,500);
//aTmpMarker.iconSize = tmpSize;
return ;										// cad de faire le lien aisément entre php et javascript
}



