
function creerLigneRoute(stringLigneRoute,positionRoute,nombreTotalRoutesAjoutees,idTbody,positionRouteAttente)
{
	var infosLigneRoute=stringLigneRoute.split('[#]');
	var id=infosLigneRoute[0];
	var titre=infosLigneRoute[1];
	var url=infosLigneRoute[2];
	var note=infosLigneRoute[3];
	var kilometrage=Math.floor(infosLigneRoute[4]/coeffConversion*10)/10;
	var type=infosLigneRoute[5];
	var stringType=infosLigneRoute[6];
	//communs IE et Firefox
		
	var kilometrage=document.createTextNode(stringType);
	var texteNote=document.createTextNode(note+'/5');
	
	var note10=Math.floor(note*10);
if(document.all)
	{
		
	if(positionRoute>0)
	{
	var ligneRoute=document.createElement('<tr style="background-color:#FFCC66;">');
	}
	else var ligneRoute=document.createElement('<tr>');
	var cellule0=document.createElement('<td width="31">');
	var cellule1=document.createElement('<td class="sujet" style="text-align:center;">');
	var cellule2=document.createElement('<td width="81">');
	var cellule3=document.createElement('<td width="51">');
	var cellule4=document.createElement('<td width="301">');
	
	
	var icone0=document.createElement('img');
	
	if(positionRoute>0)icone0.setAttribute('src','/images/icones/creerRoadbooks/routeSel'+positionRoute+'.png');
	else  icone0.setAttribute('src','/images/icones/creerRoadbooks/routeAttente'+positionRouteAttente+'.png');
	
	var span1=document.createElement('<span class="enonce">');
	var lien1=document.createElement('<a href="javascript:void(0);" onclick="javascript:window.open(\''+url+'\');">');
	var titre=document.createTextNode(titre);
	
	var strong2=document.createElement('<strong>');
	var strong3=document.createElement('<strong>');

if(positionRoute>0)
	{
	var boutonDeplacer=document.createElement('<input type="button" value="'+tabRtes1+'" onclick="javascript:deplacerRouteRbk('+id+',\'tableau\');" id="boutonDeplacerRoute"'+id+'" />');
	
	var positionRouteUp=positionRoute-1;
	var lienDeplUp=document.createElement('<a href="javascript:void(0);"  onclick="deplacerRouteRbk('+id+','+positionRouteUp+');">');
	var imageDeplUp=document.createElement('<img src="images/icones/up25.png" style="border:none;"/>');
	lienDeplUp.appendChild(imageDeplUp);
	
	var positionRouteDown=positionRoute+1;
	var lienDeplDown=document.createElement('<a href="javascript:void(0);"  onclick="deplacerRouteRbk('+id+','+positionRouteDown+');">');
	var imageDeplDown=document.createElement('<img src="images/icones/down25.png" style="border:none;"/>');
	lienDeplDown.appendChild(imageDeplDown);	
	
	}
	else
	{
		if(nombreTotalRoutesAjoutees>0) {
		var boutonAjouter=document.createElement('<input type="button" value="'+tabRtes2+'" onclick="javascript:ajouterRouteRbk('+id+',1,\'tableau\');" id="boutonAjouterRoute"'+id+'" />');	}
		else
		{
		var boutonAjouter=document.createElement('<input type="button" value="'+tabRtes2+'" onclick="javascript:ajouterRouteRbk('+id+',0,\'tableau\');" id="boutonAjouterRoute"'+id+'" />');
		}	
	
	}
	
	var menuDeroulant=document.createElement('<select id="tableSelect'+id+'"/>');
	var tableOptionsSelect=new Array();
	var tableTextOptionsSelect=new Array();
	
	if(nombreTotalRoutesAjoutees>0)
	{
		if(positionRoute==0)
		{
		
			for(var g=1;g<=nombreTotalRoutesAjoutees;g++)
			{
			tableOptionsSelect[g]=document.createElement('<option value="'+g+'"/>');
			tableTextOptionsSelect[g]=document.createTextNode(g);
			tableOptionsSelect[g].appendChild(tableTextOptionsSelect[g]);
			}
			var numLastRoad=nombreTotalRoutesAjoutees+1;
			tableOptionsSelect[numLastRoad]=document.createElement('<option value="'+numLastRoad+'" selected="selected"/>');
			tableTextOptionsSelect[nombreTotalRoutesAjoutees+1]=document.createTextNode(tabRtes3);
			tableOptionsSelect[nombreTotalRoutesAjoutees+1].appendChild(tableTextOptionsSelect[numLastRoad]);
			
			for (var l=1;l<=nombreTotalRoutesAjoutees+1;l++)
			{
			menuDeroulant.appendChild(tableOptionsSelect[l]);
			
			}
		}
		else
		{
		for(var g=1;g<=nombreTotalRoutesAjoutees;g++)
			{
			
			if(g==positionRoute) tableOptionsSelect[g]=document.createElement('<option value="'+g+'" selected="selected" />');
			else tableOptionsSelect[g]=document.createElement('<option value="'+g+'"/>');
			tableOptionsSelect[g].setAttribute('value',g);
			tableTextOptionsSelect[g]=document.createTextNode(g);
			tableOptionsSelect[g].appendChild(tableTextOptionsSelect[g]);
		
			}
					
			for (var l=1;l<=nombreTotalRoutesAjoutees;l++)
			{
			menuDeroulant.appendChild(tableOptionsSelect[l]);
			
			}
		}
	}
	
		
	if(type==1)var lienZoom=document.createElement('<a href="#mapCanvas"  onclick="zoomerRoute('+id+');">');
	else var lienZoom=document.createElement('<a href="#mapCanvas"  onclick="zoomerSite('+id+');">');
	var imageZoom=document.createElement('<img src="images/icones/zoom+25.png" style="border:none;"/>');
	lienZoom.appendChild(imageZoom);
	
	if(positionRoute>0)
	{
	//création des boutons Supression et ajout étapes
	
	
	var lienSuppr=document.createElement('<a href="javascript:void(0);"  onclick="retirerRouteRbk('+id+');">');
	var imageSuppr=document.createElement('<img src="images/icones/delete25.png" style="border:none;"/>');
	lienSuppr.appendChild(imageSuppr);
	
		var lienInvert=document.createElement('<a href="javascript:void(0);"  onclick="InvertRouteRbk('+id+');">');
	var imageInvert=document.createElement('<img src="images/icones/googleMaps/croisement/inversion.gif" style="border:none;"/>');
	lienInvert.appendChild(imageInvert);
		
	}
	
		var insertionEtapePrec=document.createElement('<a href="javascript:void(0);"  onclick="ajouterEtape(\'R[#]'+positionRoute+'\',\'prev\');">');
	var imageInsertionPrec=document.createElement('<img src="/images/icones/upAj25.png" style="margin-left:4px;" border="0"/>');
	
	var insertionEtapePrecPrems=document.createElement('<a href="javascript:void(0);"  onclick="ajouterEtapePrems();">');
	var imageInsertionPrecPrems=document.createElement('<img src="/images/icones/upAj25.png" style="margin-left:4px;" border="0"/>');
	
	var insertionEtapeSuiv=document.createElement('<a href="javascript:void(0);"  onclick="ajouterEtape(\'R[#]'+positionRoute+'\',\'next\');">');
	var imageInsertionSuiv=document.createElement('<img src="/images/icones/downAj25.png" style="margin-left:4px;" border="0"/>');
	
	
	
	insertionEtapePrec.appendChild(imageInsertionPrec);
	insertionEtapePrecPrems.appendChild(imageInsertionPrecPrems);
insertionEtapeSuiv.appendChild(imageInsertionSuiv);
	
	}
	else
	{
	var ligneRoute=document.createElement('tr');
	
	if(positionRoute>0)
	{
	ligneRoute.setAttribute("style","background-color:#FFCC66;");
	}
	var cellule0=document.createElement('td');
	var cellule1=document.createElement('td');
	var cellule2=document.createElement('td');
	var cellule3=document.createElement('td');
	var cellule4=document.createElement('td');
	
	
	
	cellule0.setAttribute('width','31');
	cellule1.setAttribute('style','text-align:center;');
	cellule1.setAttribute('class','sujet');
	cellule2.setAttribute('width','81');
	cellule3.setAttribute('width','51');
	cellule4.setAttribute('width','301');

	
	var icone0=document.createElement('img');
	
	if(positionRoute>0)icone0.setAttribute('src','/images/icones/creerRoadbooks/routeSel'+positionRoute+'.png');
	else  icone0.setAttribute('src','/images/icones/creerRoadbooks/routeAttente'+positionRouteAttente+'.png');
	
	var lien1=document.createElement('a');
	var span1=document.createElement('span');
	var titre=document.createTextNode(titre);	
	
	lien1.setAttribute('href',"javascript:void(0);");
	lien1.setAttribute('onclick',"javascript:window.open('"+url+"');");
	span1.setAttribute('class',"enonce");
	
	var strong2=document.createElement('strong');
	
	var strong3=document.createElement('strong');
	
	//les boutons de la fenêtre de commande
	
	
	if(positionRoute>0)
	{
	var boutonDeplacer=document.createElement('input');
	boutonDeplacer.setAttribute("type","button");
	boutonDeplacer.setAttribute("value",tabRtes1);
	boutonDeplacer.setAttribute("onclick","javascript:deplacerRouteRbk("+id+",'tableau');");
	boutonDeplacer.setAttribute("id","boutonDeplacerRoute"+id);
	
	
	
	var lienDeplUp=document.createElement('a');
	var imageDeplUp=document.createElement('img');
	
	lienDeplUp.setAttribute('href',"javascript:void(0);");
	imageDeplUp.setAttribute('src',"images/icones/up25.png");
	imageDeplUp.setAttribute('style',"border:none;");
	lienDeplUp.setAttribute('onclick',"deplacerRouteRbk("+id+","+(positionRoute-1)+");");
	lienDeplUp.appendChild(imageDeplUp);
	
	var lienDeplDown=document.createElement('a');
	var imageDeplDown=document.createElement('img');
	
	var positionRouteDown=positionRoute+1;
	lienDeplDown.setAttribute('href',"javascript:void(0);");
	imageDeplDown.setAttribute('src',"images/icones/down25.png");
	imageDeplDown.setAttribute('style',"border:none;");
	lienDeplDown.setAttribute('onclick',"deplacerRouteRbk("+id+","+positionRouteDown+");");
	lienDeplDown.appendChild(imageDeplDown);
	}
	
	else
	{	
	var boutonAjouter=document.createElement('input');
	boutonAjouter.setAttribute("type","button");
	boutonAjouter.setAttribute("value",tabRtes2);	
	boutonAjouter.setAttribute("id","boutonAjouterRoute"+id);
	if(nombreTotalRoutesAjoutees>0) boutonAjouter.setAttribute("onclick","javascript:ajouterRouteRbk("+id+",1,'tableau');");
	else boutonAjouter.setAttribute("onclick","javascript:ajouterRouteRbk("+id+",0,'tableau');");
	
	}
	
	
	
	var menuDeroulant=document.createElement('select');
	menuDeroulant.setAttribute("id","tableSelect"+id);
	
	var tableOptionsSelect=new Array();
	var tableTextOptionsSelect=new Array();
	
	if(nombreTotalRoutesAjoutees>0)
	{
		if(positionRoute==0)
		{
		
			for(var g=1;g<=nombreTotalRoutesAjoutees;g++)
			{
			tableOptionsSelect[g]=document.createElement('option');
			tableOptionsSelect[g].setAttribute('value',g);
			tableTextOptionsSelect[g]=document.createTextNode(g);
			tableOptionsSelect[g].appendChild(tableTextOptionsSelect[g]);
			}
			tableOptionsSelect[nombreTotalRoutesAjoutees+1]=document.createElement('option');
			tableOptionsSelect[nombreTotalRoutesAjoutees+1].setAttribute('value',nombreTotalRoutesAjoutees+1);
			tableOptionsSelect[nombreTotalRoutesAjoutees+1].setAttribute('selected','selected');
			tableTextOptionsSelect[nombreTotalRoutesAjoutees+1]=document.createTextNode(tabRtes3);
			tableOptionsSelect[nombreTotalRoutesAjoutees+1].appendChild(tableTextOptionsSelect[nombreTotalRoutesAjoutees+1]);
			
			for (var l=1;l<=nombreTotalRoutesAjoutees+1;l++)
			{
			menuDeroulant.appendChild(tableOptionsSelect[l]);
			
			}
		}
		else
		{
		for(var g=1;g<=nombreTotalRoutesAjoutees;g++)
			{
			tableOptionsSelect[g]=document.createElement('option');
			tableOptionsSelect[g].setAttribute('value',g);
			tableTextOptionsSelect[g]=document.createTextNode(g);
			tableOptionsSelect[g].appendChild(tableTextOptionsSelect[g]);
			if(g==positionRoute) tableOptionsSelect[g].setAttribute('selected','selected');
			}
					
			for (var l=1;l<=nombreTotalRoutesAjoutees;l++)
			{
			menuDeroulant.appendChild(tableOptionsSelect[l]);
			
			}
		}
	}
	
	var lienZoom=document.createElement('a');
	var imageZoom=document.createElement('img');
	
	lienZoom.setAttribute('href',"#mapCanvas");
	imageZoom.setAttribute('src',"images/icones/zoom+25.png");
	imageZoom.setAttribute('style',"border:none;");
	if(type==1)lienZoom.setAttribute('onclick',"zoomerRoute("+id+");");
	else lienZoom.setAttribute('onclick',"zoomerSite("+id+");");
	lienZoom.appendChild(imageZoom);
	
	if(positionRoute>0)
	{
	//création des boutons Supression et ajout étapes
	
	var lienSuppr=document.createElement('a');
	var imageSuppr=document.createElement('img');
	
	lienSuppr.setAttribute('href',"javascript:void(0);");
	imageSuppr.setAttribute('src',"images/icones/delete25.png");
	imageSuppr.setAttribute('style',"border:none;");
	lienSuppr.setAttribute('onclick',"retirerRouteRbk("+id+");");
	lienSuppr.appendChild(imageSuppr);
	
	var lienInvert=document.createElement('a');
	var imageInvert=document.createElement('img');
	
	lienInvert.setAttribute('href',"javascript:void(0);");
	imageInvert.setAttribute('src',"images/icones/googleMaps/croisement/inversion.gif");
	imageInvert.setAttribute('style',"border:none;");
	lienInvert.setAttribute('onclick',"InvertRouteRbk("+id+");");
	lienInvert.appendChild(imageInvert);
	
	}
	
	var insertionEtapePrec=document.createElement('a');
	var imageInsertionPrec=document.createElement('img');
	
	var insertionEtapePrecPrems=document.createElement('a');
	var imageInsertionPrecPrems=document.createElement('img');
	
	var insertionEtapeSuiv=document.createElement('a');
	var imageInsertionSuiv=document.createElement('img');
	
	insertionEtapePrec.setAttribute("href","javascript:void(0);");
	insertionEtapePrecPrems.setAttribute("href","javascript:void(0);");
	insertionEtapeSuiv.setAttribute("href","javascript:void(0);");
	
	insertionEtapePrec.setAttribute("onclick","ajouterEtape('R[#]"+positionRoute+"','prev');");
	insertionEtapePrecPrems.setAttribute("onclick","ajouterEtapePrems();");
	insertionEtapeSuiv.setAttribute("onclick","ajouterEtape('R[#]"+positionRoute+"','next');");
	
	imageInsertionPrec.setAttribute("src","/images/icones/upAj25.png");
	imageInsertionPrec.setAttribute("style","margin-left:4px;");
	imageInsertionPrec.setAttribute("border","0");
	
	imageInsertionPrecPrems.setAttribute("src","/images/icones/upAj25.png");
	imageInsertionPrecPrems.setAttribute("style","margin-left:4px;");
	imageInsertionPrecPrems.setAttribute("border","0");
	
	imageInsertionSuiv.setAttribute("src","/images/icones/downAj25.png");
	imageInsertionSuiv.setAttribute("style","margin-left:4px;");
	imageInsertionSuiv.setAttribute("border","0");
	
	insertionEtapePrec.appendChild(imageInsertionPrec);
	insertionEtapePrecPrems.appendChild(imageInsertionPrecPrems);
insertionEtapeSuiv.appendChild(imageInsertionSuiv);
	
	}
	
	
	
	cellule0.appendChild(icone0);
	
	lien1.appendChild(titre);
	span1.appendChild(lien1);
	cellule1.appendChild(span1);
	
	strong2.appendChild(kilometrage);
	cellule2.appendChild(strong2);
		
	
	strong3.appendChild(texteNote);
	cellule3.appendChild(strong3);
	
	
	if(tableauWaypointRoutes.length==0 && positionRouteAttente==1)
	{
	var insererEtapeTextPrems=document.createTextNode(tabRtes4);
	var br1=document.createElement('br');	
	cellule4.appendChild(insererEtapeTextPrems);
	cellule4.appendChild(insertionEtapePrecPrems);
	cellule4.appendChild(br1);
	}
	if(positionRoute==0)
	{
	cellule4.appendChild(boutonAjouter);
		if(nombreTotalRoutesAjoutees>0)
		{
		var positionText=document.createTextNode(tabRtes5);
		cellule4.appendChild(positionText);
		}
	}
	else if(nombreTotalRoutesAjoutees>1)
	{
	cellule4.appendChild(boutonDeplacer);
	var numeroText=document.createTextNode(tabRtes6);
		cellule4.appendChild(numeroText);
	}
	if(nombreTotalRoutesAjoutees>1 ||(positionRoute==0 && nombreTotalRoutesAjoutees>0 ))cellule4.appendChild(menuDeroulant);
	if(nombreTotalRoutesAjoutees>1 && positionRoute>0)
	{
		if(positionRoute>1)
		{
			var ouText=document.createTextNode(tabRtes7);
			cellule4.appendChild(ouText);
		}
		if(positionRoute>1) cellule4.appendChild(lienDeplUp);
		if(positionRoute<nombreTotalRoutesAjoutees) cellule4.appendChild(lienDeplDown);
		var br3=document.createElement('br');
		cellule4.appendChild(br3);
		var actionsText=document.createTextNode(" Actions : ");
	cellule4.appendChild(actionsText);
	}
	
	cellule4.appendChild(lienZoom);
	if(positionRoute>0)cellule4.appendChild(lienSuppr);
	if(positionRoute>0)
	{
	if(type==1)cellule4.appendChild(lienInvert);
	var insererEtapeText=document.createTextNode(tabRtes4);
	var br4=document.createElement('br');
	cellule4.appendChild(br4);
	cellule4.appendChild(insererEtapeText);
	cellule4.appendChild(insertionEtapePrec);
	cellule4.appendChild(insertionEtapeSuiv);
	}
	

ligneRoute.appendChild(cellule0);	
ligneRoute.appendChild(cellule1);
ligneRoute.appendChild(cellule2);
ligneRoute.appendChild(cellule3);
ligneRoute.appendChild(cellule4);

$(idTbody).appendChild(ligneRoute);

}

