
    
    
    function positionOverview(x,y) {
        var omap=document.getElementById("map_overview");
        omap.style.left = x+"px";
        omap.style.top = y+"px";
        omap.firstChild.style.border = "1px solid blue";
        omap.firstChild.firstChild.style.left="4px";
        omap.firstChild.firstChild.style.top="4px";
        omap.firstChild.firstChild.style.width="190px";
        omap.firstChild.firstChild.style.height="190px";
      }

		
	
	
      function loadMap(lat, lng, zoom,mapid, mapTypeControlStyle, navigationControlStyle) {
		geocoder = new google.maps.Geocoder();
		  var latlng = new google.maps.LatLng(lat, lng);
		  mapid='google.maps.MapTypeId.'+mapid;
		  var navcontrol=false;
			var maptypecontrol=false;

			if( mapTypeControlStyle !=''){
				maptypecontrol=true;
				mapTypeControlStyle='google.maps.MapTypeControlStyle.'+mapTypeControlStyle;
			}
			if( navigationControlStyle !=''){
				navcontrol=true;
				navigationControlStyle='google.maps.NavigationControlStyle.'+navigationControlStyle;
			}
		  map=null;
			var myOptions2 = { 
      		zoom: eval(zoom), 
	      	center: latlng,
			scrollwheel:false,
			mapTypeId: eval(mapid),
			navigationControl: navcontrol, 
		    navigationControlOptions: {style : eval(navigationControlStyle)  },
			mapTypeControl:maptypecontrol,
			mapTypeControlOptions: {style : eval(mapTypeControlStyle) }
		}
		map = new google.maps.Map(document.getElementById("map"), myOptions2);		

		
  }
      
  function affichetheme(theme){

  	var tab_theme=theme.split(',');
	for (var i = 0; i < tab_theme.length; i++){
		if(tab_theme[i] !=='undefined' && tab_theme[i] !==''){
			eval(tab_theme[i]).setVisible(true);		
	 	//google.maps.event.addListener(marker, "dragstart", function() {   map.close();   });	
	 	/*google.maps.event.addListener(marker, "dragend", function() {  
	  		var latlng=marker.get_position();
			getAddress(latlng);   
		});	
		return marker;*/		

		}
	}
  }
    
  function enlevetheme(theme){


  	var tab_theme=theme.split(',');
	for (var i = 0; i < tab_theme.length; i++){	
		if(tab_theme[i] !=='undefined' && tab_theme[i] !==''){
			eval(tab_theme[i]).setVisible(false);
			var tmp=tab_theme[i].replace(/marker/, 'infowindow');
			eval(tmp).close();		

		}
	}
  }
      
    // addAddressToMap() is called when the geocoder returns an
    // answer.  It adds a marker to the map with an open info window
    // showing the nicely formatted version of the address and the country code.
    function addAddressToMap(response) {
      //map.clearOverlays();
      if (!response || response.Status.code != 200) {
        alert("Désolé, nous ne trouvons pas de localisation pour cette adresse");
      } else {
        place = response.Placemark[0];
        map.setCenter(new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]), 15);
        point = new GLatLng(place.Point.coordinates[1],
                            place.Point.coordinates[0]);
        marker = new GMarker(point);
        map.addOverlay(marker);
        marker.openInfoWindowHtml(place.address);
      }
    }
    
    // showLocation() is called when you click on the Search button
    // in the form.  It geocodes the address entered into the form
    // and adds a marker to the map at that location.
    function showLocation() {
	
      var address = document.forms['formsearch'].q.value;
      if (document.forms['formsearch'].cp.value != '' )	{address = address + ', ' + document.forms['formsearch'].cp.value    }
      if (document.forms['formsearch'].ville.value != '' )	{address = address + ', ' + document.forms['formsearch'].ville.value    }
      if (document.forms['formsearch'].pays.value != '' )	{address = address + ', ' + document.forms['formsearch'].pays.value     }
		geocoder.geocode({'address': address}, function(results, status) {
          	if (status == google.maps.GeocoderStatus.OK) {
		 		map.setCenter(results[0].geometry.location);
				markersearc = new google.maps.Marker({
        				position:results[0].geometry.location, 
			        	map: map,
						draggable: false
					});
			  	markersearc.setPosition(results[0].geometry.location);
				map.addOverlay(marker);
       			markersearc.openInfoWindowHtml(adress);

	        } else {
    	      alert("Erreur de géolocalisation: " + status);
			}
      	});
    }

   // findLocation() is used to enter the sample addresses into the form.
    function findLocation(address) {
      document.forms[0].q.value = address;
      showLocation();
    }
    
    //]]>
    
    // fonction d'affichage du menu ----------
	function affiche(theme,num){
		if (document.getElementById('div' + num))
		{	var x=document.getElementById('div' + num);
			//if (document.getElementById('div' + num).style.display == 'none')
			if (document.getElementById('div' + num).style.display != 'block')
				{
					x.style.display="block";
					//document.getElementById('image'+num).src = 'images/moinsdos.gif';
					// ajoute les marker de ce theme de la carte
					affichetheme(theme)
					//map.removeOverlay(markerselect);
				}
			else
				{
					x.style.display="none";
					//document.getElementById('image'+num).src = 'images/plusdos.gif';
					// enleve les marker de ce theme de la carte
					enlevetheme(theme)
					map.removeOverlay(markerselect);
				}
		}
	}
	
	// affichage de l'image de sélection d'une localisation (marker)
	function selectmarker(marker, point){
		map.removeOverlay(markerselect);
		pointselect = new GLatLng(point.lat(),point.lng());
		markerselect= new GMarker(pointselect, iconeselect); 
		map.panTo(pointselect);
		map.addOverlay(markerselect);
		map.removeOverlay(marker);
		map.addOverlay(marker);
	}
