function calculerRoute()
{
	
	//calcul du type de trajet
	var trajetBoucle=0;
	var queEtapes=1;
	var etapesOff=1;
	if(markerDepartArr.getLatLng().lat()!=0 && markerDepartArr.getLatLng().lng()!=0)
	{
		if(markerDepartArr.isHidden()==0)
		{
			 trajetBoucle=1;	
		}
		
	}
	if(trajetBoucle==1)
	{
		// on regarde si il n'y a que des etapes
		for(var t=0;t<tableauWaypointRoutes.length;t++)
		{
		if(tableauWaypointRoutes[t]=='R')
			{
				queEtapes=0;
			}
		}
		if(queEtapes==1)
		{
			for(var h=0;h<tableStatusMarkersEtape.length;h++)
			{
				if(tableStatusMarkersEtape[h]==1)
					{
						etapesOff=0;
					}
			}
		}
		
	}
	
	if(trajetBoucle==1 && (tableauWaypointRoutes.length==0 || (queEtapes==1 && etapesOff==1)))
	{
	attenteCalculRoute();
	CacherElement('imageAttenteCalculRoute'+stringCalculDirect);
	AfficherElement('erreursCalculRouteBouclePasEtape'+stringCalculDirect);		
	}
	else
	{
	reponseServerGoogleOK=0;	
	attenteCalculRoute();
	
	var stringPostWPRoute='';
	var compteurEtapes=1;
	var compteurRoutes=1;
	
	if(tableauWaypointRoutes.length)
	{
	for(var t=0;t<tableauWaypointRoutes.length;t++)
	{
		if(tableauWaypointRoutes[t]=='E')
		{
			if(tableStatusMarkersEtape[compteurEtapes]==1)
			{
		stringPostWPRoute+='E[*]'+markersEtape[compteurEtapes].getLatLng().lat()+'[-]'+markersEtape[compteurEtapes].getLatLng().lng();
			}
		compteurEtapes++;
		}
		else
		{
		var idRoute=tableRoutesSelectionnees[compteurRoutes];	
		stringPostWPRoute+='R[*]'+idRoute+'[*]'+departMarkerRoute[idRoute].getLatLng().lat()+'[-]'+departMarkerRoute[idRoute].getLatLng().lng()+'[*]'+arriveeMarkerRoute[idRoute].getLatLng().lat()+'[-]'+arriveeMarkerRoute[idRoute].getLatLng().lng();	
		compteurRoutes++;
		}
		
		if(t!=(tableauWaypointRoutes.length-1) && (tableauWaypointRoutes[t]=='R' || tableStatusMarkersEtape[compteurEtapes-1]==1))
		{
		stringPostWPRoute+='[#]';	
		}
	}
	
	/*alert(stringPostWPRoute);
	var textNodeWPDatas=document.createTextNode(stringPostWPRoute);
	$('waypointsConstruction').appendChild(textNodeWPDatas);*/

////////////////////////////////////////////
//  Requète ajax de constructions des WP pour google maps
/////////////////////////////////////////
	
	var xhrWP=null;
		
		if (window.XMLHttpRequest) { 
			xhrWP = new XMLHttpRequest();
		}
		else if (window.ActiveXObject) 
		{
			xhrWP = new ActiveXObject("Microsoft.XMLHTTP");
		}
		
		
xhrWP.onreadystatechange = function() { 
		
		if (xhrWP.readyState == 4)
			{
				//alert(xhrWP.responseText);
				var tabPtsInt=xhrWP.responseText.split('[#]');
				if(trajetBoucle==1)var tableWaypoints=new Array(markerDepartArr.getLatLng().lat()+' '+markerDepartArr.getLatLng().lng());
				else var tableWaypoints=new Array(markerDepart.getLatLng().lat()+' '+markerDepart.getLatLng().lng()); 
				
				for(var b=0;b<tabPtsInt.length;b++)
				{
				tableWaypoints.push(tabPtsInt[b]);	
				}
				
				if(trajetBoucle==1)tableWaypoints.push(markerDepartArr.getLatLng().lat()+' '+markerDepartArr.getLatLng().lng());
				else tableWaypoints.push(markerArrivee.getLatLng().lat()+' '+markerArrivee.getLatLng().lng()); 
				
				//alert(tableWaypoints.join(','));
				
				if($('avoidHighways'+stringCalculDirect).checked && $('dirMode0').checked) gdir.loadFromWaypoints(tableWaypoints, { "locale": localeDirections,"avoidHighways" : 1 });
				else if($('dirMode1').checked) gdir.loadFromWaypoints(tableWaypoints, { "locale": localeDirections,travelMode : G_TRAVEL_MODE_WALKING  });
				
				else gdir.loadFromWaypoints(tableWaypoints, { "locale": localeDirections });
				
				setTimeout("finTimeOutGdir()",35000);
			}
		}
		
		xhrWP.open("POST", "/pages/creerRoadbooks/ajaxRoadbookMotoCalculWP.php", true);
	xhrWP.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");      
    	xhrWP.send("waypointsConstruction="+stringPostWPRoute);
	}
	else
	{
		var tableWaypoints=new Array(markerDepart.getLatLng().lat()+' '+markerDepart.getLatLng().lng()); 
		if(trajetBoucle==1)tableWaypoints.push(markerDepartArr.getLatLng().lat()+' '+markerDepartArr.getLatLng().lng());
				else tableWaypoints.push(markerArrivee.getLatLng().lat()+' '+markerArrivee.getLatLng().lng()); 
				
				if($('avoidHighways'+stringCalculDirect).checked && $('dirMode0').checked) gdir.loadFromWaypoints(tableWaypoints, { "locale": localeDirections,"avoidHighways" : 1 });
				else if($('dirMode1').checked) gdir.loadFromWaypoints(tableWaypoints, { "locale": localeDirections,travelMode: G_TRAVEL_MODE_WALKING  });
				else gdir.loadFromWaypoints(tableWaypoints, { "locale": localeDirections });
				
				setTimeout("finTimeOutGdir()",35000);
	}
	}
}