function isInsideHippodrome(pt1,pt2,ptTest,d)
{
var isInside=0;

if(pointCloserThan(pt1,pt2,ptTest,d) || distanceTwoPoints(pt1,ptTest)<d || distanceTwoPoints(ptTest,pt2)<d) isInside=1;

return(isInside);
}

function ajouterRouteRbk(numRoute,premiere,location){
remplirTableStringsEtapes();

	if(premiere>0)
	{
	if(location=='tableau') var positionAjout=$('tableSelect'+numRoute).options[$('tableSelect'+numRoute).selectedIndex].value;
	else var positionAjout=$('infoWindowSelect'+numRoute).options[$('infoWindowSelect'+numRoute).selectedIndex].value;
	}
	
	else
	{
	var positionAjout=1;
	}
	tableRoutesSelectionnees.insertElement(numRoute,positionAjout);


if(positionAjout==1)
{
	if(nombreRoutesAjoutees==0)
	{
	tableauWaypointRoutes.push('R');
	}
	else
	{
	//on recherche à quelle position est la première route
	var p=0;
	
	while(tableauWaypointRoutes[p]!='R')p++;
	tableauWaypointRoutes.insertElement('R',p);
	
	}
}
else
{
var k=0;
var nombreRoutesTrouvees=0;
	while(nombreRoutesTrouvees<positionAjout-1)
	{
	if(tableauWaypointRoutes[k]=='R')nombreRoutesTrouvees++;
	k++;
	}
	
	tableauWaypointRoutes.insertElement('R',k);

}
	
function nullOrder(marker,b) {
        return 0;
      }


 		var iconeDRoute = new GIcon(G_DEFAULT_ICON);
		 iconeDRoute.image = "/images/icones/creerRoadbooks/routeIn.png";
		 iconeDRoute.shadow = "";
		 iconeDRoute.iconSize = new GSize(16, 16);  
		 iconeDRoute.iconAnchor = new GPoint(8, 16);          
		 markerOptionsDRoute = { icon:iconeDRoute, draggable:1, zIndexProcess:nullOrder };
		 
		 departMarkerRoute[numRoute] = new GMarker(departRoute[numRoute],markerOptionsDRoute);
			map.addOverlay(departMarkerRoute[numRoute]);
			
			var iconeARoute = new GIcon(G_DEFAULT_ICON);
		 iconeARoute.image = "/images/icones/creerRoadbooks/routeOut.png";
		 iconeARoute.shadow = "";
		 iconeARoute.iconSize = new GSize(16, 16);  
		 iconeARoute.iconAnchor = new GPoint(8, 16);         
		 markerOptionsARoute = { icon:iconeARoute, draggable:1, zIndexProcess:nullOrder };
		 
		 arriveeMarkerRoute[numRoute] = new GMarker(arriveeRoute[numRoute],markerOptionsARoute);
			map.addOverlay(arriveeMarkerRoute[numRoute]);
			
GEvent.addListener(departMarkerRoute[numRoute], "dragend", 
		function() {collerMarkerRoute(numRoute,'D')});
GEvent.addListener(arriveeMarkerRoute[numRoute], "dragend", 
		function() {collerMarkerRoute(numRoute,'A')});
	if(listeTypesSites[numRoute]!=1){
		departMarkerRoute[numRoute].hide();
		arriveeMarkerRoute[numRoute].hide();
	}
nombreRoutesAjoutees++;
calculTableauRoutesEtEtapes();
miseAJourIconesRoutesSel();
map.removeControl(OverviewMapControl);
map.closeInfoWindow();
}

