if (GBrowserIsCompatible()) {		
		var gmarkers = [];
		var i = 0;		
		var map = new GMap2(document.getElementById("map"));
    var point = new GLatLng(46.15,-1.0)

    
		map.addControl(new GMapTypeControl());
		map.setCenter(point, 10);
		map.addControl(new GLargeMapControl());
    
		var baseIcon = new GIcon();
		baseIcon.iconSize=new GSize(32,32);
		baseIcon.iconAnchor=new GPoint(6,20);
		baseIcon.shadowSize=new GSize(59,32);
		baseIcon.infoWindowAnchor=new GPoint(5,1);
		var marche = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/ms/micons/red-dot.png', null, 'http://maps.google.com/mapfiles/ms/micons/msmarker.shadow.png');
		var mag = new GIcon(baseIcon, 'http://maps.google.com/mapfiles/ms/micons/green-dot.png', null, 'http://maps.google.com/mapfiles/ms/micons/msmarker.shadow.png');

		
		function createMarker(point, texte, val) { 
			if(val=='Mag'){var icone = mag;} 
   		if(val=='Marche'){var icone = marche;}    		
  		var marker = new GMarker(point,icone); 
			GEvent.addListener(marker, "click", function() { 
				document.getElementById("description").innerHTML=texte;
			}); 
				GEvent.addListener(marker, 'mouseover', function() {
				document.getElementById("description").innerHTML=texte;
			});
				GEvent.addListener(marker, 'mouseout', function() {
				//document.getElementById("description").innerHTML="";
			});
			return marker;
		}      	
      	
       
       
  			
  			





	//Thumbnail map

      //  ======== Add a map overview ==========
      //  ======== save a reference to the control =========
      var ovcontrol = new GOverviewMapControl(new GSize(171,171)); 
      map.addControl(ovcontrol);

      //  ======== A function to adjust the positioning of the overview ========
      function positionOverview(x,y) {
        var omap=document.getElementById("map_overview");
        omap.style.left = x+"px";
        omap.style.top = y+"px";
        
        // == restyling ==
        omap.firstChild.style.border = "0";

        omap.firstChild.firstChild.style.left="-1px";
        omap.firstChild.firstChild.style.top="-1px";
        omap.firstChild.firstChild.style.width="171px";
      	omap.firstChild.firstChild.style.height="171px";
      }

 //  ======== Cause the overview to be positioned AFTER IE sets its initial position ======== 
      setTimeout("positionOverview(630,330)",1);
      

}


function getXhr(){
		var xhr = null; 
		if(window.XMLHttpRequest) // Firefox et autres
				xhr = new XMLHttpRequest(); 
		else if(window.ActiveXObject){ // Internet Explorer 
				try {
						xhr = new ActiveXObject("Msxml2.XMLHTTP");
				} catch (e) {
						xhr = new ActiveXObject("Microsoft.XMLHTTP");
				}
		}
		else { // XMLHttpRequest non supporté par le navigateur 
				alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
				xhr = false; 
		} 
		return xhr
}
			



function listeVille(){
	var q = document.getElementById("cp").value;	
	var xhr = getXhr();
	var lib = "";
	var LVille="";
	xhr.onreadystatechange = function(){
		if(xhr.readyState == 4 && xhr.status == 200){
			resp=xhr.responseText;
			if (resp != ""){
					LVille = resp.split("|");
					for (i=0;i<LVille.length;i++){
						LDetail=LVille[i].split(";");
						lib=lib+"<a class=\"detailville\" href=\"javascript:mapLoad('"+LDetail[0]+"');\">"+LDetail[1]+"</a>";
					}			
					document.getElementById("result").innerHTML=lib+"";
			}else{
					document.getElementById("result").innerHTML="<div class='msg'>Veuillez taper un code postal</div>";
			}
		}
	}
	xhr.open("GET","scripts/ville.asp?zip="+q,true);
	xhr.send(null);
}

function mapLoad(valeur){
	if (valeur != 0){
		if (GBrowserIsCompatible()){
			param = valeur.split(",");
			this.map.setCenter(new GLatLng(param[0], param[1]), 12);
	    }
	}
}
