	//création d'une icone personnalisé qui servira pour les markers
var MonIcon = new GIcon(); 
MonIcon.image = 'http://213.198.116.199/templates/1/medias/img/icons/g_brenard-trucks.png';
MonIcon.iconSize = new GSize(75,37);
MonIcon.iconAnchor = new GPoint(25, 37);
MonIcon.infoWindowAnchor = new GPoint(25, 37);


//compteur du nb de marker sur la carte
var i = 0;
var description = "";
var nb_etoile_camping = "";
var nom_camping_etoile="";
var site_fiche_detaille = "";
var icone = "";
var ville="";
var rue="";
var cp="";

//var tab_marker[];



//placer un point sur tournon sur rhone : (45.06867131826394, 4.830894470214844)
//faire afficher une infobulle stylée
function createMarker(point, name, address, link, type, photo) {
  var marker = new GMarker(point, type);
  var html = address;
  var html1 = html;
	GEvent.addListener(marker, 'click', function() {
		var maxContentDiv = document.createElement('div');
		maxContentDiv.innerHTML = 'Chargement...'
		marker.openInfoWindowHtml("<table cellpadding='5' cellspacing='2' border='0' style='display:block;float:left;width:375px'><tr><td colspan='2' style='color:#707072;font-weight:bold;font-size:13px'>"+name+"</td></tr><tr><td>" + html1 + "<br />"+link+"</td><td>"+photo+"</td></tr></table>");
			//{,maxContent: maxContentDiv, 
			// maxTitle: "Mini Fiche : "}
			
		var iw = map.getInfoWindow();
		GEvent.addListener(iw, "maximizeclick", function() {
			GDownloadUrl("minifiche.php", function(data) { //attention l'url doit etre sur le meme site sinon ca ne passe pas... les données retournées sont dans data.
				maxContentDiv.innerHTML = data; //un ptit coup d'ajax pour recuperer les infos d'une page
			});
		  });
		GEvent.addListener(iw, "restoreend", function() {
			//GDownloadUrl("http://www.cotedor-tourisme.com", function(data) {
				//alert('petit');
				//document.getElementById('navmap').style.display='';
			//});
		});
		
		GEvent.addListener(iw, "closeclick", function() {
			//GDownloadUrl("http://www.cotedor-tourisme.com", function(data) {
				// document.getElementById('navmap').style.display='';
			//});
		});
	});
  
	//--- infoalt
	/*
	var infoalt = new InfoAlt(marker,name,4);
	marker.infoalt = infoalt;
	map.addOverlay(infoalt);
	GEvent.addListener(marker,'mouseover',function(){
	this.infoalt.show();
	});
	GEvent.addListener(marker,'mouseout',function(){
	this.infoalt.hide();
	});
	//FIN --- infoalt
	
	*/
  return marker;
}


//faire afficher un marker sans click ni rien juste mouseover
function createMarkerSimple(point, name, type) {
	var marker = new GMarker(point, type);
	//--- infoalt
	var infoalt = new InfoAlt(marker,name,4);
	marker.infoalt = infoalt;
	map.addOverlay(infoalt);
	GEvent.addListener(marker,'mouseover',function(){
	this.infoalt.show();
	});
	GEvent.addListener(marker,'mouseout',function(){
	this.infoalt.hide();
	});
	//FIN --- infoalt
	
	return marker;
}


//faire afficher un marker avec lien sur le marker vers la fiche sitra
function createMarkerLien(point, name, link, type) {
	var marker = new GMarker(point, type);
	//var html = address;
	//var html1 = html + "<br /><a href=\""+ link +"\" target=_blank>Voir la fiche complète</a>";
	GEvent.addListener(marker, 'click', function() {
		window.open(link,'_blank','toolbar=1, location=1, directories=1, status=1, scrollbars=1, resizable=1, copyhistory=1, menuBar=1');
	});
  
	//--- infoalt
	var infoalt = new InfoAlt(marker,name,4);
	marker.infoalt = infoalt;
	map.addOverlay(infoalt);
	GEvent.addListener(marker,'mouseover',function(){
	this.infoalt.show();
	});
	GEvent.addListener(marker,'mouseout',function(){
	this.infoalt.hide();
	});
	//FIN --- infoalt
	
	return marker;
}
		
		
//--------------info Alt ----------------------------------


function InfoAlt(marker, text, padding){
	this.marker_ = marker;
	this.text_ =  text;
	this.padding_ = padding;
}

InfoAlt.prototype = new GOverlay();

InfoAlt.prototype.initialize = function(map){
	var div = document.createElement("div");
	div.appendChild(document.createTextNode(this.text_));
	div.className = 'InfoAlt';
	div.style.position = 'absolute';
	div.style.visibility = 'hidden';
	map.getPane(G_MAP_FLOAT_PANE).appendChild(div);
	this.map_ = map;
	this.div_ = div;
}

InfoAlt.prototype.remove = function(){
	this.div_.parentNode.removeChild(this.div_);
}

InfoAlt.prototype.copy = function(){
	return new InfoAlt(this.marker_,this.text_,this.padding_);
}

InfoAlt.prototype.redraw = function(force){
	if (!force) return;
	var markerPos = this.map_.fromLatLngToDivPixel(this.marker_.getPoint());
	var iconAnchor = this.marker_.getIcon().iconAnchor;
	var xPos = Math.round(markerPos.x - this.div_.clientWidth / 2);
	var yPos = markerPos.y - iconAnchor.y - this.div_.clientHeight - this.padding_;
	this.div_.style.top = yPos + 'px';
	this.div_.style.left = xPos + 'px';
}

InfoAlt.prototype.show = function(){
	this.div_.style.visibility = 'visible';
}

InfoAlt.prototype.hide = function(){
	this.div_.style.visibility = 'hidden';
}
//--------------FIN info Alt ----------------------------------


// findLocation() is used to enter the sample addresses into the form.
function findLocation(address,une_rue,un_cp,une_ville,un_nom_camping_etoile,une_description,une_site_fiche_detaille) {
	document.forms[0].q.value = address;
	
	rue = "";
	ville = "";
	cp = "";
	nb_etoile_camping = "";
	nom_camping_etoile="";
	site_fiche_detaille = "";
	icone = "";
	description = "";
	
	rue = une_rue;
	ville=une_ville;
	cp=un_cp;
	nom_camping_etoile= un_nom_camping_etoile;
	site_fiche_detaille = une_site_fiche_detaille;
	description = une_description;

	
	showLocation();  
}

// 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("Impossible de localiser cette adresse."+response.name);
	
//	var chaine = response.name;
	//var reg=new RegExp("[,]+", "g");
	//var tableau=chaine.split(reg);
	//findLocation(' '+ville+' '+cp+', fr',rue,cp,ville,nom_camping_etoile,description,site_fiche_detaille);		
  } else {
	var chaine = response.name;
	var reg=new RegExp("[,]+", "g");
	var tableau=chaine.split(reg);
	
	
	place = response.Placemark[0];
	point = new GLatLng(place.Point.coordinates[1],
						place.Point.coordinates[0]);
	//var marker = new GMarker(point);
	//map.addOverlay(marker);
	var marker = createMarker(point, nom_camping_etoile, cp+' '+ville+'<br />'+description,site_fiche_detaille,MonIcon);
	map.addOverlay(marker);

	//map.setZoom(13);
	//map.setCenter(new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]));
	//map.setMapType(G_HYBRID_MAP);
  }
}

 // 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[0].q.value;
  geocoder.getLocations(address, addAddressToMap);
}