function viderTableRoutes(){
$('listeRoutesTable').removeChild($('listeRoutesBody'));

			var tBody=document.createElement('tbody');
			tBody.setAttribute('id','listeRoutesBody');
			$('listeRoutesTable').appendChild(tBody);
}



function calculTableauRoutesEtEtapes() {
viderTableRoutes();
var compteurRoutes=0;
var compteurEtapes=0;
var premDer=1;

if(tableauWaypointRoutes.length==0 && arrayListeRoutes.length==0)
{
var ligneRoute=document.createElement('tr');
	var cellule0NoR=document.createElement('td');	
	 var textNoRoads=document.createTextNode(tabRtes8);
	 var strongNoRoads=document.createElement('strong');
	 strongNoRoads.appendChild(textNoRoads);
	var textInsert=document.createTextNode(tabRtes9); 
	if(document.all)
	{
	var insertionEtapePrecPrems=document.createElement('<a href="javascript:void(0);"  onclick="ajouterEtapePrems();">');
	var imageInsertionPrecPrems=document.createElement('<img src="/images/icones/upAj25.png" style="margin-left:4px;" border="0"/>');
	}
	else
	{
		var insertionEtapePrecPrems=document.createElement('a');
	var imageInsertionPrecPrems=document.createElement('img');
	
	insertionEtapePrecPrems.setAttribute("href","javascript:void(0);");	
	insertionEtapePrecPrems.setAttribute("onclick","ajouterEtapePrems();");
	
	imageInsertionPrecPrems.setAttribute("src","/images/icones/upAj25.png");
	imageInsertionPrecPrems.setAttribute("style","margin-left:4px;");
	imageInsertionPrecPrems.setAttribute("border","0");
	}
	insertionEtapePrecPrems.appendChild(imageInsertionPrecPrems);
	cellule0NoR.appendChild(strongNoRoads);
	cellule0NoR.appendChild(textInsert);
	cellule0NoR.appendChild(insertionEtapePrecPrems);
	ligneRoute.appendChild(cellule0NoR);
	$('listeRoutesBody').appendChild(ligneRoute);
}

else
{
	//if(test)alert(tableauWaypointRoutes.join(','));
	for(var l=0;l<tableauWaypointRoutes.length;l++)
	{
		if(tableauWaypointRoutes[l]=='R')
		{
			
		compteurRoutes++;
		var numRouteAjoutee=tableRoutesSelectionnees[compteurRoutes];
		
		
		creerLigneRoute(listeInfosRoute[numRouteAjoutee],compteurRoutes,nombreRoutesAjoutees,'listeRoutesBody');
		
		//on regarde si il y a besoin d'inverser départ et arrivée
			if(l>0) //si ce n'est pas le premier élément
			{
				//on recherche le premier element non vide précédent
				var p=1;
				var compteurEtapesLoc=compteurEtapes;
				var boucleRecherche=0;
				while(p<=l && tableauWaypointRoutes[(l-p)]!='R' && markersEtape[compteurEtapesLoc]==null)
					{
						boucleRecherche=1;
						compteurEtapesLoc--;
						if(p<l)p++;
						else break;
					 }
					 
				if(p==l && boucleRecherche==1) //cette route est le premier élément non nul
				{
					if(document.mainForm.typeRbk[1].checked)var markerPrems=markerDepartArr;
					else var markerPrems=markerDepart;
					if(distanceTwoPoints(departMarkerRoute[numRouteAjoutee].getLatLng(),markerPrems.getLatLng())>distanceTwoPoints(arriveeMarkerRoute[numRouteAjoutee].getLatLng(),markerPrems.getLatLng()))
																																																																	                    {
					InvertRouteRbk(numRouteAjoutee);																																																											
																																																															                    }
				}
				else
				{
				
				if(tableauWaypointRoutes[(l-p)]=='E')
				{
				if(distanceTwoPoints(departMarkerRoute[numRouteAjoutee].getLatLng(),markersEtape[compteurEtapesLoc].getLatLng())>distanceTwoPoints(arriveeMarkerRoute[numRouteAjoutee].getLatLng(),markersEtape[compteurEtapesLoc].getLatLng()))
																																																																	                    {
					InvertRouteRbk(numRouteAjoutee);																																																											
																																																															                    }
				}
				else
				{
					var cptRoutePrec=compteurRoutes-1;
					var idRoutePrec=tableRoutesSelectionnees[cptRoutePrec];
				if(distanceTwoPoints(departMarkerRoute[numRouteAjoutee].getLatLng(),arriveeMarkerRoute[idRoutePrec].getLatLng())>distanceTwoPoints(arriveeMarkerRoute[numRouteAjoutee].getLatLng(),arriveeMarkerRoute[idRoutePrec].getLatLng()))
																																																																	                    {
					InvertRouteRbk(numRouteAjoutee);																																																											
																																																															                    }
				}
			}
			}
			else
			{
				
				if(document.mainForm.typeRbk[1].checked)var markerPrems=markerDepartArr;
					else var markerPrems=markerDepart;
					
					if(distanceTwoPoints(departMarkerRoute[numRouteAjoutee].getLatLng(),markerPrems.getLatLng())>distanceTwoPoints(arriveeMarkerRoute[numRouteAjoutee].getLatLng(),markerPrems.getLatLng()))
																																																																	                    {
					InvertRouteRbk(numRouteAjoutee);																																																											
																																																															                    }
			}
		
		}
		
		if(tableauWaypointRoutes[l]=='E')
		{
			premDer=1;
		compteurEtapes++;
		if(l==0) premDer=0;
		if(l==tableauWaypointRoutes.length-1) premDer=2;
		if(tableauWaypointRoutes.length<2) premDer=4;
		if(tableStatusMarkersEtape[compteurEtapes]==1) var statusMarker=1;
		else var statusMarker=0;
		
		if(typeof(listeInfosEtapes[compteurEtapes])=='undefined') var stringSaisie='';
		else var stringSaisie=listeInfosEtapes[compteurEtapes]
		creerLigneEtape(compteurEtapes,statusMarker,stringSaisie,premDer,'listeRoutesBody')		
		
		}
	
	}
	var nbRoutesNonSel=1;
	for(var z=0;z<arrayListeRoutes.length;z++)
	{
		
		if(tableRoutesSelectionnees.in_array(arrayListeRoutes[z])==false)
		{
		creerLigneRoute(listeInfosRoute[arrayListeRoutes[z]],0,nombreRoutesAjoutees,'listeRoutesBody',nbRoutesNonSel);	
		nbRoutesNonSel++;
		}
	
	}
}
}