function onGDirectionsLoad(){ 
reponseServerGoogleOK=1;
viderTableInstructions();
var nombreRoutes=gdir.getNumRoutes();
	  var pointDepart=gdir.getMarker(0).getLatLng();

	  var pointArrivee=gdir.getMarker(nombreRoutes).getLatLng();

	  var polyline=gdir.getPolyline();
	  var nombrePoints=polyline.getVertexCount();
	  
	  var frontieres=gdir.getBounds();	  
	  var centreCarte=frontieres.getCenter();
	  var tailleBounds=frontieres.toSpan();
	  
	   map.closeInfoWindow();
	  map.setCenter(centreCarte,map.getCurrentMapType().getBoundsZoomLevel(frontieres, map.getSize()));
	  latInit=centreCarte.lat();
	  lngInit=centreCarte.lng();
	  zoomInit=map.getCurrentMapType().getBoundsZoomLevel(frontieres, map.getSize());
	  var stringImprBounds=latInit+'[#]'+lngInit+'[#]'+map.getCurrentMapType().getBoundsZoomLevel(frontieres, new GSize(580,630));
	  var nodeformImprBounds=document.createTextNode(stringImprBounds);
	  $('stringBoundsCentre').innerHTML='';
	  $('stringBoundsCentre').appendChild(nodeformImprBounds);
	  
	  
	 tableauVertexPoyline=new Array();	  
	tableauVertexPolylineImpr=new Array();
	
	 //alert(nombrePoints);
	if(document.all)
	{
			var tauxEchantillonageIE=4;
		var nbPtsIE=Math.max(Math.floor(nombrePoints/tauxEchantillonageIE),Math.floor(gdir.getDistance()['meters']/(tauxEchantillonageIE*100)));
		var ratioIE=nombrePoints/nbPtsIE;
		for(var t=0;t<nbPtsIE;t++)
		{	
		var m=Math.floor(t*ratioIE);
          tableauVertexPoyline.push(polyline.getVertex(m));
		  tableauVertexPolylineImpr.push((Math.round(polyline.getVertex(m).lng()*100000)/100000)+','+(Math.round(polyline.getVertex(m).lat()*100000)/100000)+',800');
		}
	}
	
	else
	{
	for(var t=0;t<nombrePoints;t++)
		{		
          tableauVertexPoyline.push(polyline.getVertex(t));
		  tableauVertexPolylineImpr.push((Math.round(polyline.getVertex(t).lng()*100000)/100000)+','+(Math.round(polyline.getVertex(t).lat()*100000)/100000)+',800');
		  
		}
		
	}
	
	
	if(polylineCurrent>=0)
		{ 
			
			polylineAffichee[polylineCurrent].hide();
		}
		
		var stringPolylineImpr=tableauVertexPolylineImpr.join(' ');
		var nodePolylineImpr=document.createTextNode(stringPolylineImpr);
		$('stringPolylineImpression').innerHTML='';
	  $('stringPolylineImpression').appendChild(nodePolylineImpr);
	  
		//création Tableau d'instructions
		var tabDeparts=new Array();
		var tabArrivee=new Array();
		var tabNotes=new Array();
		var tabWpGps=new Array();
		var tabStringWP=new Array();
		var compteurRoutesOnLoad=0;
		var compteurSteps=0;
		var routeMotoActive=0;
		var nbRoutesMotoOK=0;
		var distCumulee=0;
		var distRM=0;
		
      for (var m=1;m<=nombreRoutesAjoutees;m++)
	  {
		var idRoute=tableRoutesSelectionnees[m];
		tabDeparts.push(departMarkerRoute[idRoute].getLatLng());
		tabArrivee.push(arriveeMarkerRoute[idRoute].getLatLng());
		var tabInfos=tableInfoWindowMarker[idRoute].split('[#]');
		 tabNotes.push(tabInfos[1]);
	  }
	  
	  for(var i=0;i<nombreRoutes;i++)
	  {
	 	var route=gdir.getRoute(i);
		var nombreSteps=route.getNumSteps();
		
		
		var pointDir=new GLatLng();
		 for(var j=0;j<nombreSteps;j++)
	  		{
				var noteActive=-1;
				var entreeRoute=0;
				var sortieRoute=0;
				
				var siteTouristique=0;
				var pasRouteEtape=1;
				var distPartielleBuffer=0;
				var rechercheDirection=/(.*)Prendre la direction <b>(.*)/;
				var indexRouteMotoB=nbRoutesMotoOK+1;
				//if(j<6)alert(distanceTwoPoints(tabDeparts[nbRoutesMotoOK],route.getStep(j).getLatLng()));
				if(nbRoutesMotoOK<nombreRoutesAjoutees)
				{	
					if(distanceTwoPoints(tabDeparts[nbRoutesMotoOK],route.getStep(j).getLatLng())<50 && listeTypesSites[tableRoutesSelectionnees[(indexRouteMotoB)]]>1)
					{
					siteTouristique=1;
					noteActive=tabNotes[nbRoutesMotoOK]*10;
					nbRoutesMotoOK++;
					
					}
				}
	
				if(nbRoutesMotoOK<nombreRoutesAjoutees)
				{
					if(distanceTwoPoints(tabArrivee[nbRoutesMotoOK],route.getStep(j).getLatLng())<50 && routeMotoActive)
					{
						
					routeMotoActive=0;
					sortieRoute=1;
					noteActive=tabNotes[nbRoutesMotoOK]*10;
					nbRoutesMotoOK++;
					
					}
				}
				if(nbRoutesMotoOK<nombreRoutesAjoutees)
				{
					
					if(distanceTwoPoints(tabDeparts[nbRoutesMotoOK],route.getStep(j).getLatLng())<50 && routeMotoActive==0 && listeTypesSites[tableRoutesSelectionnees[(indexRouteMotoB)]]==1)
					{
					routeMotoActive=1;
					entreeRoute=1;
					
					}
				}
				
				
				
				if(i==0 && j==0)
				{
				var	codeStep=1;
				}
				
				else
				{
				
				if(entreeRoute) var codeStep=2;
				else if(sortieRoute) var codeStep=3;
				else if(siteTouristique) var codeStep=5;
				else var codeStep=0;
				}
				if(codeStep==0)compteurSteps++;
				
				distCumulee=distCumulee+route.getStep(j).getDistance()['meters']+distPartielleBuffer;
				if(routeMotoActive)distRM+=route.getStep(j).getDistance()['meters'];
				var distCumuleeM=Math.round(distCumulee/100)/10;
				var dist=Math.round((route.getStep(j).getDistance()['meters']+distPartielleBuffer)/100)/10;
				if(routeMotoActive) noteActive=tabNotes[nbRoutesMotoOK]*10;
				if(entreeRoute || siteTouristique)
				{var indexRouteMoto=nbRoutesMotoOK+1;
				if(siteTouristique)indexRouteMoto=nbRoutesMotoOK;
				var stringInfosRoute=listeInfosRoute[tableRoutesSelectionnees[indexRouteMoto]];
				var tabRouteMoto=stringInfosRoute.split('[#]');
				var urlRoute=tabRouteMoto[2];
				var titreRoute=tabRouteMoto[1];
				}
				else
				{var indexRouteMoto=0;
				var urlRoute='';
				var titreRoute='';
				}
				var iconeRouteRbk=iconeRoadbook(route.getStep(j).getDescriptionHtml());
				var stringDrivingInstructions=compteurSteps+'[#]'+noteActive+'[#]'+route.getStep(j).getDescriptionHtml()+'[#]'+distCumuleeM+'[#]'+dist+'[#]'+route.getStep(j).getLatLng().lat()+'[#]'+route.getStep(j).getLatLng().lng()+'[#]'+indexRouteMoto+'[#]'+urlRoute+'[#]'+titreRoute+'[#]'+iconeRouteRbk;
				
			if(pasRouteEtape)
			{
				ligneDrivingInstructions(stringDrivingInstructions,codeStep,'listeInstructionsRoute');
				tabStringWP.push(stringDrivingInstructions+'[#]'+codeStep);
			}
			
			tabWpGps.push(route.getStep(j).getLatLng().lat()+'[-]'+route.getStep(j).getLatLng().lng());
	  		}
	  
	  }
		var stringDrivingInstructions=compteurSteps+'[#]'+(-1)+'[#]<b>'+affRbk2+'</b>[#][#]'+distCumuleeM+'[#]'+pointArrivee.lat()+'[#]'+pointArrivee.lng();
				
			ligneDrivingInstructions(stringDrivingInstructions,4,'listeInstructionsRoute');
			tabStringWP.push(stringDrivingInstructions+'[#]'+4);
		
		var stringWP=tabStringWP.join('[*]');
		var nodeStringWPImpression=document.createTextNode(stringWP);
		$('stringWPImpression').innerHTML='';
		 $('stringWPImpression').appendChild(nodeStringWPImpression);
		
		
		var stringWPGPS=tabWpGps.join('[#]');
		distRM=Math.floor(distRM/100)/10;
		if(uniteDist==1)
		{
		$('kilometrage').innerHTML=Math.floor(gdir.getDistance()['meters']/100)/10+affInf1+distRM+affInf2;
		}
		else
		{
		$('kilometrage').innerHTML=Math.floor(gdir.getDistance()['meters']/100/coeffConversion)/10+' mi (including '+Math.floor(distRM/coeffConversion*10)/10+' miles of touristic road)';
			
		}
		$('duree').innerHTML=seconds2dateString(gdir.getDuration()['seconds']);
		var nodeStringGPS=document.createTextNode(stringWPGPS);
		$('stringWP').innerHTML='';
		$('stringWP').appendChild(nodeStringGPS);
		
		var distTotale=Math.floor(gdir.getDistance()['meters']/100)/10;
		var stringResumeRBK=seconds2dateString(gdir.getDuration()['seconds'])+'[#]'+distTotale+'[#]'+distRM;
		var nodeResumeRBK=document.createTextNode(stringResumeRBK);
		$('resumeRBK').innerHTML='';
		$('resumeRBK').appendChild(nodeResumeRBK);
		
	polylineCurrent++;
	  polylineAffichee[polylineCurrent]=new GPolyline(tableauVertexPoyline, '#003399', 4, 0.5);
	  map.addOverlay(polylineAffichee[polylineCurrent]);
	   
	  if(polylineCurrent>0)
		{ 
			map.removeOverlay(polylineAffichee[(polylineCurrent-1)]);
			polylineAffichee[(polylineCurrent-1)]=0;
			
		}
	  routeCalculeeFinal();
}

