      var map = null;
      var agence = new Array ;
	  var lezoom = 5;
	  var epingle = false;
		
	  function EventMouseWheel()
	  {
		  return true;
	  }
	  function ZoomCarte()
	  {
	  	lezoom = map.GetZoomLevel();
		 if(lezoom < 7 && epingle == true)
		 {
		 	loadinfocarte();
			epingle = false;
		 }
		 else if (lezoom >= 7 && epingle == false)
		 {
		 	loadinfocarte();
			epingle = true;
		 }
	  }
	  
      function loadinfocarte()
	  {
		 
		 var icon = "<div style='font-size:10px;font-family: Arial, Helvetica, sans-serif;color:#000000;font-weight:bold;text-align:center;width:16px;padding-left:3px;padding-top:2px;height:21px;background-repeat:no-repeat;background-image: URL(images/pointeur3.png)'></div>";
		 
		if( lezoom >= 7)
			icon = "";
			
	  	map.DeleteAllShapes();
		for(x in agence)
			AddPushpin(agence[x][0], agence[x][1], agence[x][2], agence[x][3], icon);
	
		//document.getElementById('attente').style.display="none"; 
		//map.SetCenterAndZoom(lastloca, 11);
	  }
      function AddPushpin(loca, titre, desc, ag, icon)
      {
         var shape = new VEShape(VEShapeType.Pushpin, loca);
		 if(icon == "")
		 	icon = "<div style='font-size:10px;font-family: Arial, Helvetica, sans-serif;color:#000000;font-weight:bold;text-align:center;width:34px;padding-left:3px;padding-top:2px;height:25px;background-repeat:no-repeat;background-image: URL(images/pointeur2.png)'>" + titre + "</div>";
			
         //Set the icon
         shape.SetCustomIcon(icon);
         shape.SetTitle(desc);
		 shape.SetDescription(ag);

		 //shape.SetDescription(desc);
		 
         //Set the info box
         map.ClearInfoBoxStyles();
		 shape.SetZIndex(999);
         
         //Add the shape the the map
         map.AddShape(shape);

      }
	  function carteclick(e)
      {
         if(e.elementID != null)
		 {
		 	 var entete = map.GetShapeByID(e.elementID).GetTitle();
			 var dep = entete.substring(0,2);
             window.location.href = "list_agence.php?departement=" + dep;
			 
         }
		 else
           return false;
      }
	  function loaddonnee()
	  {
		// Mise à jour de la variable de session
		var xhr_object = null;
		
		map = new VEMap('myMap');
		//map.SetDashboardSize(VEDashboardSize.Tiny);
		map.HideScalebar();
		
		if(window.XMLHttpRequest)
			xhr_object = new XMLHttpRequest();
		else if(window.ActiveXObject)
			xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
		else {
			alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
			return;
	   	}
		xhr_object.open("POST", "localisationagence.php", true);
		xhr_object.onreadystatechange = function()
        {
        	if (xhr_object.readyState == 4)
            { 
				
				if(xhr_object.responseText != "")
				{ 
					map.LoadMap();
					//map.HideDashboard();
					map.AttachEvent("onmousewheel", EventMouseWheel);
					map.AttachEvent("onclick", carteclick);
					map.SetCenterAndZoom((new VELatLong(46.5,2.716667)), 5);
					eval(xhr_object.responseText);
					map.AttachEvent("onendzoom", ZoomCarte);
					loadinfocarte();
				}
				else
					document.getElementById('attente2').style.display="block"; 
			}
		}
		xhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		var data = '';
		xhr_object.send(data);
	}