function miseAJourIconesRoutesSel()
{
	
	for(var t=1;t<tableRoutesSelectionnees.length;t++)
	{
		
	markerRoute[tableRoutesSelectionnees[t]].setImage('/images/icones/creerRoadbooks/routeSel'+t+'_rsz.png');
	markerRoute[tableRoutesSelectionnees[t]].show();	
	if(typeof(geoXmlRoutes[tableRoutesSelectionnees[t]])!='undefined')
	{
		//alert(geoXmlRoutes[tableRoutesSelectionnees[t]]));
		if(geoXmlRoutes[tableRoutesSelectionnees[t]]!=null) geoXmlRoutes[tableRoutesSelectionnees[t]].show();
		
	}
	
	}
	var nbRoutesNonSel=1;
	for(var p=0;p<arrayListeRoutes.length;p++)
	{ 
	
		if(!tableRoutesSelectionnees.in_array(arrayListeRoutes[p]))
		{
			markerRoute[arrayListeRoutes[p]].setImage('/images/icones/creerRoadbooks/routeAttente'+nbRoutesNonSel+'_rsz.png');
			markerRoute[arrayListeRoutes[p]].show();
			if(geoXmlRoutes[arrayListeRoutes[p]]!=null)geoXmlRoutes[arrayListeRoutes[p]].show();
			nbRoutesNonSel++;
		}
	}
	
	for(var r=1;r<tableStatusMarkersEtape.length;r++)
	{ 
		if(markersEtape[r]!=null)
		{
		markersEtape[r].setImage("/images/icones/creerRoadbooks/etape"+r+"_rsz.png");
		if(tableStatusMarkersEtape[r]==1)markersEtape[r].show();
		}
	}
	

}


