// Generic function to make getting elements easier function $() { var elements = new Array(); for (var i = 0; i < arguments.length; i++) { var element = arguments[i]; if (typeof element == 'string') element = document.getElementById(element); if (arguments.length == 1) return element; elements.push(element); } return elements; } function CaptureForm3(form) { // It would probably be a good idea to Geocode Ajax style here... maybe I'll do that later var err = $("leftdata"); form["mapsize"].value = getMapSize(); if(form["fromcoord"].value.length > 0 && form["tocoord"].value.length > 0 ) { return true; } var goodtogo = true; var errortext = ""; if (form["fromaddress"].value.length == 0) { errortext += "Please input a starting address

"; form["fromaddress"].focus(); goodtogo = false; } if (form["toaddress"].value.length == 0) { errortext += "Please input a destination address
"; if(goodtogo) { form["toaddress"].focus(); } goodtogo = false; } if(!goodtogo) { err.innerHTML = '
' + errortext + '
'; return false; } return true; } function getDirectionsAjax(form) { var err = $("leftdata"); form["mapsize"].value = getMapSize(); var goodtogo = true; var errortext = ""; if (form["fromaddress"].value.length == 0) { errortext += "Please input a starting address

"; form["fromaddress"].focus(); goodtogo = false; } if (form["toaddress"].value.length == 0) { errortext += "Please input a destination address
"; if(goodtogo) { form["toaddress"].focus(); } goodtogo = false; } if(!goodtogo) { err.innerHTML = '
' + errortext + '
'; } else { var scripturl = '?'; for(var i=0;i= 0) { mapElem.style.height = mapheight + "px"; sideElem.style.height = mapheight + "px"; } } function getWindowHeight() { if (window.self && self.innerHeight) {return self.innerHeight;} if (document.documentElement && document.documentElement.clientHeight) {return document.documentElement.clientHeight;} return 0; } function getMapSize() { var mapElem = document.getElementById("map"); var h = mapElem.offsetHeight; var w = mapElem.offsetWidth; return w + 'x' + h; } function showLegend() { // create the div for the legend var legend = document.createElement("div"); legend.id = "legend"; document.getElementById("map").appendChild(legend); legend.innerHTML = 'Legend:
walkWalkingpink
busBusblue
busSubwaygreen
'; } function resizeLeft(pixels) { var l = $('leftcontainer'); var m = $('mapcontainer'); l.style.width = pixels +"px"; m.style.marginLeft = (pixels+6) +"px"; if(gMap) gMap.checkResize(); } function initOverLabels () { if (!document.getElementById) return; var labels, id, field; // Set focus and blur handlers to hide and show // labels with 'overlabel' class names. labels = document.getElementsByTagName('label'); for (var i = 0; i < labels.length; i++) { if (labels[i].className == 'overlabel') { // Skip labels that do not have a named association // with another field. id = labels[i].htmlFor || labels[i].getAttribute('for'); if (!id || !(field = document.getElementById(id))) { continue; } // Change the applied class to hover the label // over the form field. labels[i].className = 'overlabel_apply'; // Hide any fields having an initial value. if (field.value !== '') { hideLabel(field.getAttribute('id'), true); } // Set handlers to show and hide labels. field.onfocus = function () { hideLabel(this.getAttribute('id'), true); }; field.onchange = function () { if (this.value != '') { hideLabel(this.getAttribute('id'), true); } }; field.onblur = function () { if (this.value === '') { hideLabel(this.getAttribute('id'), false); } }; // Handle clicks to label elements (for Safari). labels[i].onclick = function () { var id, field; id = this.getAttribute('for'); if (id && (field = document.getElementById(id))) { field.focus(); } }; } } }; function hideLabel (field_id, hide) { var field_for; var labels = document.getElementsByTagName('label'); for (var i = 0; i < labels.length; i++) { field_for = labels[i].htmlFor || labels[i].getAttribute('for'); if (field_for == field_id) { labels[i].style.textIndent = (hide) ? '-1000px' : '0px'; return true; } } } function initClickMode() { clickmode = $('clon').checked; GEvent.addListener(gMap, "click", function(marker, point) { if(clickmode && currentview ==1) { if (point) { if(first) { var coord = Math.round(point.lat()*100000)/100000 + "," + Math.round(point.lng()*100000)/100000; $("fromaddress").value = "Click (" + coord + ")"; $("fromaddress").onchange(); if(markerstart) gMap.removeOverlay(markerstart); markerstart = createStdMarker(point,"From: <\/b>
(" + coord + ")","start"); gMap.addOverlay(markerstart); first = false; } else { var coord = Math.round(point.lat()*100000)/100000 + "," + Math.round(point.lng()*100000)/100000; $("toaddress").value = "Click (" + coord +")"; $("toaddress").onchange(); if(markerend) gMap.removeOverlay(markerend); markerend = createStdMarker(point,"To: <\/b>
(" + coord + ")","end"); gMap.addOverlay(markerend); first = true; } } } }); } // PRINT VIEW function showLayout(num) { // for the printmode var layelems = $("lay0","lay1","lay2"); for(var i=0;i
"; infotext += this.result_.streetAddress + ", "; infotext += this.result_.city + "," + this.result_.region + "
"; if(this.result_.phoneNumbers) { for (var i=0; i < this.result_.phoneNumbers.length; i++) { if(this.result_.phoneNumbers[i].type == "main") { infotext += this.result_.phoneNumbers[i].number + ""; } } } infotext += '
Zoom In
'; infotext += 'Directions: '; infotext += "From here"; infotext += " - To here"; container.innerHTML += infotext; this.infotext_ = infotext; return container; } LocalResult.prototype.SidebarHtml = function() { if(this.container_) return this.container_; var container = document.createElement("div"); container.className = "searchresult_unsel"; container.id = 'searchres'+this.index; var htmltxt = ''; htmltxt += '
'; htmltxt += '' + this.result_.title + '
'; htmltxt += this.result_.streetAddress + ", "; htmltxt += this.result_.city + "," + this.result_.region + "
"; if(this.result_.phoneNumbers) { for (var i=0; i < this.result_.phoneNumbers.length; i++) { if(this.result_.phoneNumbers[i].type == "main") { htmltxt += this.result_.phoneNumbers[i].number + "
"; } } } htmltxt += 'Directions: '; htmltxt += "From here"; htmltxt += " - To here"; htmltxt += "
"; container.innerHTML += htmltxt; this.container_ = container; return container; } function openMarkerWindow(num,elem) { gCurrentResults[num-1].marker().openInfoWindow(gCurrentResults[num-1].InfoHtml()); highlightResult(num); } function highlightResult(num) { for(var i=0;i 1/100 - maxlat) grids.push(baseGrid+1); if (left > 1/100 - maxlng) grids.push(baseGrid+180*100); if (grids.length == 3 ) grids.push(grids[1] + grids[2] - grids[0]); // add the opposite corner if we have two sides return grids; } // returns the element indicies in each of the grids. e.g. input is grids 1000 and 1001, and each grid contains 4 points, // then the result may look like indicies[0].start: 100, indicies[0].end: 103, indicies[1].start: 221,indicies[1].start:224 function getSetofIndicies(Grids) { var indicies = []; for(var i=0;i gypsyMarkers[indx].r) return null; return indx; } function TooltipPositionHandler(point) { // okay, we need to do some performace hacking, the problem is too many calculation so lets wait until the user chills for a bit. currentpoint = point; if(timeoutid) clearTimeout(timeoutid); timeoutid = setTimeout("positionTooltip(currentpoint);",10); } function positionTooltip(point) { var indicies = getSetofIndicies(getGrids(point)); // debugPrintGrids(getGrids(point)); if(!indicies) { hideTooltip(); } else { var indx = getMarkerIndex(point,indicies) if(indx === null) { hideTooltip(); } else { showTooltip(indx); } } } /* function showInfoWindow(point) { var indicies = getSetofIndicies(getGrids(point)); if(!indicies) { return; } else { var indx = getMarkerIndex(point,indicies) if(indx === null) { return; } else { gMap.openInfoWindowHtml(gypsyMarkers[indx].point,gypsyMarkers[indx].html); } } } */ function showTooltip(indx) { if(currenttooltip != indx && !dragging) { // render tooltip tooltip.innerHTML = '
' + renderTooltipHTML(gypsyMarkers[indx]) + '
'; var point=gMap.getCurrentMapType().getProjection().fromLatLngToPixel(gMap.getBounds().getSouthWest(),gMap.getZoom()); var offset=gMap.getCurrentMapType().getProjection().fromLatLngToPixel(gypsyMarkers[indx].point,gMap.getZoom()); var pos = new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(offset.x - point.x+6,- offset.y + point.y+6)); pos.apply(tooltip); // postition tooltip cursorelem.style.cursor = 'pointer'; setTimeout("tooltip.style.visibility = 'visible'",50); // show tooltip (allow time to render) currenttooltip = indx; } } function renderTooltipHTML(GyMarker) { var label = "" + GyMarker.st + "
"; var lines = GyMarker.li; for (i=0;i"; } if(GyMarker.xfer) { label += " Xfer to "; var xferlines = GyMarker.xf; for(var i=0;i"; } } return label; } function hideTooltip() { tooltip.style.visibility= "hidden"; currenttooltip=-1; if (cursorelem.style.cursor == 'pointer') { cursorelem.style.cursor = defaultcursor; } } function debugPrintGrids(Grids) { ptbox.value =""; for(var i=0;i'; GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); }); return marker; } function loadsubwaymap(map) { // ====== Create a copyright entry ===== var copyright = new GCopyright(1, new GLatLngBounds(new GLatLng(53.8136257,-3.0981445),new GLatLng(53.8654855,-2.9663944) ), 18, "Subway Lines"); var copyrightCollection = new GCopyrightCollection('Map Data:'); copyrightCollection.addCopyright(copyright); CustomGetTileUrl=function(a,b){ var z = 17 - b; var w = ((a.x + a.y) % 4); // little hack to break the ie 2 connection limit var f = "http://ts" + w + ".gypsymaps.com/tiles/subway/?x="+a.x+"&y="+a.y+"&zoom="+z; return f; } var tilelayers = [new GTileLayer(copyrightCollection,10,16)]; tilelayers[0].getTileUrl = CustomGetTileUrl; var custommap = new GMapType(tilelayers, new GMercatorProjection(18), "Subway","grr"); map.addMapType(custommap); return custommap; } function loadbusmap(map) { var copyright = new GCopyright(1, new GLatLngBounds(new GLatLng(53.8136257,-3.0981445),new GLatLng(53.8654855,-2.9663944) ), 18, "Subway Lines"); var copyrightCollection = new GCopyrightCollection('Map Data:'); copyrightCollection.addCopyright(copyright); CustomGetTileUrl=function(a,b){ var z = 17 - b; var w = ((a.x + a.y) % 4); // little hack to break the ie 2 connection limit var f = "http://ts" + w +".gypsymaps.com/tiles/bus/?x="+a.x+"&y="+a.y+"&zoom="+z; return f; } var tilelayers = [new GTileLayer(copyrightCollection,10,16)]; tilelayers[0].getTileUrl = CustomGetTileUrl; var custommap = new GMapType(tilelayers, new GMercatorProjection(18), "Bus","grr"); map.addMapType(custommap); return custommap; }//Functions for the PAN & Zoom Custom controls var ZoomOut; var ZoomSlide = []; var IEBrowser = navigator.appVersion.split("MSIE"); var IEVersion = parseFloat(IEBrowser[1]); var maxzoom; // lets make these global var minzoom; var dragslider; var slideimage; function MyPanZoomControls() { } MyPanZoomControls.prototype = new GControl(); MyPanZoomControls.prototype.initialize = function(gMap) { me = this; var container = document.createElement("div"); container.id = "zoomcntrl"; var GoLeftDiv = document.createElement("div"); this.setButtonStyle_(GoLeftDiv,"images/controls/West.png","gw"); GoLeftDiv.style.top = "20px"; GoLeftDiv.style.left = "0px"; container.appendChild(GoLeftDiv); GEvent.addDomListener(GoLeftDiv, "click", GEvent.callbackArgs(gMap,gMap.panDirection,1,0)); var GoUpDiv = document.createElement("div"); this.setButtonStyle_(GoUpDiv,"images/controls/North.png","gn"); GoUpDiv.style.top = "0px"; GoUpDiv.style.left = "20px"; container.appendChild(GoUpDiv); GEvent.addDomListener(GoUpDiv, "click", GEvent.callbackArgs(gMap,gMap.panDirection,0,1)); var Center = document.createElement("div"); this.setButtonStyle_(Center,"images/controls/Center.png","gb"); Center.style.top = "20px"; Center.style.left = "20px"; container.appendChild(Center); GEvent.addDomListener(Center, "click", GEvent.callback(gMap,gMap.returnToSavedPosition)); var GoDownDiv = document.createElement("div"); this.setButtonStyle_(GoDownDiv,"images/controls/South.png","gs"); GoDownDiv.style.top = "40px"; GoDownDiv.style.left = "20px"; container.appendChild(GoDownDiv); GEvent.addDomListener(GoDownDiv, "click", GEvent.callbackArgs(gMap,gMap.panDirection,0,-1)); var GoRightDiv = document.createElement("div"); this.setButtonStyle_(GoRightDiv,"images/controls/East.png","ge"); GoRightDiv.style.top = "20px"; GoRightDiv.style.left = "40px"; container.appendChild(GoRightDiv); GEvent.addDomListener(GoRightDiv, "click", GEvent.callbackArgs(gMap,gMap.panDirection,-1,0)); var ZoomIn = document.createElement("div"); this.setButtonStyle_(ZoomIn,"images/controls/ZoomIn.png","zi"); ZoomIn.style.top = "65px"; ZoomIn.style.left = "20px"; container.appendChild(ZoomIn); GEvent.addDomListener(ZoomIn, "click",GEvent.callbackArgs(gMap,gMap.zoomIn)); /* GEvent.addDomListener(ZoomIn, "click", function() { gMap.zoomIn(); }); */ // Slide Bar var baseoffset = 84; var slideheight = 8; // Let's find out the global max and min zoom for our map maxzoom=0; //initialize value to something wrong so it is set in loop minzoom=100; var localmaxzoom=0; var localminzoom=100; var maptypes = gMap.getMapTypes(); var currentmap=false; var tilelayers; for(var j=0;j maxzoom) maxzoom = tilelayers[k].maxResolution(); if(currentmap) { if(tilelayers[k].minResolution() < localminzoom) localminzoom = tilelayers[k].minResolution(); if(tilelayers[k].maxResolution() > localmaxzoom) localmaxzoom = tilelayers[k].maxResolution(); } } } // lets figureout the constraints of the presently viewed var i = maxzoom; ZoomSlide[i] = document.createElement("div"); this.setButtonStyle_(ZoomSlide[i],"images/controls/TopCap.png","zoom" + i); ZoomSlide[i].style.top = (baseoffset + slideheight*(maxzoom -i) + 1) + "px";; ZoomSlide[i].style.left = "20px"; if(ilocalmaxzoom) this.makeInactive_(ZoomSlide[i]); else this.makeActive_(ZoomSlide[i]); ZoomSlide[i].zoomval = i; container.appendChild(ZoomSlide[i]); GEvent.addDomListener(ZoomSlide[i], "click",GEvent.callbackArgs(gMap,gMap.setZoom,i)); for(i=maxzoom-1;i>0;i--) { ZoomSlide[i] = document.createElement("div"); ZoomSlide[i].style.top = (baseoffset + slideheight*(maxzoom -i) + 4) + "px"; ZoomSlide[i].style.left = "20px"; this.setButtonStyle_(ZoomSlide[i],"images/controls/SlideNotch.png","zoom" + i); if( i < localminzoom || i>localmaxzoom) this.makeInactive_(ZoomSlide[i]); else this.makeActive_(ZoomSlide[i]); container.appendChild(ZoomSlide[i]); GEvent.addDomListener(ZoomSlide[i], "click",GEvent.callbackArgs(gMap,gMap.setZoom,i)); } ZoomSlide[i] = document.createElement("div"); this.setButtonStyle_(ZoomSlide[i],"images/controls/BottomCap.png","zoom" + i); ZoomSlide[i].style.top = (baseoffset + slideheight*(maxzoom -i) +4) + "px";; ZoomSlide[i].style.left = "20px"; container.appendChild(ZoomSlide[i]); if(ilocalmaxzoom) this.makeInactive_(ZoomSlide[i]); else this.makeActive_(ZoomSlide[i]); GEvent.addDomListener(ZoomSlide[i], "click",GEvent.callbackArgs(gMap,gMap.setZoom,i)); var ZoomOutDiv = document.createElement("div"); this.setButtonStyle_(ZoomOutDiv,"images/controls/ZoomOut.png","zo"); ZoomOutDiv.style.top = (baseoffset + slideheight*(maxzoom -i) +17) + "px";; ZoomOutDiv.style.left = "20px"; container.appendChild(ZoomOutDiv); GEvent.addDomListener(ZoomOutDiv, "click", function() { gMap.zoomOut(); }); SliderContainer = document.createElement("div"); SliderContainer.style.position = 'absolute'; SliderContainer.style.width = "0px"; SliderContainer.style.height = ((maxzoom+1) * slideheight + 3 ) + "px"; SliderContainer.style.top = "86px"; SliderContainer.style.left = "20px"; container.appendChild(SliderContainer); gMap.getContainer().appendChild(container); var slideimage = document.createElement("img"); if (!IEVersion || (IEVersion && IEVersion >= 7)) slideimage.src = "images/controls/slider.png"; else { slideimage.src = "images/controls/blank.gif"; slideimage.style.filter = "filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/controls/slider.png')"; } slideimage.style.display = 'block'; slideimage.style.position = 'absolute'; SliderContainer.appendChild(slideimage); dragslider = new GDraggableObject(slideimage,{container:SliderContainer}); // Add a listener for when the this has finsied dragging this way we can get the zoom GEvent.addListener(dragslider,"dragend",function() { var zoom = maxzoom - Math.round(this.top / 8); gMap.setZoom(zoom); // incase the zoom end event doesn't fire if(gMap.getZoom() != zoom) { dragslider.top = (maxzoom - gMap.getZoom())*8; slideimage.style.top = (maxzoom - gMap.getZoom())*8 + "px"; } }); // Add a listner for zoom end, and move the slider to the appropriate position GEvent.addListener(gMap,"zoomend",function(a,b) { dragslider.top = (maxzoom-b)*8; slideimage.style.top = (maxzoom-b)*8 + "px"; }); // set the inital position dragslider.top = (maxzoom - gMap.getZoom())*8; slideimage.style.top = (maxzoom - gMap.getZoom())*8 + "px"; this.createMapTypeListner(); return container; } MyPanZoomControls.prototype.makeActive_ = function(elem) { if (!IEVersion || (IEVersion && IEVersion >= 8)) { elem.style.opacity = ''; } else { elem.style.filter = ''; } } MyPanZoomControls.prototype.makeInactive_ = function(elem) { if (!IEVersion || (IEVersion && IEVersion >= 8)) { elem.style.opacity = '.4'; } else { elem.style.filter = 'alpha(opacity=40)'; } } MyPanZoomControls.prototype.setButtonStyle_ = function(button,imgfile,id) { var image = document.createElement("img"); if (!IEVersion || (IEVersion && IEVersion >= 8)) image.src = imgfile; // why version 8? see limitations in http://blogs.msdn.com/ie/archive/2005/04/26/412263.aspx -- alpha, alpha blending problem else { image.src = "images/controls/blank.gif"; image.style.filter = "filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+imgfile+"')"; } image.style.display = 'block'; image.id = id; button.appendChild(image); button.style.cursor = "pointer"; button.style.position = 'absolute'; button.style.display = 'block'; button.style.padding = "0px"; button.style.margin = "0px"; } MyPanZoomControls.prototype.getDefaultPosition = function() { return new GControlPosition(0,new GSize(6,7)); } MyPanZoomControls.prototype.createMapTypeListner = function() { var me = this; GEvent.addListener(gMap,"maptypechanged",function() { var minzoom =100; var maxzoom =0; var tilelayers = gMap.getCurrentMapType().getTileLayers(); for(var i=0;i maxzoom) maxzoom = tilelayers[i].maxResolution(); } for(var k=0;kmaxzoom) me.makeInactive_(ZoomSlide[k]); else me.makeActive_(ZoomSlide[k]); } }); } function CaptureForm2(form) { form["q"].value = betterAddress(form["q"].value); showAddress(form["q"].value); return false; } function betterAddress(add) { var betteradd; if(add.length > 3 && !(add.match(","))) { betteradd = add + ", New York, NY"; } else { betteradd = add; } return betteradd; } function showAddress(address) { var err = document.getElementById("adderrors"); var geocoder = new GClientGeocoder(); geocoder.getLatLng( address, function(point) { if (!point) { alert(address + " not found"); } else { gMap.setCenter(point, 13); var marker = new GMarker(point); gMap.addOverlay(marker); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(makeinfowindowHTML(address,point)); }); marker.openInfoWindowHtml(makeinfowindowHTML(address,point)); } } ); } function makeinfowindowHTML(address,point) { var html = address + "

"; html += "Get Transit Directions:
"; html += "From Here"; html += " To Here"; return html; } function doesIntersect(ax,ay,bx,by,cx,cy,dx,dy) { if( (ax == bx && ay == by) || (cx == dx && cy == dy) ) return 0; if( (bx - ax) != 0) { var t = ( (ay - cy) + (by - ay) * (cx - ax) / (bx-ax) ) / ( (dy - cy) - (by - ay) * (dx - cx) / (bx - ax) ); var s = (cx - ax + t * (dx - cx) ) / (bx - ax); } else { var t = (ax - cx) / (dx - cx); if( (by - ay) !=0 ) { var s = (cy - ay + t * (dy - cy) ) / (by - ay); } else { return 0; } } if(t < 0 || t > 1 || s > 1 || s < 0) { return 0; } else { var angle = perpDot(ax,ay,bx,by,cx,cy,dx,dy); if(angle >0) { return 1; } else { return 2; } } return 0; } function perpDot(ax,ay,bx,by,cx,cy,dx,dy) { var tx = bx-ax; var ty = by-ay; var tmag = Math.sqrt(Math.pow(tx,2) + Math.pow(ty,2)); var sx = dx-cx; var sy = dy-cy; var smag = Math.sqrt(Math.pow(sx,2) + Math.pow(sy,2)); tx = tx/tmag; ty = ty/tmag; sx = sx/smag; sy = sy/smag; return -ty * sx + tx * sy; } function doSegmentsIntersect(paa,pab,pba,pbb) { return doesIntersect(paa.lng(),paa.lat(),pab.lng(),pab.lat(),pba.lng(),pba.lat(),pbb.lng(),pbb.lat()); } function estimateTaxiFare(GyResult,elem) { if(!GyResult.fareEstimated) { d = new GDirections(); elem.style.display = 'block'; GEvent.addListener(d,"load",function() { GyResult.fareEstimated = true; if(this.getStatus().code == 200) { elem.innerHTML = 'Calculating...'; t = new TFE(this,GyResult); t.calc(); gMap.addOverlay(t.GDir.getPolyline()); elem.innerHTML = ''; elem.appendChild(t.getDomResult()); } else { elem.innerHTML = 'Grr... Something\'s Broken'; urchinTracker('/Taxi_Fare_Est_Fail'); } }); urchinTracker('/Taxi_Fare_Est'); points_arr = new Array(); points_arr.push(GyResult.from.point); points_arr.push(GyResult.to.point); d.loadFromWaypoints(points_arr,{getPolyline:true,getSteps:true}); elem.innerHTML = 'Loading...'; } else { if(elem.style.display=='block') { elem.style.display='none' } else { elem.style.display='block' } } } function TFE(googleDirections,GyResult) { this.GyResult = GyResult; this.GDir = googleDirections; this.totaltime =0; this.totaldist=0; this.waiting_time=0; this.driving_dist=0; this.tolls= new Array(); this.initial_cost=2.5; this.extras =0; this.tollBooths = null; this.fare = 0; this.totalcost = 0; } TFE.prototype.getDebugString = function() { var str = "waiting time:" + this.waiting_time + "
"; str += "driving dist:" + this.driving_dist + "
"; str += "initial_cost:" + this.initial_cost + "
"; str += "tolls:
"; for(var i=0;i"; } return str; } TFE.prototype.floatToCurr = function(amount) { dollars = parseInt(Math.floor(amount)); pennies = parseInt(Math.floor((amount-dollars)*100)); res = "$ " + dollars + "." if(pennies < 10) res += "0"; res += pennies; return res; } TFE.prototype.metersToMiles = function(m) { return Math.round( (m /1609.0)*10)/10; } TFE.prototype.secsToTime = function(secs) { res = new Object; res.hrs = Math.floor(secs/3600); rem = secs - res.hours*3600; res.mins = Math.floor(secs/60); rem = secs - res.mins*60; res.secs = Math.floor(secs); return res; } TFE.prototype.timeToText = function(t) { if(t.hours) { return "About " + t.hours + " hours " + t.mins + " minutes"; } else { return "About " + t.mins +" minutes"; } } TFE.prototype.getDomResult = function() { elem = document.createElement('div'); elem.className = "tcr_cont"; html = ''; html += ""; html += ""; html += "
Approx. Fare: " + ''+ this.floatToCurr(this.totalcost) + "
" + this.metersToMiles(this.totaldist) + " mi (" + this.timeToText(this.secsToTime(this.totaltime)) + ")
"; html += '
' html += ''; html += ""; html += ""; for (var i=0;i"; } html += "
Initial Fee " + this.floatToCurr(this.initial_cost) + "
Fare" + this.floatToCurr(this.fare) + "
" + this.floatToCurr(this.tolls[i].price) + "
"; html += "
"; elem.innerHTML = html; return elem; } TFE.prototype.calc = function() { this.totaldist = this.GDir.getDistance().meters; this.totaltime = this.GDir.getDuration().seconds; for(var i=0;i