function attenteCalculRoute()
{
AfficherElement('imageAttenteCalculRoute');	
CacherElement('texteCalculRouteOK');
CacherElement('erreursCalculRouteBoucleGoogle');
CacherElement('texteVoirTraceCalcul');
CacherElement('erreursCalculRouteBouclePasEtape');
}

function erreurGoogleMapCalcul()
{
AfficherElement('erreursCalculRouteBoucleGoogle');	
CacherElement('imageAttenteCalculRoute');
}

function routeCalculeeFinal()
{
AfficherElement('texteCalculRouteOK');	
AfficherElement('infosRoadbook');
AfficherElement('tableDrivingDirections');
CacherElement('imageAttenteCalculRoute');
}

function finTimeOutGdir()
{

	if(gdir.getStatus().code!=200 && reponseServerGoogleOK==0)
	{
	erreurGoogleMapCalcul();
	//alert(gdir.getStatus().code);
	}
	gdir.clear();

	
}

function viderTableInstructions(){
$('listeWPTable').removeChild($('listeInstructionsRoute'));

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

function ligneDrivingInstructions(stringDrivingInstructions,depArr,idTbody)
{
	var tabInstructions=stringDrivingInstructions.split('[#]');
if(document.all)
	{
		if(depArr>0)var ligneInstructions=document.createElement('<tr style="background-color:#FFCC66;">');
		else if(tabInstructions[1]>=0)var ligneInstructions=document.createElement('<tr style="background-color:#FFCC88;">');
		else var ligneInstructions=document.createElement('<tr>');
		
		var cellule1=document.createElement('<td width="51">');
	var cellule2=document.createElement('<td width="66">');
	var cellule2b=document.createElement('<td width="66">');
	var cellule3=document.createElement('<td class="sujet" style="text-align:center;">');
	var cellule4=document.createElement('<td width="101">');
	var cellule5=document.createElement('<td width="91">');
	
	var strong1=document.createElement('<strong>');
	
	if(depArr==0)
	{
	var numRoute1=document.createTextNode(tabInstructions[0]);
	}
	else
	{
	var img1=document.createElement('img');
	if(depArr==1) img1.setAttribute('src',"/images/icones/googleMaps/drapeau/drapeauD.png");
	if(depArr==4) img1.setAttribute('src',"/images/icones/googleMaps/drapeau/drapeauA.png");
	if(depArr==3) img1.setAttribute('src',"/images/icones/creerRoadbooks/routeOut.png");
	if(depArr==2 || depArr==5) img1.setAttribute('src',"/images/icones/creerRoadbooks/routeIn.png");
		
	}
	
	var imgNote2=document.createElement('img');
	imgNote2.setAttribute('src','/images/icones/googleMaps/iconesRouteSomm/'+tabInstructions[1]+'.png');
	
	var img2b=document.createElement('img');
	img2b.setAttribute('src','/images/icones/googleMaps/iconesRoadbooks/'+tabInstructions[10]+'.gif');
	img2b.setAttribute('style','width:60px; height 60px; border:1px solid black;');
	
	var span3=document.createElement('span');
	span3.setAttribute('class','enonce');
	span3.setAttribute('style','font-size:10px;');
	span3.innerHTML=tabInstructions[2];
	
	var a3=document.createElement('<a href="javascript:void(0);" onclick="javascript:window.open(\''+tabInstructions[8]+'\');">');
	
	
	var img3=document.createElement('img');
	img3.setAttribute('src','/images/icones/creerRoadbooks/routeSel'+tabInstructions[7]+'_rsz.png');
	
	if(depArr==5)var introText3=document.createTextNode(affRbk1B);
	else var introText3=document.createTextNode(affRbk1);
	var br3=document.createElement('br');
	var br3b=document.createElement('br');
	var strong3=document.createElement('strong');
	var text3=document.createTextNode(tabInstructions[9]);
	var span3b=document.createElement('span');
	span3b.setAttribute('class','enonce');
	
	var strong4=document.createElement('strong');
	var pk4=document.createTextNode(stringPK+' : '+(Math.floor(tabInstructions[3]/coeffConversion*10)/10)+' '+unitStr);
	var br4=document.createElement('br');
	var kmCum4=document.createTextNode('-> '+(Math.floor(tabInstructions[4]/coeffConversion*10)/10)+' '+unitStr);
	
	var img5=document.createElement('<img src="images/icones/googleMaps/croisement/loupePanneau.gif" style="border:none;"/>');
	
	
	var a5=document.createElement('<a href="#map_canvas" onclick="zoomCroisement('+tabInstructions[5]+','+tabInstructions[6]+')">');
	
	}
	else
	{
	var ligneInstructions=document.createElement('tr');
	if(depArr>0) ligneInstructions.setAttribute("style","background-color:#FFCC66;");
	else if(tabInstructions[1]>=0)ligneInstructions.setAttribute("style","background-color:#FFCC88;");
	
	var cellule1=document.createElement('td');
	var cellule2=document.createElement('td');
	var cellule2b=document.createElement('td');
	var cellule3=document.createElement('td');
	var cellule4=document.createElement('td');
	var cellule5=document.createElement('td');
	
	cellule1.setAttribute('width','51');
	cellule2.setAttribute('width','66');
	cellule2b.setAttribute('width','66');
	cellule3.setAttribute('class','sujet');
	cellule3.setAttribute('style','text-align:center;');
	cellule4.setAttribute('width','101');
	cellule5.setAttribute('width','91');
	
	var strong1=document.createElement('strong');
	if(depArr==0)
	{
	var numRoute1=document.createTextNode(tabInstructions[0]);
	}
	else
	{
	var img1=document.createElement('img');
	if(depArr==1) img1.setAttribute('src',"/images/icones/googleMaps/drapeau/drapeauD.png");
	if(depArr==4) img1.setAttribute('src',"/images/icones/googleMaps/drapeau/drapeauA.png");
	if(depArr==3) img1.setAttribute('src',"/images/icones/creerRoadbooks/routeOut.png");
	if(depArr==2 || depArr==5) img1.setAttribute('src',"/images/icones/creerRoadbooks/routeIn.png");
	
	}
	
	var imgNote2=document.createElement('img');
	imgNote2.setAttribute('src','/images/icones/googleMaps/iconesRouteSomm/'+tabInstructions[1]+'.png');
	
	var img2b=document.createElement('img');
	img2b.setAttribute('src','/images/icones/googleMaps/iconesRoadbooks/'+tabInstructions[10]+'.gif');
	img2b.setAttribute('style','width:60px; height 60px; border:1px solid black;');
	
	var span3=document.createElement('span');
	span3.setAttribute('class','enonce');
	span3.setAttribute('style','font-size:10px;');
	span3.innerHTML=tabInstructions[2];
	
	var a3=document.createElement('a');
	a3.setAttribute('href','javascript:void(0);');
	a3.setAttribute('onclick',"javascript:window.open('"+tabInstructions[8]+"');");
	
	var img3=document.createElement('img');
	img3.setAttribute('src','/images/icones/creerRoadbooks/routeSel'+tabInstructions[7]+'_rsz.png');
	
	if(depArr==5)var introText3=document.createTextNode(affRbk1B);
	else var introText3=document.createTextNode(affRbk1);
	var br3=document.createElement('br');
	var br3b=document.createElement('br');
	var strong3=document.createElement('strong');
	var text3=document.createTextNode(tabInstructions[9]);
	var span3b=document.createElement('span');
	span3b.setAttribute('class','enonce');
	
	var strong4=document.createElement('strong');
	var pk4=document.createTextNode(stringPK+' : '+(Math.floor(tabInstructions[3]/coeffConversion*10)/10)+' '+unitStr);
	var br4=document.createElement('br');
	var kmCum4=document.createTextNode('-> '+(Math.floor(tabInstructions[4]/coeffConversion*10)/10)+' '+unitStr);
	
	var img5=document.createElement('img');
	img5.setAttribute('src','images/icones/googleMaps/croisement/loupePanneau.gif');
	img5.setAttribute('style','border:none;');
	
	var a5=document.createElement('a');
	a5.setAttribute('href','#map_canvas');
	a5.setAttribute('onclick','zoomCroisement('+tabInstructions[5]+','+tabInstructions[6]+')');
	}
	
	if(depArr==0)
	{
	strong1.appendChild(numRoute1);
	cellule1.appendChild(strong1);
	}
	else cellule1.appendChild(img1);
	
	if(tabInstructions[1]>-1)cellule2.appendChild(imgNote2);
	
	if(tabInstructions[10]>0)cellule2b.appendChild(img2b);
	
	if(tabInstructions[7]>0)
	{
		strong3.appendChild(introText3);
	cellule3.appendChild(strong3);
	cellule3.appendChild(img3);
	span3b.appendChild(a3);
	a3.appendChild(text3);
	cellule3.appendChild(span3b);
	cellule3.appendChild(br3);
	cellule3.appendChild(br3b);
	}
	cellule3.appendChild(span3);
	
	if(depArr<4)
	{
	strong4.appendChild(pk4);
	if(depArr!=4)
		{
		cellule4.appendChild(kmCum4);		
		cellule4.appendChild(br4);
		}
		cellule4.appendChild(strong4);
		
	
	}
	
	a5.appendChild(img5);
	cellule5.appendChild(a5);
	
	
	ligneInstructions.appendChild(cellule1);
	ligneInstructions.appendChild(cellule2);
	ligneInstructions.appendChild(cellule2b);
	ligneInstructions.appendChild(cellule3);
	ligneInstructions.appendChild(cellule4);
	ligneInstructions.appendChild(cellule5);
	
	$(idTbody).appendChild(ligneInstructions);

}

function zoomCroisement(lat,lng){
	
  
	map.setCenter(new GLatLng(lat,lng), 15);
	markerWaypoint.setLatLng(new GLatLng(lat,lng));
	markerWaypoint.show();

	
}

function iconeRoadbook(instructions)
{
	var image=0;
	var recherche=/(.*)Tourner à <b>droite<\/b>(.*)/;
	var rechercheEng=/(.*)Turn <b>right<\/b>(.*)/;
	var recherche1=/(.*) tourne à <b>droite<\/b>(.*)/;
	var recherche1Eng=/(.*)turns <b>right<\/b>(.*)/;
	if (recherche.test(instructions) || rechercheEng.test(instructions) || recherche1.test(instructions) || recherche1Eng.test(instructions))
	{
	image=1;
	}
	
	recherche=/(.*)Continuer(.*)sur(.*)/;
	rechercheEng=/(.*)Continue (.*)on(.*)/;
	if (recherche.test(instructions) || rechercheEng.test(instructions))
	{
	image=2;
	}
	
	recherche=/(.*)Tourner à <b>gauche<\/b>(.*)/;
	rechercheEng=/(.*)Turn <b>left<\/b>(.*)/;
	recherche1=/(.*) tourne à <b>gauche<\/b>(.*)/;
	recherche1Eng=/(.*)turns <b>left<\/b>(.*)/;
	if (recherche.test(instructions) || rechercheEng.test(instructions) || recherche1.test(instructions) || recherche1Eng.test(instructions))
	{
	image=3;
	}
	
	recherche=/(.*)Prendre la direction <b>nord-ouest<\/b>(.*)/;
	rechercheEng=/(.*)Head <b>northwest<\/b>(.*)/;
	if (recherche.test(instructions) || rechercheEng.test(instructions))
	{
	image=4;
	}
	
	recherche=/(.*)Prendre la direction <b>nord<\/b>(.*)/;
	rechercheEng=/(.*)Head <b>north<\/b>(.*)/;
	if (recherche.test(instructions) || rechercheEng.test(instructions))
	{
	image=5;
	}
	
	recherche=/(.*)Prendre la direction <b>nord-est<\/b>(.*)/;
	rechercheEng=/(.*)Head <b>northeast<\/b>(.*)/;
	if (recherche.test(instructions) || rechercheEng.test(instructions))
	{
	image=6;
	}
	
	recherche=/(.*)Prendre la direction <b>est<\/b>(.*)/;
	rechercheEng=/(.*)Head <b>east<\/b>(.*)/;
	if (recherche.test(instructions) || rechercheEng.test(instructions))
	{
	image=7;
	}
	
	recherche=/(.*)Prendre la direction <b>sud-est<\/b>(.*)/;
	rechercheEng=/(.*)Head <b>southeast<\/b>(.*)/;
	if (recherche.test(instructions) || rechercheEng.test(instructions))
	{
	image=8;
	}
	
	recherche=/(.*)Prendre la direction <b>sud<\/b>(.*)/;
	rechercheEng=/(.*)Head <b>south<\/b>(.*)/;
	if (recherche.test(instructions) || rechercheEng.test(instructions))
	{
	image=9;
	}
	
	recherche=/(.*)Prendre la direction <b>sud-ouest<\/b>(.*)/;
	rechercheEng=/(.*)Head <b>southwest<\/b>(.*)/;
	if (recherche.test(instructions) || rechercheEng.test(instructions))
	{
	image=10;
	}
	
	recherche=/(.*)Prendre la direction <b>ouest<\/b>(.*)/;
	rechercheEng=/(.*)Head <b>west<\/b>(.*)/;
	if (recherche.test(instructions) || rechercheEng.test(instructions))
	{
	image=11;
	}
	
	recherche=/(.*)Tourner légèrement à <b>droite<\/b>(.*)/;
	rechercheEng=/(.*)Slight <b>right<\/b>(.*)/;
	recherche1=/(.*)tourne légèrement à <b>droite<\/b>(.*)/;
	recherche1Eng=/(.*)turns slightly <b>right<\/b>(.*)/;
	if (recherche.test(instructions) || recherche1.test(instructions) || rechercheEng.test(instructions) || recherche1Eng.test(instructions))
	{
	image=12;
	}
	
	recherche=/(.*)Tourner légèrement à <b>gauche<\/b>(.*)/;
	rechercheEng=/(.*)Slight <b>left<\/b>(.*)/;
	recherche1=/(.*)tourne légèrement à <b>gauche<\/b>(.*)/;
	recherche1Eng=/(.*)turns slightly <b>left<\/b>(.*)/;
	if (recherche.test(instructions) || recherche1.test(instructions) || rechercheEng.test(instructions) || recherche1Eng.test(instructions))
	{
	image=13;
	}
	
	recherche=/(.*)Tourner complètement à <b>gauche<\/b>(.*)/;
	rechercheEng=/(.*)Sharp <b>left<\/b>(.*)/;
	if (recherche.test(instructions) || rechercheEng.test(instructions))
	{
	image=14;
	}
	
	recherche=/(.*)Tourner complètement à <b>droite<\/b>(.*)/;
	rechercheEng=/(.*)Sharp <b>right<\/b>(.*)/;
	if (recherche.test(instructions) || rechercheEng.test(instructions))
	{
	image=15;
	}

	rechercheEng=/At (.*), take the <b>1st<\/b> exit(.*)/;
	recherche=/Au rond-point(.*), prendre la <b>1ère<\/b> sortie(.*)/;
	if (recherche.test(instructions) || rechercheEng.test(instructions))
	{
	image=16;
	}
	
	recherche=/Au rond-point(.*), prendre la <b>2e<\/b> sortie(.*)/;
	rechercheEng=/At(.*), take the <b>2nd<\/b> exit(.*)/;
	if (recherche.test(instructions) || rechercheEng.test(instructions))
	{
	image=17;
	}
	
	recherche=/Au rond-point(.*), prendre la <b>3e<\/b> sortie(.*)/;
	rechercheEng=/At(.*), take the <b>3rd<\/b> exit(.*)/;
	if (recherche.test(instructions) || rechercheEng.test(instructions))
	{
	image=18;
	}
	
	recherche=/Au rond-point(.*), prendre la <b>4e<\/b> sortie(.*)/;
	rechercheEng=/At (.*), take the <b>4th<\/b> exit(.*)/;
	if (recherche.test(instructions) || rechercheEng.test(instructions))
	{
	image=19;
	}
	
	recherche=/Au rond-point(.*), prendre la <b>5e<\/b> sortie(.*)/;
	rechercheEng=/At (.*), take the <b>5th<\/b> exit(.*)/;
	if (recherche.test(instructions) || rechercheEng.test(instructions))
	{
	image=20;
	}
	
	recherche=/Au rond-point(.*), prendre la <b>6e<\/b> sortie(.*)/;
	rechercheEng=/At (.*), take the <b>6th<\/b> exit(.*)/;
	if (recherche.test(instructions) || rechercheEng.test(instructions))
	{
	image=21;
	}
	
	
	return image;
}