function deplacerRouteRbk(numRoute,location){
remplirTableStringsEtapes();
	
	if(location=='tableau') var positionDepl=$('tableSelect'+numRoute).options[$('tableSelect'+numRoute).selectedIndex].value;
	else if(location==100000) var positionDepl=$('infoWindowSelect'+numRoute).options[$('infoWindowSelect'+numRoute).selectedIndex].value;
	else var positionDepl=location;
	
	//on récupère la position dans le tableau Global Actuel
	for(var i = 0; i < tableRoutesSelectionnees.length; i++) {
		if(tableRoutesSelectionnees[i] == numRoute) {
			var positionRoute=i;
		}
	}
	
	var k=0;
	var nombreRoutesTrouvees=0;
	while(nombreRoutesTrouvees<positionRoute)
	{
	if(tableauWaypointRoutes[k]=='R')nombreRoutesTrouvees++;
	k++;
	}
	
	tableauWaypointRoutes.removeElementIndex((k-1));


	//on la vire, puis on la rajoute à la position voulue	
	if(positionDepl==1)
	{
		if(nombreRoutesAjoutees==0)
		{
		tableauWaypointRoutes=new Array();
		tableauWaypointRoutes[0]='R';
		}
		else
		{
		//on recherche à quelle position est la première route
		var p=0;
		while(tableauWaypointRoutes[p]!='R')p++;
		tableauWaypointRoutes.insertElement('R',p);
		}
	}
	else
	{
	var z=0;
	var nombreRoutesTrouvees=0;
		while(nombreRoutesTrouvees<positionDepl-1)
		{
		if(tableauWaypointRoutes[z]=='R')nombreRoutesTrouvees++;
		z++;
		}
		
		tableauWaypointRoutes.insertElement('R',z);
	
	}
	
	//même procédé dans le tableau des routes
	
	tableRoutesSelectionnees.removeElement(numRoute);
	tableRoutesSelectionnees.insertElement(numRoute,positionDepl);
	
calculTableauRoutesEtEtapes();
miseAJourIconesRoutesSel();
map.removeControl(OverviewMapControl);
map.closeInfoWindow();
}


function retirerRouteRbk(numRoute) {
remplirTableStringsEtapes();
//compter la position de la route dans le tableau des routes sélectionnées
var positionRoute=0;
for(var t=0;t<tableRoutesSelectionnees.length;t++)
{
 if(tableRoutesSelectionnees[t]==numRoute) positionRoute=t;
}
//recalculer le tableau routes + etapes
var k=0;
var nombreRoutesTrouvees=0;
	while(nombreRoutesTrouvees<positionRoute)
	{
	if(tableauWaypointRoutes[k]=='R')nombreRoutesTrouvees++;
	k++;
	}
tableauWaypointRoutes.removeElementIndex((k-1));
//
tableRoutesSelectionnees.removeElement(numRoute);
departMarkerRoute[numRoute].hide();
arriveeMarkerRoute[numRoute].hide();
markerRoute[numRoute].hide();
if(geoXmlRoutes[arrayListeRoutes[numRoute]]!=null)geoXmlRoutes[numRoute].hide();
nombreRoutesAjoutees--;

calculTableauRoutesEtEtapes();
miseAJourIconesRoutesSel();
map.removeControl(OverviewMapControl);
map.closeInfoWindow();
revenirZoomInitial();
}

