  var geocoder;  var map;  var marker;  var bounds;  var zone;   var contentString = '<div id="content">'+
  '<h2 id="firstHeading" class="firstHeading">Uluru<'+'/h2>'+
  '<div id="bodyContent">'+
  '<p><b>Uluru<'+'/b><'+'/p>'+
  '<'+'/div>'+
  '<'+'/div>';  //Change these parameters to customize map
  var param_wsId = "od6";
  var param_ssKey = "ABQIAAAAqqkaRHw2WGtZ00PTQMuSDRSccb1oEoab1SGjEvtsxLj6VQq7txRIo2dFt3xotY_-WD6wqDTc5X5CZg";
  var param_useSidebar = true;
  var param_titleColumn = "title";
  var param_descriptionColumn = "description";
  var param_latColumn = "latitude";
  var param_lngColumn = "longitude";
  var param_rankColumn = "rank";
  var param_iconType = "green";
  var param_iconOverType = "orange";
  var locations = null;  
  var nb_location = 0;
  function mapause(time)
  {
     d=new Date();
     diff=0;
      while(diff < time)
      {
        n=new Date();
        diff=n-d;
       } 
  }  
  function initGoogleMap() {
	geocoder = new google.maps.Geocoder();
    var latlng = new google.maps.LatLng(50.459777,4.863739);
    var myOptions = {
      zoom: 7,      mapTypeControl: true,      mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},      navigationControl: true,      navigationControlOptions: {style: google.maps.NavigationControlStyle.ZOOM_PAN},
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }    if(jQuery("#titreGoogleMap").length>0)    {    	myOptions = {    		      zoom: 7,    		      mapTypeControl: true,    		      mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},    		      center: latlng,    		      mapTypeId: google.maps.MapTypeId.ROADMAP    		    }	    }
    var mapCan = window.document.getElementById("map_canvas");
    if (mapCan != null) {    	if (map == null) {    		map = new google.maps.Map(mapCan, myOptions);			if (locations==null){				locations = new Array();				if(jQuery("#titreGoogleMap").length>0){
			  		var myPlace = new Array();
					myPlace.push(""+jQuery("#titreGoogleMap").val());					myPlace.push(""+jQuery("#addressGoogleMap").val());
					myPlace.push("1");	
					locations.push(myPlace);				}	
			}			bounds = new google.maps.LatLngBounds();    		setMarker();    	}
    }
  }
     
  /**
   * Creates a script tag in the page that loads in the 
   * JSON feed for the specified key/ID. 
   * Once loaded, it calls cm_loadMapJSON.
   */
  function cm_getJSON() {    // Retrieve the JSON feed.    var script = document.createElement('script');    script.setAttribute('src', 'http://spreadsheets.google.com/feeds/list'                           + '/' + param_ssKey + '/' + param_wsId + '/public/values' +                          '?alt=json-in-script&callback=cm_loadMapJSON');    script.setAttribute('id', 'jsonScript');    script.setAttribute('type', 'text/javascript');    document.documentElement.firstChild.appendChild(script);  }
  //http://spreadsheets.google.com/feeds/list/o16162288751915453340.4402783830945175750/od6/public/values?alt=json-in-script  var currentMarker = 0;  var doubleCheck = -1;  var localMarkers = new Array();  function putItOnTheMap(results, status){            var timeoutdelay = 1;	    if (status == google.maps.GeocoderStatus.OK && results.length) 	    {	    	if ("RANGER_INTERPOLATED"!=results[0].geometry.location_type)	        {	      	  var point = results[0].geometry.location;	      	  theZone = locations[currentMarker];	    	  var googleABC = new google.maps.MarkerImage(templatePath+'/shared/css/images/red_markers_A_J2.png',	  	      new google.maps.Size(20, 34),	  	      new google.maps.Point(0,0+(currentMarker*34)),	  	      new google.maps.Point(0, 34));	    	  bounds.extend(point);	    	  if (currentMarker == locations.length-1) {		      	  map.fitBounds(bounds);		  		  map.setCenter(bounds.getCenter());		  		  		  		  //alert(map.get_zoom());		  		  if ( map.getZoom() > 10 ) {		  			map.setZoom(10);		  		  } 	    	  }	  		  var myFlag = googleABC;	  		  if (theZone.length<4)	  		  {	  			  myFlag = null;	  		  }	      	  var marker = new google.maps.Marker({	  	  						icon : myFlag,	  			      	        position: point,	  			      	        map: map,	  			      	        title: theZone[0],	  			      	        zIndex : 100-(currentMarker*10)	  			      	    });	      	  localMarkers[currentMarker]=marker;	      	  	  		  if (theZone.length>3) {	  			  		contentToCopy = jQuery("DIV.result:eq("+currentMarker+") p.org_attach a").clone();	  			  		contentToCopy.attr("target",new Date().getTime());	  			  		contentToCopy.wrap("<div></div>");	  			  		contentToCopy =contentToCopy.parent(); 	  			  			  			  		contentString = '<div style="width:380px;height:138px;">'+	  			  				'<h4 style="margin:0;padding:0;color:green;"><a style="color:green;" target="'+new Date().getTime()+'" href="'+("ent"==theZone[6]?js_entiteContPageUrl:js_userContPageUrl)+""+theZone[5]+'">' + theZone[0] + '</a><'+'/h4>'+	  			  				("ent"==theZone[6]?theZone[7]:contentToCopy.html())+	  			  				'<div style="font-size:10px">'+	  			  				'' + results[0].formatted_address + ''+	  			  				'</div>'+	  			  				'</div>';	  			  			var infowindow = new google.maps.InfoWindow({	  								content: contentString,	  								position: point	  								});					  		google.maps.event.addListener(marker, 'click', function() {					  		      infowindow.open(map,marker);					  		  });					  							    	  if (jQuery("DIV.result"))					    	  {					    		  newObj = jQuery("DIV.result:eq("+currentMarker+") h5").before("<div id='info"+currentMarker+"'></div>").prev();					    		  newObj.css("background-image","url("+templatePath+'/shared/css/images/red_markers_A_J2.png)');					    		  newObj.css("background-position","0 -"+(currentMarker*34)+"px");					    		  newObj.css("float","left");					    		  newObj.css("width","20px");					    		  newObj.css("height","32px");					    		  newObj.css("margin-right","5px");					    		  newObj.click(function(){					    			  document.getElementById("geolocal").scrollIntoView(true);					    			  infowindow.open(map,marker);					    		  });					    	  }					  			  		  }	        }	    	currentMarker++;		doubleCheck = -1;		timeoutdelay = 1;	      }	    else	    {	    	if(window.console) console.debug("Geo not found "+currentMarker + " or "+status);		if (status == google.maps.GeocoderStatus.OVER_QUERY_LIMIT && doubleCheck < 2)		{ doubleCheck++;		  timeoutdelay = 1000;		}		else		{		   currentMarker++;		   doubleCheck = -1;		   timeoutdelay = 1;		}	    }	    	    setTimeout(setMarker,timeoutdelay);  }  function setMarker() {	  if (currentMarker < locations.length) {		  		  var zone = locations[currentMarker];			  geocoder.geocode( { address: zone[1], language:"fr"}, putItOnTheMap);	  }  }    function setMarkers() {	  bounds = new google.maps.LatLngBounds();	  // Add markers to the map	  // Marker sizes are expressed as a Size of X,Y	  // where the origin of the image (0,0) is located	  // in the top left of the image.	  // Origins, anchor positions and coordinates of the marker	  // increase in the X direction to the right and in	  // the Y direction down.
	  var image = new google.maps.MarkerImage(templatePath+'/shared/css/images/flag_blue.png',      // This marker is 20 pixels wide by 32 pixels tall.      new google.maps.Size(20, 32),      // The origin for this image is 0,0.      new google.maps.Point(0,0),      // The anchor for this image is the base of the flagpole at 0,32.      new google.maps.Point(0, 32));	  //alert("googleMap - setMarkers, image");	  var shadow = new google.maps.MarkerImage(templatePath+'/shared/css/images/flag_checkered.png',
      // The shadow image is larger in the horizontal dimension      // while the position and offset are the same as for the main image.      new google.maps.Size(37, 32),      new google.maps.Point(0,0),      new google.maps.Point(0, 32));	  // Shapes define the clickable region of the icon.      // The type defines an HTML <area> element 'poly' which      // traces out a polygon as a series of X,Y points. The final      // coordinate closes the poly by connecting to the first      // coordinate.	  //alert("googleMap - setMarkers, shadow");
	  var shape = {	      coord: [1, 1, 1, 20, 18, 20, 18 , 1], 	      type: 'poly'	  };
	  for (var i = 0; i < locations.length; i++) {		  var zone = locations[i];		  		  if (false) {			if (zone[4]=="true")			{				marker = new google.maps.Marker({						      	        position: new google.maps.LatLng(zone[3].lat, zone[3].lng),						      	        map: map,						      	        title: zone[0]						      	    });			}			if (zone[4]=="false")			{				marker = new google.maps.Marker({						      	        position: new google.maps.LatLng(zone[3].lat, zone[3].lng),						      	        map: map,						      	        title: zone[0]						      	    });			}		  }		if (true)		{		  geocoder.geocode( { address: zone[1], language:"fr"}, 	    				  function(results, status) {	        if (status == google.maps.GeocoderStatus.OK && results.length) {	          // You should always check that a result was returned, as it is	          // possible to return an empty results object.	          if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {	        	  var point = results[0].geometry.location;	        	  //theZone = getZoneInfo(results[0].formatted_address);			  theZone = locations[nb_location];		  	  var googleABC = new google.maps.MarkerImage(templatePath+'/shared/css/images/red_markers_A_J2.png',			      new google.maps.Size(20, 34),			      new google.maps.Point(0,0+(nb_location*34)),			      new google.maps.Point(0, 34));			  nb_location++;	        	  bounds.extend(point);	        	  map.fitBounds(bounds);				  map.setCenter(bounds.getCenter());			  //alert(map.get_zoom());
			  if ( map.get_zoom() > 10 ) {    				map.set_zoom(10);			  } 			  var myFlag = googleABC;			  if (theZone.length<4)			  {			  	myFlag = null;			  }	        	  var marker = new google.maps.Marker({			  				icon : myFlag,					      	        position: point,					      	        map: map,					      	        title: theZone[0]					      	    });				  if (theZone.length>3) {	        	  
				  contentString = '<div style="width:380px;height:138px;">'+							  '<h4 style="margin:0;padding:0;color:green;"><a style="color:green;" href="'+js_entiteContPageUrl+""+theZone[5]+'">' + theZone[0] + '</a><'+'/h4>'+
							  ("ent"==theZone[6]?theZone[7]:"")+							  '<div style="font-size:10px">'+
							  '' + results[0].formatted_address + ''+
							  '</div>'+
						  '</div>';
				  var infowindow = new google.maps.InfoWindow({										content: contentString,										position: point										});
				google.maps.event.addListener(marker, 'click', function() {				      infowindow.open(map,marker);				  });	          }

	          }
	        }
	    });
		  mapause(100);
		}
	  }  }

  function getZoneInfo(address) {
	  //("getZoneInfo" + address);
	  for (var i = 0; i < locations.length; i++) {
		  zone = locations[i];
		  if (address == zone[1]) {
			  return address;
		  }
	  }
	  return null;
  }
