	var map, cluster, baseIcon, detailmap, mydiv;
	var places;
	var clovis;
	var geocoder,gdir;
	var markersArray = [];
	var pline, polyline;
	var loadingDiv;
	
	function init() {
		 if (GBrowserIsCompatible()) {
		        map = new GMap2(document.getElementById("map_canvas"));
		        map.setCenter(new GLatLng(31,17), 2);
				map.setUIToDefault();
				map.addControl(new GOverviewMapControl());
				var loadingDivSize = new GSize(map.getSize().width/4, 150);
				var pos = new GControlPosition(G_ANCHOR_TOP_LEFT, loadingDivSize);
				loadingDiv = new GMLoadingDiv({
		            position: pos,
		            slim: true,
		            width: map.getSize().width/2
		        });
		        map.addControl(loadingDiv);
				_mPreferMetric = true;
		        geocoder = new GClientGeocoder();
		        cluster = new ClusterMarker(map);
		        baseIcon = new GIcon(G_DEFAULT_ICON);
				baseIcon.image = "images/mapiconpoi-2-min.png";
				baseIcon.shadow = "images/shadow-mapiconpoi-2-min.png";
				baseIcon.iconSize = new GSize(15, 19);
				baseIcon.shadowSize = new GSize(25, 19);
				baseIcon.iconAnchor = new GPoint(7, 19);
				baseIcon.infoWindowAnchor = new GPoint(9, 2);
				
				

		 }
	}
    
	function initialize() {
    	init();
		loadAllDealerCluster();
		GEvent.addDomListener(document.getElementById("btn_submit"),"click", getDealerByCriteria);
		GEvent.addListener(map,"moveend", generateList);
    }
    
	function generateList(){
		if(document.getElementById('dealers_description') != null) {
		var placesOnMap = getAllPlacesInMaps();
		document.getElementById("dealers_description").innerHTML = "";
		if(sTradVisible == undefined) {
			sTradVisible = " / "
		}
		document.getElementById("dealers_description").innerHTML += "<div class=\"left\" ><strong>" + placesOnMap.length + " " + sTradVisible + " " + places.length + "</strong></div>";
		if(placesOnMap.length <= 50) {
			
			for(var i=0;i<placesOnMap.length; i++) {
				document.getElementById("dealers_description").innerHTML += getTextForPlaceList(placesOnMap[i],(clovis.length > 0));
			}
		} 
		}	
	}
	
    function initialize_external() {
        init();
        GEvent.addListener(map,"moveend", generateList);
  		getFlashDealerInfo();  		
      }
	
    function initialize_from_flash_map() {
        init();
  		getFlashDealerInfo();
      }
    
    function initialize_direction() {
        init();
        
        gdir = new GDirections(map);//, document.getElementById("directions"));
        GEvent.addListener(gdir, "load", onGDirectionsLoad);
        GEvent.addListener(gdir, "error", handleErrors);
        GEvent.addDomListener(document.getElementById("submit_dir"),"click",calcIt);
        myDiv = document.createElement("div");
		myDiv.id = "detailmap";
		myDiv.style.height = "200px";
		myDiv.style.width = "200px";
		myDiv.style.overflow = "hidden";
  		//getFlashDealerInfo();
      }
    
   
    function getAllPlacesInMaps() {
    	var inBoundsPlaces = [];
    	if(places != undefined && places.length > 0) {
    		var bound = map.getBounds();
    		for(var i = 0; i< places.length; i++) {
    			var point = new GLatLng(places[i].getAttribute("lat"),places[i].getAttribute("long"));
    			if(bound.containsLatLng(point)){
    				//places[i].setAttribute("dist",point.distanceFrom(map.getCenter())/1000);
    				inBoundsPlaces.push(places[i]);
    			}
    		}
    	}
    	return inBoundsPlaces;
    }
   
    /*
    function distance(lat_a, lon_a, lat_b, lon_b) 
    {
      a = Math.PI / 180;
      lat1 = lat_a * a;
      lat2 = lat_b * a;
      lon1 = lon_a * a;
      lon2 = lon_b * a;

      t1 = Math.sin(lat1) * Math.sin(lat2);
      t2 = Math.cos(lat1) * Math.cos(lat2);
      t3 = Math.cos(lon1 - lon2);
      t4 = t2 * t3;
      t5 = t1 + t4;
      rad_dist = Math.atan(-t5/Math.sqrt(-t5 * t5 +1)) + 2 * Math.atan(1);

      return (rad_dist * 3437.74677 * 1.1508) * 1.6093470878864446;
    }*/

    ///
    // This function is used to get the map center according to parameters given on the URL
    // If no parameters passed, zoom to the world
    ///
    function getFlashDealerInfo()
	{
		var param = window.location.toString().split('?')[1];
		if(param != undefined)
		{
			loadDealer("getEtab.do?", param, false);
		}
		else {
			map.setCenter(new GLatLng(30,0), 1);
		}
	}

    function loadAllDealerCluster() {
    	
    	loadDealer('getAllEtab.do',"", false);
    }
    
    function getDealerByCriteria() {
    	var criteria = "";
    	criteria += (document.getElementById("isDistrib").checked? "isDistrib=true&":"isDistrib=false&");
    	criteria += (document.getElementById("isRepair").checked? "isRepair=true&":"isRepair=false&");
    	criteria += (document.getElementById("isTruckPlus").checked? "isTruckPlus=true&":"isTruckPlus=false&");
    	criteria += (document.getElementById("is2424").checked? "is2424=true&":"is2424=false&");
    	criteria += (document.getElementById("isClovis").checked? "isClovis=true&":"isClovis=false&");
    	criteria += (document.getElementById("isFP").checked? "isFP=true&":"isFP=false&");
    	criteria += (document.getElementById("isRTO").checked? "isRTO=true&":"isRTO=false&");
    	criteria += (document.getElementById("isAdBlue").checked? "isAdBlue=true":"isAdBlue=false");
    	loadDealer('getEtabWithCond.do',criteria, true);
    }
    
	function createMarker(id,name,pos, address, tel, web, clovis) {
			markerOptions = { icon:baseIcon };
			var marker = new GMarker(pos, markerOptions);
			
			GEvent.addListener(marker, "click", 
					GEvent.callbackArgs(this,bindMarkerInfo,marker,id,name, address, tel, web, clovis)
			);

			return marker;
		}
	
	function bindMarkerInfo(marker,id,name, address, tel, web, clovis){
		//marker.openInfoWindowHtml(getTextForPlacePopup(id,name, address, tel, web, clovis));
		map.openInfoWindowHtml(marker.getLatLng() ,getTextForPlacePopup(id,name, address, tel, web, clovis), {"pixelOffset": new GSize(0, -10) });
	}
	
	/*
	* Load every dealer
	* Gather result as XML, parse and add to the cluster marker
	*/
	function loadDealer(url, postdata, avoidmove) {
		loadingDiv.show();
		GDownloadUrl(url, function(data, response) {
			if(response != 200) {
				return;
			}
			cluster.removeMarkers();
			var xmlDom = GXml.parse(data);
			var iNbInCountry = 0;
			var locations = xmlDom.documentElement.getElementsByTagName("location");
			clovis = xmlDom.documentElement.getElementsByTagName("clovis");			
			places = xmlDom.documentElement.getElementsByTagName("place");
			if(clovis.length > 0) {
				baseIcon.image = "images/mapiconpoi-1.png";
				baseIcon.shadow = "images/shadow-mapiconpoi-1.png";
				baseIcon.iconSize = new GSize(30.0, 18.0);
				baseIcon.shadowSize = new GSize(40.0, 18.0);
				baseIcon.iconAnchor = new GPoint(15.0, 9.0);
				baseIcon.infoWindowAnchor = new GPoint(15.0, 9.0);
			}
			
			var bound = new GLatLngBounds();
			var point;
			markersArray = [];
			if(document.getElementById("dealers_description") != undefined){
				document.getElementById("dealers_description").innerHTML = "";
			}

			for(var i=0; i<places.length; i++) {
				var place = places[i];
				point = new google.maps.LatLng(place.getAttribute("lat"),place.getAttribute("long"));
				markersArray[place.getAttribute("idetab")] = createMarker(place.getAttribute("idetab"),place.getAttribute("name"),point,place.getAttribute("address"), place.getAttribute("tel"), place.getAttribute("web"),(clovis.length > 0));
				
				if(place.getAttribute("incountry") == "true"){
					bound.extend(point);
					iNbInCountry++;
				}

			}

			cluster.addMarkers(markersArray);
			cluster.intersectPadding=5;
			
			if(gdir != undefined){
				if(gdir.getStatus().code == 200) {
					bound.extend(gdir.getRoute(0).getEndLatLng());
					bound.extend(gdir.getRoute(0).getStep(0).getLatLng());
				}
			}

			if(avoidmove == false){
				if(iNbInCountry>0 || gdir != undefined) {
					map.setCenter(bound.getCenter());
					var zoom = map.getBoundsZoomLevel(bound);
					if(zoom>0){
						zoom--;
					}
					map.setZoom(zoom);
				} 
				else {
					if(locations.length>0){
						var target = locations[0].getAttribute("name");
						showAddress(target, false);
					}
					else {
						cluster.fitMapToMarkers();
					}
				}
			} else {
				generateList();
				cluster.refresh();
			}
			
			if(gdir != undefined){
				if(gdir.getStatus().code == 200) {
					showDirection();	
				}
			}
			loadingDiv.hide();

		}, postdata
		);
		
	}
	
	function getTextForPlaceList(place, clovis) {
		//var dealer_description = "<div id=\"info_dealers\" style=\" border-style:solid; border-color: rgb(208, 208, 208);\">";
		var dealer_description = "<div id=\"info_dealers_" + place.getAttribute("idetab") + "\">";
		if(clovis == true){
			//Clovis rent
			dealer_description += "<div id=\"dealer_name\" ><a class=\"link01\" href=\"javascript:void(window.open(&quot;http://www.renault-trucks.net/J47PAYS/web/controller?command=URLOpenPopup&amp;siteCode=" + place.getAttribute("idetab") + " &quot;,&quot;&quot;,&quot;width=780,height=760,top=50,status=no,scrollbars=yes,resizable=no&quot;))\"><b style=\"text-decoration: underline;\">" + place.getAttribute("name") + "</b></a>&nbsp;<a href=\"#\" onclick=\"showDealer(" + place.getAttribute("idetab") + ")\" >"+ sTradLocate+" </a>";
		} else {
			//Denime ID card
			dealer_description += "<div id=\"dealer_name\" ><a class=\"link01\" href=\"javascript:void(window.open(&quot;http://"+window.location.hostname+"/J47MAP/web/result.do?id=" + place.getAttribute("idetab") + " &quot;,&quot;&quot;,&quot;width=780,height=760,top=50,status=no,scrollbars=yes,resizable=no&quot;))\"><b style=\"text-decoration: underline;\">" + place.getAttribute("name") + "</b></a>&nbsp;<a href=\"#\" onclick=\"showDealer(" + place.getAttribute("idetab") + ")\" >"+ sTradLocate+" </a></div>";
		}
		dealer_description += "<div style=\"padding-left:20px;\" >";
		
		dealer_description += "<table style=\"width: 100%\"><tr><td style=\"width:50%\"><div id=\"status\"  style=\"font-weight: bold;\">" + place.getAttribute("status")+ "</div>";
		dealer_description += "<div id=\"dealer_address\">" + place.getAttribute("address")+ "</div>";
		if(place.getAttribute("tel").length>0){
		dealer_description += "<div id=\"dealer_phone\"><img src=\"images/phone_icon.png\" />  " + place.getAttribute("tel") + " </div>";
		}
		if(place.getAttribute("fax").length>0){
		dealer_description += "<div id=\"dealer_fax\"><img src=\"images/fax_icon.png\" /> "+ place.getAttribute("fax") +"</div>";
		}

		dealer_description += "</td><td style=\"width:50%\">";
		var service = place.getAttribute("services");
		var services = service.split(',');
		
		if(services[0].length > 0){
			
			for(var i=0;i<services.length;i++) {
					dealer_description += "<div><img src=\"" + tabImg[services[i]] + "\" /></div>";
			}
		}/**/
		dealer_description += "</td></tr></table></div></div><hr />";
		return dealer_description;
	}
	
	function getTextForPlacePopup(place, clovis) {
		var point = new google.maps.LatLng(place.getAttribute("lat"),place.getAttribute("long"));
		map.openInfoWindowHtml(point, getTextForPlacePopup(place.getAttribute("idetab"),place.getAttribute("name"),point,place.getAttribute("address"), place.getAttribute("tel"), place.getAttribute("web"),(clovis.length > 0)));
	}
		
	function getTextForPlacePopup(idetab,name, address, tel, web, clovis) {

		var dealer_description = "<div id=\"info_dealers_" + idetab + "\">";
		
		if(clovis == true){
			//Clovis rent
			dealer_description += "<div id=\"dealer_name\" ><a class=\"link01\" href=\"javascript:void(window.open(&quot;http://www.renault-trucks.net/J47PAYS/web/controller?command=URLOpenPopup&amp;siteCode=" + idetab + " &quot;,&quot;&quot;,&quot;width=780,height=760,top=50,status=no,scrollbars=yes,resizable=no&quot;))\"><b style=\"text-decoration: underline;\">" + name + "</b></a></div>";
		} else {
			//Denime ID card
			dealer_description += "<div id=\"dealer_name\" ><a class=\"link01\" href=\"javascript:void(window.open(&quot;http://"+window.location.hostname+"/J47MAP/web/result.do?id=" + idetab + " &quot;,&quot;&quot;,&quot;width=780,height=760,top=50,status=no,scrollbars=yes,resizable=no&quot;))\"><b style=\"text-decoration: underline;\">" + name + "</b></a></div>";
		}
		
		dealer_description += "<div style=\"padding-left:20px;\" >";
		dealer_description += "<div id=\"dealer_address\" style=\"font-weight: bold;\">" + address+ "</div>";
		if(tel.length>0){
		dealer_description += "<div id=\"dealer_phone\"><img src=\"images/phone_icon.png\" />  " + tel + " </div>";
		}	
		if(web.length>0){
		dealer_description += "<div id=\"dealer_web\"><img src=\"images/web_icon.png\" /><a class=\"link01\" href=\"javascript:void(window.open(&quot;" + web + " &quot;,&quot;&quot;,&quot;&quot;))\"><b style=\"text-decoration: underline;\">" + web + "</b></a></div>";
		}
		dealer_description += "</div></div>";
		return dealer_description;
	}
	
	///
	// @Param:
	//	address: content entered by user
	//  limitedzoom: boolean, if true the search cannot zoom at a level higher than 10 (to let users see dealer nearby)
	//  
	//  @Required: in order to use this function, the page must contains a div called error containing the error message
	///
	function showAddress(address, limitedzoom) {
		if(document.getElementById("address") != null) {
			if(address.length <= 0){
				document.getElementById("address").style.backgroundColor = "#CC0000";
				return;
			}
			else {
				document.getElementById("address").style.backgroundColor = "#F6F6F6";
			}
		}
		
		var tabAccuracy = new Array(2,4,6,10,12,13,16,16,17,17);
		  if(limitedzoom){
			tabAccuracy = new Array(2,4,6,10,10,10,10,10,10,10);
		  }
		  if (geocoder) {
			geocoder.getLocations(address,
			function(response) {
			  if(response.Status.code!=200 || response.Placemark.length == 0){
				  errorShow(sTrad602);
			  } else {
				errorHide();
				place = response.Placemark[0];
				
				accuracy = place.AddressDetails.Accuracy;
				map.setCenter(new GLatLng(place.Point.coordinates[1],
					 place.Point.coordinates[0]), tabAccuracy[accuracy]);
			  }
			}
			);
		  }
		}
    
    function showMap() {
    	if (navigator.geolocation) {
    		navigator.geolocation.getCurrentPosition( 
    		
    	    function (position) {
    	    	if (geocoder) {
    	            geocoder.getLatLng(
    	             position.coords.latitude +","+ position.coords.longitude,
    	              function(point) {
    	                if (!point) {
    	                  alert("You have not been located.");
    	                } else {
    	                  map.setCenter(point, 14);
    	                  var marker = new GMarker(point);
    	                  map.addOverlay(marker);
    	                }
    	              }
    	            );
    	          }
    	    },
    	    function (error) {
    	        alert(error.message);
    	    }
    	    )
    	    
    	}
      }

    function calcIt() {
    	var from = document.getElementById("fromAddress").value;
		var to = document.getElementById("toAddress").value;
		var i = 0;
		if(from.length <= 0){
			document.getElementById("fromAddress").style.backgroundColor = "#CC0000";
			i++;
		}
		else {
			document.getElementById("fromAddress").style.backgroundColor = "#F6F6F6";
		}
		
		if(to.length <= 0){
			document.getElementById("toAddress").style.backgroundColor = "#CC0000";
			i++;
		}
		else {
			document.getElementById("toAddress").style.backgroundColor = "#F6F6F6";
		}
		
		if(i>0) return;
		
		var fromOK = false;
		var toOK = false;
		cluster.removeMarkers();
		var geoFrom = function(response) {
			if(response.Status.code != 200) { handleErrors(response.Status.code);return;}
			if(response.Placemark.length == 0) {return;}
			errorHide();
			var solutions = [];
			var placemark;
			var precision;
			for(var i=0;i<response.Placemark.length;i++) {
				placemark = response.Placemark[i];
				precision = placemark.AddressDetails.Accuracy;
				if(precision >= 4) {
					solutions.push(placemark.address);
				}
			}
			
			if(solutions.length == 0){ 
				errorShow(from +": " +sTradAddressnotfound);
			} else {
				errorHide();
				fromOK = true;
				from = solutions[0];
				document.getElementById("fromAddress").value = from;
			} 
			geoCalc();
		};
		
		var geoTo = function(response) {
			if(response.Status.code != 200) {
				handleErrors(response.Status.code);
				return;
			} 
			if(response.Placemark.length == 0) {
				return;
			}
			errorHide();
			var solutions = [];
			var placemark;
			var precision;
			for(var i=0;i<response.Placemark.length;i++) {
				placemark = response.Placemark[i];
				precision = placemark.AddressDetails.Accuracy;
				if(precision >= 4) {
					solutions.push(placemark.address);
				}
			}
			
			if(solutions.length == 0){ 
				errorShow(to +": " +sTradAddressnotfound);
			} else {
				errorHide();
				toOK = true;
				to = solutions[0];
				document.getElementById("toAddress").value = to;
			} 	
			geoCalc();
		};

		var geoCalc = function() {
			if(fromOK && toOK) {
				gdir.clear();
				gdir.load("from:" + from + " to:" + to, {getPolyline:true,getSteps:true});
				
			}
		};
		
		geocoder.getLocations(from, geoFrom);
		geocoder.getLocations(to, geoTo);
    }
    
    function handleErrors(code){
    	if( typeof code == "object"){
    		code = code.getStatus().code;
    	}
        if (code == G_GEO_UNKNOWN_ADDRESS)
        	errorShow(sTrad602);
           
        else if (code == G_GEO_UNKNOWN_DIRECTIONS)
        	errorShow(sTrad604);
        
        else errorShow(sTradErrorUnknown);
       }
    
    function showDirection() {
    	var route = gdir.getRoute(0);
    	var numSteps = route.getNumSteps();
    	var html = '<table cellspacing="0" cellpadding="5px" id="routeTable_0" style="font-size: 13px;" width="100%">';
    	
    	var stepPlace = [];
    	if(places != undefined && places.length > 0) {
    		for(var i = 0; i< places.length; i++) {
    			var step = places[i].getAttribute("step");
    			if(stepPlace[step] == undefined){
    				stepPlace[step] = 1;
    			}else{
    				stepPlace[step] += 1;	
    			}
    			
    		}
    	}
    	
    	var from = document.getElementById("fromAddress").value;
		var to = document.getElementById("toAddress").value;
		
    	html += '<tr class="stepHead" >';
    	html += '<td valign="top"></td><td> <b><img src="images/icon_greenA.png" />' + from + '</b> <b><img src="images/icon_greenB.png" />' + to + '</b></td><td> '+route.getDistance().html+ '<br /> (' + route.getDuration().html +  ')</td>';
    	html += '</tr>';
    	


    	
    	
    	for (var s = 0 ; s < numSteps ; s++ ) {
    		var step = route.getStep(s);
    		var stepLatLng = step.getLatLng();
    		//bounds.extend(stepLatLng);

    		var stepPolylineIndex = step.getPolylineIndex();
    		var stepDescriptionHTML = step.getDescriptionHtml();
    		//var re = new RegExp(pattern,'g');
    		//stepDescriptionHTML = stepDescriptionHTML.replace(re,'<b style="color:#CA0039">$1</b>');
    		var stepDistance = step.getDistance();
    		var stepDuration = step.getDuration();
    		if(s%2>0){
    			html += '<tr class="stepRow1" onclick="showStep(0,'+s+')"><td style="color: red; font-weight:bold;">&nbsp;&nbsp;' + (s+1) + '.</td><td> ' + stepDescriptionHTML + '</td><td>' + stepDistance.html + '</td></tr>';
    			if(stepPlace[s] > 0){
    				html += '<tr class="stepRow1" onclick="showStep(0,'+s+')"><td style="color: red; font-weight:bold;"></td><td style="color: red; font-weight:bold;">' + stepPlace[s] + ' ' + sTradDealers + ' </td><td>&nbsp;</td></tr>';	
    			} 
    		} else {
    			html += '<tr class="stepRow2" onclick="showStep(0,'+s+')"><td style="color: red; font-weight:bold;">&nbsp;&nbsp;' + (s+1) + '.</td><td> ' + stepDescriptionHTML + '</td><td>' + stepDistance.html + '</td></tr>';
    			if(stepPlace[s] > 0){
    				html += '<tr class="stepRow2" onclick="showStep(0,'+s+')"><td style="color: red; font-weight:bold;"></td><td style="color: red; font-weight:bold;">' + stepPlace[s] + ' ' + sTradDealers + ' </td><td>&nbsp;</td></tr>';	
    			} 
    		}
    	}
    	
    	html += '</table>';
    	document.getElementById("directions").innerHTML = "";
    	document.getElementById("directions").innerHTML = html;
    }
    
    function onGDirectionsLoad(){
		//showDirection();  
		var distance = gdir.getDistance()["meters"];
		errorHide();
		if( (distance /1000) > 1000){
			places = "";
			pline = "";
			document.getElementById("directions").innerHTML = "";
			document.getElementById("error").style.display = '';
		}else {
			document.getElementById("error").style.display = 'none';
			loadDealer("getEtabAlongRoute.do","rad=20&pline=" + getPolylinePoints(gdir.getPolyline()).join('x') + "&bounds=" + getBounds() + "&steps=" + getSteps(), false);
			pline = copyPolyline(gdir.getPolyline());
		}

    }
    
    function copyPolyline(p) {
    	var str = '';
    		pLinePoints = Array();
    		for (var n = 0 ; n < p.getVertexCount() ; n++ ) {
    			pLinePoints.push(p.getVertex(n));
    		}
    		var pLine = new GPolyline(pLinePoints,'#F7098A');
    		return pLine;
    	}

	function getPolylinePoints(p) {
		var pLinePoints = Array();
		for (var n = 0 ; n < p.getVertexCount() ; n++ ) {
			pLinePoints.push(p.getVertex(n).toUrlValue());
		}
		return pLinePoints;
		}
	
	function getPolylinePointsA() {
		var p =  gdir.getPolyline();
		var nbResult = p.getVertexCount();
		alert(nbResult);
		var sResult = "";
		for (var n = 0 ; n < nbResult ; n++ ) {
			var vertex = p.getVertex(n);
			sResult+= vertex.lng() + "," + vertex.lat();
			if(n<(nbResult-1)){
				sResult += "x";
			}
		}
		return sResult;
		}
	
	function getBounds() {
		
		var sResult = "";
		sResult += gdir.getBounds().getSouthWest().lng()+","+gdir.getBounds().getSouthWest().lat()+"x";
		sResult += gdir.getBounds().getNorthEast().lng()+","+gdir.getBounds().getNorthEast().lat();
		return sResult;
	}
	
	function getSteps() {
		
		var str = '';
		var route  = gdir.getRoute(0);
		for (var n = 0 ; n < route.getNumSteps() ; n++ ) {
			str += route.getStep(n).getPolylineIndex() +"x" ;
		}
		return str;
	}
	
	function errorShow(sContent){
		document.getElementById("error").innerHTML = sContent;
		document.getElementById("error").style.display = '';
	}
	
	function errorHide(){
		document.getElementById("error").style.display = 'none';
	}

	function showDealer(id) {
		map.closeInfoWindow();
		var dealer = markersArray[id];
		GEvent.trigger(dealer, "click");
		scroll(0,0);
	}
	
	function showStep(r,s) {
		map.closeInfoWindow();
		var step = gdir.getRoute(r).getStep(s);
		
		
		var stepLatLng = step.getLatLng();
		var stepDescriptionHTML = step.getDescriptionHtml();
		var stepDistance = step.getDistance();
		var stepDuration = step.getDuration();

		
		var infoHTML = '<div id="tab1" class="bubble" style="width: 220px">';
		infoHTML += '<table>';
		infoHTML += '<tr class="stepRow"><td>&nbsp;&nbsp;' + (s+1) + '.</td><td> ' + stepDescriptionHTML + '</td><td>' + stepDistance.html + '</td></tr>';
		infoHTML += '<tr class="stepRow"><td>&nbsp;&nbsp;</td colspan="2"><td> ' + stepLatLng + '</td></tr>';
		infoHTML += '</table>';
		infoHTML += '</div>';


		
		
		var tab1 = new GInfoWindowTab("Location", myDiv);
		var tab2 = new GInfoWindowTab("Info", infoHTML);
		var infoTabs = [tab1,tab2];
		map.openInfoWindowTabsHtml(stepLatLng,infoTabs);

		

		// Minimap for driving directions
		detailmap = new GMap2(myDiv, {"size": new GSize(200,200)});
		detailmap.setCenter(stepLatLng,15);
		
		detailmap.addControl(new GSmallMapControl());
		detailmap.addOverlay(pline);
		
		var CopyrightDiv = myDiv.firstChild.nextSibling;
		var CopyrightImg = myDiv.firstChild.nextSibling.nextSibling;
		CopyrightDiv.style.display = "none"; 
		CopyrightImg.style.display = "none"; 

		
	}

    
		
 