function creerImageAttente(idTbody)
{
if(document.all)
	{
	var ligneAttente=document.createElement('<tr id="ligneAttenteUpload">');
	var celluleAttente=document.createElement('<td class="sujet" style="text-align:center;">');
	var imageAttente=document.createElement('<img src="/images/icones/'+precalc1+'.gif"/>');
	}
	else
	{
	var ligneAttente=document.createElement('tr');
	var celluleAttente=document.createElement('td');
	var imageAttente=document.createElement('img');
	
	ligneAttente.setAttribute('id','ligneAttenteUpload');
	
	celluleAttente.setAttribute('class','sujet');
	celluleAttente.setAttribute('style','text-align:center;');
	imageAttente.setAttribute('src','/images/icones/'+precalc1+'.gif');
	}
	celluleAttente.appendChild(imageAttente);
	ligneAttente.appendChild(celluleAttente);	
	$(idTbody).appendChild(ligneAttente);		
}

function InvertRouteRbk(id){
var positionActDepart=departMarkerRoute[id].getLatLng();
var positionActArrivee=arriveeMarkerRoute[id].getLatLng();
departMarkerRoute[id].setLatLng(positionActArrivee);
arriveeMarkerRoute[id].setLatLng(positionActDepart); 
}

function collerMarkerRoute(numRoute,depOuArr) {
if(depOuArr=='D') var latLngPt=departMarkerRoute[numRoute];
else var latLngPt=arriveeMarkerRoute[numRoute];
setCloserPointOnRoad(latLngPt,numRoute);

}

function htmlInfoWindowMarker(stringInfos)
{

var tableDatasInfowindow=stringInfos.split('[#]');

if(tableDatasInfowindow[6]!=1)
{
var lngIW2c=lngIW2b;
var lngIW4c=lngIW4b;
var lngIW7c=lngIW7b;
var lngIW9c=lngIW9b;
var lngIW10c=lngIW10b;

}
else
{
var lngIW2c=lngIW2;
var lngIW4c=lngIW4;
var lngIW7c=lngIW7;
var lngIW9c=lngIW9;
var lngIW10c=lngIW10;	
	
}

htmlMarkerRoute[tableDatasInfowindow[4]]='<p style="font-size:14px; font-weight:bold;">'+tableDatasInfowindow[0]+'</p><p>'+lngIW1+' : <strong>'+tableDatasInfowindow[1]+'/5</strong></p>';
htmlMarkerRoute[tableDatasInfowindow[4]]+='<ul><li style="margin-left:0px;">'+lngIW13+' : '+tableDatasInfowindow[7]+'</li></ul>';
urlWithQuotes="'"+tableDatasInfowindow[5]+"'";
				if(tableDatasInfowindow[2]>0)
				{
				
					if(document.all)
					{
						if(tableDatasInfowindow[3]<1)
						{
					htmlMarkerRoute[tableDatasInfowindow[4]]+='<div class="imageSeule"><a href="#map_canvas" onclick="javascript:window.open('+urlWithQuotes+');"><img src="images/imagesUploadees/'+tableDatasInfowindow[2]+'.jpg" width="150" ></a></div>';
						 }
						 else
						 {
						 htmlMarkerRoute[tableDatasInfowindow[4]]+='<div class="imageSeule"><a href="#map_canvas" onclick="javascript:window.open('+urlWithQuotes+');"><img src="images/imagesUploadees/'+tableDatasInfowindow[2]+'.jpg" height="150" ></a></div>';
						 }
 
					}
					else
					{
					if(tableDatasInfowindow[3]<1)
						{
					htmlMarkerRoute[tableDatasInfowindow[4]]+='<div class="imageSeule" style="height:100px;"><a href="#map_canvas" onclick="javascript:window.open('+urlWithQuotes+');"><img src="images/imagesUploadees/'+tableDatasInfowindow[2]+'.jpg" width="150" ></a></div>';
						 }
						 else
						 {
						 htmlMarkerRoute[tableDatasInfowindow[4]]+='<div class="imageSeule" style="height:150px;" onclick="javascript:window.open('+urlWithQuotes+');"><a href="#map_canvas"><img src="images/imagesUploadees/'+tableDatasInfowindow[2]+'.jpg" height="150" ></a></div>';
						 }
					
					}
			}
				htmlMarkerRoute[tableDatasInfowindow[4]]+='<ul><li style="margin-left:0px;"><a href="#map_canvas" onclick=" javascript:window.open('+urlWithQuotes+');"> '+lngIW2c+'</a></li> <li style="margin-left:0px;"> <a href="#map_canvas" onclick="revenirZoomInitial();"> '+lngIW3+'</a></li></ul>';
				
				var numDernierePosition=nombreRoutesAjoutees+1;
				if(tableRoutesSelectionnees.in_array(tableDatasInfowindow[4]))
				{
				
				htmlMarkerRoute[tableDatasInfowindow[4]]+='<ul><li style="margin-left:0px;">'+lngIW4c+' <select id="infoWindowSelect'+tableDatasInfowindow[4]+'" >';
						for(var l=1;l<=nombreRoutesAjoutees;l++)
						{
						htmlMarkerRoute[tableDatasInfowindow[4]]+='<option value="'+l+'">'+l+'</option>"';
						}
					htmlMarkerRoute[tableDatasInfowindow[4]]+='</select><input type="button" value="'+lngIW5+'" onclick="javascript:deplacerRouteRbk('+tableDatasInfowindow[4]+',100000);"></li></ul>';
				
				htmlMarkerRoute[tableDatasInfowindow[4]]+='<ul><li style="margin-left:0px;">'+lngIW10c+' <input type="button" value="'+lngIW12+'" onclick="javascript:retirerRouteRbk('+tableDatasInfowindow[4]+');"></li></ul>';
				
				if(tableDatasInfowindow[6]==1)
				{
				htmlMarkerRoute[tableDatasInfowindow[4]]+='<ul><li style="margin-left:0px;">'+lngIW6+'<a href="javascript:void(0);"  onclick="InvertRouteRbk('+tableDatasInfowindow[4]+');"><img src="images/icones/googleMaps/croisement/inversion.gif" style="border:none;"/></a></li></ul>';
				}
	
				}
				else
				{
					if(nombreRoutesAjoutees>0)
					{
					htmlMarkerRoute[tableDatasInfowindow[4]]+='<ul><li style="margin-left:0px;">'+lngIW7c+'<select id="infoWindowSelect'+tableDatasInfowindow[4]+'" >';
						for(var l=1;l<=nombreRoutesAjoutees;l++)
						{
						htmlMarkerRoute[tableDatasInfowindow[4]]+='<option value="'+l+'">'+l+'</option>"';
						}
					htmlMarkerRoute[tableDatasInfowindow[4]]+='<option value="'+numDernierePosition+'" selected="selected">'+lngIW8+'</option></select><input type="button" value="'+lngIW11+'" onclick="javascript:ajouterRouteRbk('+tableDatasInfowindow[4]+',1,0);"></li></ul>';
					}
					else
					{
					htmlMarkerRoute[tableDatasInfowindow[4]]+='<ul><li style="margin-left:0px;">'+lngIW9c+'<input type="button" value="'+lngIW11+'" onclick="javascript:ajouterRouteRbk('+tableDatasInfowindow[4]+',0);"></li></ul>';
					}
				}
	
	
}


function cacherRoutesKML()
{
	for(var i=0;i<arrayListeRoutes.length;i++)
	{
		if(geoXmlRoutes[arrayListeRoutes[i]]!=null)geoXmlRoutes[arrayListeRoutes[i]].hide();
		
		markerRoute[arrayListeRoutes[i]].hide();
		
	}
}



function zoomerRoute(id)
{


map.addControl(OverviewMapControl);
var zoom=map.getCurrentMapType().getBoundsZoomLevel(geoXmlRoutes[id].getDefaultBounds(), map.getSize()) ;
	map.setCenter(centreRoute[id],zoom);
	htmlInfoWindowMarker(tableInfoWindowMarker[id]);
markerRoute[id].openInfoWindowHtml(htmlMarkerRoute[id]);

	
}

function zoomerSite(id)
{


map.addControl(OverviewMapControl);
var zoom=13;
	map.setCenter(centreRoute[id],zoom);
	htmlInfoWindowMarker(tableInfoWindowMarker[id]);
markerRoute[id].openInfoWindowHtml(htmlMarkerRoute[id]);

	
}

function revenirZoomInitial()
{

map.removeControl(OverviewMapControl);
map.closeInfoWindow();
map.setCenter(new GLatLng(latInit,lngInit),zoomInit);
markerWaypoint.hide();

}



function effacerOverlaysPrecomputations(type)
{
	if(type=='boucle')
	{
	 //efface zone boucle si elle existe
		  if(typeof(polygoneZoneAfficheeBoucle)=='object'  && polygoneZoneAfficheeBoucle!=null)
				{ 
				
					polygoneZoneAfficheeBoucle.hide();
					
				}
			if(typeof(markerDepartArr)=='object')
			{
			markerDepartArr.hide();
			}
	}
	
	if(type=='trajet')
	{
				if(typeof(polygoneZoneAffichee)=='object' && polygoneZoneAffichee!=null)
				{ 
					
					polygoneZoneAffichee.hide();
				
				}
				
		/*if(typeof(polylineAffichee)=='object' && polylineAffichee!=null)
		{ 
			
			polylineAffichee.hide();			
		}*/
		
		
			if(typeof(markerDepart)=='object')
			{
			markerDepart.hide();
			}
			if(typeof(markerArrivee)=='object')
			{
			markerArrivee.hide();
			}
	}
}

function changeRadio(numBouton)
{
	if(numBouton!=boutonRadioTypeTrajet)
	{
		if(numBouton==0)
		{
			if(routePreCalculeeBool==0)
			{
		effacerOverlaysPrecomputations('boucle');
		cacherRoutesKML();
		resetMap();
		resetAll();
			}
		if(typeRoutePrecalc==1)modifTypeRteApPrecalc=1;
		else modifTypeRteApPrecalc=0;
		boutonRadioTypeTrajet=0;
		}
		else
		{
		if(routePreCalculeeBool==0)
			{
		effacerOverlaysPrecomputations('trajet');
		cacherRoutesKML();
		resetMap();
		resetAll();
			}
		if(typeRoutePrecalc==0)modifTypeRteApPrecalc=1;
		else modifTypeRteApPrecalc=0;
		boutonRadioTypeTrajet=1;
		}
	
	
	}

}


function affichageTrajets(selObj)
{

	if(selObj.checked)
	{
	polylineAffichee.hide();  
	polylineAfficheeInv.show();  
	}
	else
	{	
	polylineAfficheeInv.hide();  
	polylineAffichee.show();  
	}
}

//fonctions de géolocalisation



function changerBaseCountry(selObj)
{
var tableCode=selObj.options[selObj.selectedIndex].value.split('[#]');
var codePays=tableCode[1];
geocoder.setBaseCountryCode(codePays);
//alert(codePays);
}

function activerAttenteRoute()
{
AfficherElement('imageAttenteCalcul');
CacherElement('texteVoirTrace'); //
CacherElement('erreursCalcul');
CacherElement('texteRouteOK'); //
CacherElement('erreursCalculBoucle'); //
CacherElement('erreursCalculBoucleGoogle');
}
function routeCalculee()
{
CacherElement('imageAttenteCalcul');
AfficherElement('texteRouteOK');
}

function erreursCalcul()
{
CacherElement('imageAttenteCalcul');
AfficherElement('erreursCalcul');
}

function erreursCalculBoucle()
{
CacherElement('imageAttenteCalcul');
AfficherElement('erreursCalculBoucle');
}

function erreursCalculBoucleGoogle()
{
CacherElement('imageAttenteCalcul');
AfficherElement('erreursCalculBoucleGoogle');
}

function typeRbkAction(idCheckBox)
{
 if(idCheckBox=='trajet')
 {
 AfficherElement('tableTrajet');
 CacherElement('tableBoucle');
 }
 else
 {
 AfficherElement('tableBoucle');
 CacherElement('tableTrajet');
 }
}


function recupCoordonneesMarker(marker,inputCible)
{
var coordonnes=marker.getLatLng();
var inputDestination=document.getElementById(inputCible);

inputDestination.setAttribute('value',coordonnes.lat()+' '+coordonnes.lng());

}

function zoomPositionActuelle(type){

		//récup des coordonnées du marker
		if(type=='pointDepart')
		{
        map.setCenter(markerDepart.getLatLng(), 14);
		}
		if(type=='pointArrivee')
		{
        map.setCenter(markerArrivee.getLatLng(), 14);
		}
		if(type=='pointDepartArr')
		{
        map.setCenter(markerDepartArr.getLatLng(), 14);
		}
		 
		 if(type.substr(0,10)=='pointEtape')
		 {
		 numMarker=type.substr(10);
		 map.setCenter(markersEtape[numMarker].getLatLng(), 14);
			 }
        
}


function zoomGeoloc(idInput){
var formulairePays=$('paysSelect');
var nomPays=formulairePays.options[formulairePays.selectedIndex].text;
var adresseSaisie=document.getElementById(idInput).value;
var adress=adresseSaisie+', '+nomPays;

	function placerMarker(idInput,point)
	{
	var icone = new GIcon(G_DEFAULT_ICON);
		
		 if(idInput.substr(0,10)=='pointEtape')
		 {
		 icone.image = "/images/icones/creerRoadbooks/etape"+idInput.substr(10)+"_rsz.png";
		 }
		 icone.shadow = "";
		 icone.iconSize = new GSize(18, 19); 
		 icone.iconAnchor = new GPoint(9, 9); 
		 markerOptions = { icon:icone, draggable:1 };
		 
		 
		if(idInput=='pointDepart')
		{ 
		CacherElement('erreurDep');
		document.getElementById('statusDepart').setAttribute("src", "/images/icones/OK.png");
		boolStatusDepart=1;
			if(markerDepart.getLatLng().lat()==0 && markerDepart.getLatLng().lng()==0)
			{
				map.addOverlay(markerDepart);
			
			}	
			var boutonZoom=document.getElementById('boutonZoomDepart');
			if(document.all) boutonZoom.style.setAttribute("cssText","display:auto;");
 			else boutonZoom.setAttribute("style", "display:auto;");
			markerDepart.setLatLng(point);
			markerDepart.show();
		}
		
			if(idInput=='pointDepartArr')
		{ 
		CacherElement('erreurDepArr');
		document.getElementById('statusDepartArr').setAttribute("src", "/images/icones/OK.png");
		boolStatusDepartArr=1;
			if(markerDepartArr.getLatLng().lat()==0 && markerDepartArr.getLatLng().lng()==0)
			{			
			map.addOverlay(markerDepartArr);
			
			}
			var boutonZoom=document.getElementById('boutonZoomDepartArr');
			if(document.all) boutonZoom.style.setAttribute("cssText","display:auto;");
 			else boutonZoom.setAttribute("style", "display:auto;");
			markerDepartArr.setLatLng(point);
			markerDepartArr.show();
			
		
        
		}
		 if(idInput=='pointArrivee')
		 {
			 CacherElement('erreurArr');
		  document.getElementById('statusArrivee').setAttribute("src", "/images/icones/OK.png");
		  boolStatusArrivee=1;
		  
		 			if(markerArrivee.getLatLng().lat()==0 && markerArrivee.getLatLng().lng()==0)
			{
				map.addOverlay(markerArrivee);
			
			}
			var boutonZoom=document.getElementById('boutonZoomArrivee');
			if(document.all) boutonZoom.style.setAttribute("cssText","display:auto;");
 			else boutonZoom.setAttribute("style", "display:auto;");
			markerArrivee.setLatLng(point);
			markerArrivee.show();
			

		 }
		 
		 
		 if(idInput.substr(0,10)=='pointEtape')
		 {
		 numMarker=idInput.substr(10);
		 CacherElement('erreurGeolocEtape'+numMarker);
		 tableStatusMarkersEtape[numMarker]=1;
		 
			var boutonZoom=document.getElementById('boutonZoomEtape'+numMarker);			
			if(document.all) boutonZoom.style.setAttribute("cssText","display:auto");
 			else boutonZoom.setAttribute("style", "display:auto;");
			
		 document.getElementById('statusEtape'+numMarker).setAttribute("src", "/images/icones/OK.png");
			 if(typeof(markersEtape[numMarker])=='undefined' || markersEtape[numMarker]==null)
				{
			 markersEtape[numMarker] = new GMarker(point,markerOptions);
			 map.addOverlay(markersEtape[numMarker]);
			 
			 //on rend visible le bouton zoom 
			//on valide le status du marker
			
			 }
			 else
			 {
			 markersEtape[numMarker].show();
			 markersEtape[numMarker].setLatLng(point);
			 	
			 }
        
		 }
		 
      }
if(adresseSaisie.length>0)
{
geocoder.getLocations(
    adress,
    function(response) {
      if (typeof(response.Placemark)=='undefined') {
		  
       erreurGeoloc(idInput);
      } else {
	  //alert(response.Placemark.length);
	   place = response.Placemark[0];
	 	point=new GLatLng(place.Point.coordinates[1],
                            place.Point.coordinates[0]);

        map.setCenter(point, 14);
		placerMarker(idInput,point)
	}
    }
  );
  }
  else
  {
  placerMarker(idInput,map.getCenter());
  }
}

function resetAll(){
cacherMarkersEtapes();	
document.getElementById('statusDepart').setAttribute("src", "/images/icones/NOK.png");
document.getElementById('statusArrivee').setAttribute("src", "/images/icones/NOK.png");
document.getElementById('statusDepartArr').setAttribute("src", "/images/icones/NOK.png");
AfficherElement('departEtArrivee');
AfficherElement('preCalculs');
AfficherElement('texteVoirTrace');
CacherElement('erreursCalcul');
CacherElement('erreursCalculBoucle');
CacherElement('texteRouteOK');
CacherElement('routesEtEtapes');
CacherElement('infosRoadbook');
CacherElement('calculerRoute');
CacherElement('tableDrivingDirections');
markerWaypoint.hide();
markerDepart.hide();
markerArrivee.hide();
markerDepartArr.hide();
CacherElement('boutonZoomArrivee');
CacherElement('boutonZoomDepart');
CacherElement('boutonZoomDepartArr');
viderTableRoutes();
cacherRoutesKML();
//if(typeof(polylineAffichee)=='object' && polylineAffichee!=null)
if(polylineCurrent>=0)
		{ 
			
			polylineAffichee[polylineCurrent].hide();
		}

markersEtape = new Array();
tableStatusMarkersEtape = new Array();

listeNotesRoute=new Array(); 
listeInfosRoute=new Array();//tableau contenant le string infos de la route
listeInfosEtapes=new Array();  //la liste des étapes (centre, nom saisi, status)
arrayListeRoutes=new Array(); //liste de toutes les routes dans la zone d'intérêt
tableRoutesSelectionnees=new Array(); // la liste des routes sélectionnées pour le roadbook,  par ID
tableauWaypointRoutes=new Array(); //tableau contenant R ou E (pour étape ou Route)
nombreRoutesAjoutees=0;
nombreEtapesAjoutees=0;
modifTypeRteApPrecalc=0;	
}

function routePreCalculee()
{
	routePreCalculeeBool=1;
/*//CacherElement('imageAttenteCalcul');
AfficherElement('texteRouteOK');
if(document.mainForm.typeRbk[1].checked) CacherElement('elargZoneTraj');
else CacherElement('elargZoneBoucle');
CacherElement('departEtArrivee');
CacherElement('preCalculs');
AfficherElement('augZone');*/
}

function resetChgtTypePrecalc()
{
	if(modifTypeRteApPrecalc)
	{
		
		if(typeRoutePrecalc)effacerOverlaysPrecomputations('boucle');
		else effacerOverlaysPrecomputations('trajet');
		cacherRoutesKML();
		CacherElement('routesEtEtapes');
		resetMap();
		resetAll();
	}
}

function onGDirectionsError()
{
	alert('error '+gdir.getStatus());
gdir.clear();

calculTableauRoutesEtEtapes();
	
}

function erreurGeoloc(idInput)
{
if(idInput=='pointDepart')
		{ 
		AfficherElement('erreurDep');
		
		}
		
			if(idInput=='pointDepartArr')
		{ 
		AfficherElement('erreurDepArr');
		
		}
		 if(idInput=='pointArrivee')
		 {
			 AfficherElement('erreurArr');
		 }
		 if(idInput.substr(0,10)=='pointEtape')
		 {
		 numMarker=idInput.substr(10);
		 AfficherElement('erreurGeolocEtape'+numMarker);
		 }
}
