<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="__MSG_title__"
             title_url="//maps.google.com"
             height="91"
             author="Google"
             author_email="googlemodules+drivingdirections+201205241@google.com"
             author_affiliation="Google"
             category="tools"
             screenshot="http://www.gstatic.com/ig/modules/driving_directions/driving_directions_content/driving_directions.cache.png"
             thumbnail="http://www.gstatic.com/ig/modules/driving_directions/driving_directions_content/driving_directions-thm.cache.png"
             description="__MSG_description__">
  <Require feature="dynamic-height"/>
  <Require feature="views"/>
  <Require feature="setprefs"/>
  <Icon>//www.gstatic.com/ig/modules/driving_directions/driving_directions_content/maps-16.cache.png</Icon>
  <Locale messages="/ig/modules/driving_directions/driving_directions_content/en_ALL.xml"/>
  <Locale country="uk" messages="/ig/modules/driving_directions/driving_directions_content/ALL_uk.xml"/>
  <Locale country="ie" messages="/ig/modules/driving_directions/driving_directions_content/ALL_uk.xml"/>
  <Locale country="ca" messages="/ig/modules/driving_directions/driving_directions_content/ALL_ca.xml"/>
  <Locale country="ca" lang="fr" messages="/ig/modules/driving_directions/driving_directions_content/fr_ca.xml"/>
  <Locale country="au" messages="/ig/modules/driving_directions/driving_directions_content/ALL_au.xml"/>
  <Locale country="nz" messages="/ig/modules/driving_directions/driving_directions_content/ALL_nz.xml"/>
  <Locale lang="en" country="ch" messages="/ig/modules/driving_directions/driving_directions_content/en_ch.xml"/>
  <Locale lang="da" messages="/ig/modules/driving_directions/driving_directions_content/da_ALL.xml"/>
  <Locale lang="de" messages="/ig/modules/driving_directions/driving_directions_content/de_ALL.xml"/>
  <Locale lang="es" messages="/ig/modules/driving_directions/driving_directions_content/es_ALL.xml"/>
  <Locale lang="es" country="mx" messages="/ig/modules/driving_directions/driving_directions_content/es_mx.xml"/>
  <Locale lang="fr" messages="/ig/modules/driving_directions/driving_directions_content/fr_ALL.xml"/>
  <Locale lang="it" messages="/ig/modules/driving_directions/driving_directions_content/it_ALL.xml"/>
  <Locale lang="ja" messages="/ig/modules/driving_directions/driving_directions_content/ja_ALL.xml"/>
  <Locale lang="pt-br" messages="/ig/modules/driving_directions/driving_directions_content/pt-br_ALL.xml"/>
  <Locale lang="fi" messages="/ig/modules/driving_directions/driving_directions_content/fi_ALL.xml"/>
  <Locale lang="no" messages="/ig/modules/driving_directions/driving_directions_content/no_ALL.xml"/>
  <Locale lang="sv" messages="/ig/modules/driving_directions/driving_directions_content/sv_ALL.xml"/>
</ModulePrefs>
<UserPref name="from" display_name="__MSG_start__" required="false" default_value="__MSG_start_location__"/>
<UserPref name="to" display_name="__MSG_end__" required="false" default_value="__MSG_end_location__"/>
<UserPref name="country" display_name="__MSG_location__" datatype="enum" default_value="__MSG_default_location__">
  <EnumValue value="0" display_value="__MSG_united_states__"/>
  <EnumValue value="1" display_value="__MSG_australia__"/>
  <EnumValue value="8" display_value="__MSG_belgium__"/>
  <EnumValue value="9" display_value="__MSG_brazil__"/>
  <EnumValue value="2" display_value="__MSG_canada__"/>
  <EnumValue value="11" display_value="__MSG_denmark__"/>
  <EnumValue value="13" display_value="__MSG_finland__"/>
  <EnumValue value="12" display_value="__MSG_france__"/>
  <EnumValue value="14" display_value="__MSG_germany__"/>
  <EnumValue value="4" display_value="__MSG_ireland__"/>
  <EnumValue value="15" display_value="__MSG_italy__"/>
  <EnumValue value="16" display_value="__MSG_japan__"/>
  <EnumValue value="19" display_value="__MSG_netherlands__"/>
  <EnumValue value="20" display_value="__MSG_norway__"/>
  <EnumValue value="5" display_value="__MSG_new_zealand__"/>
  <EnumValue value="22" display_value="__MSG_spain__"/>
  <EnumValue value="23" display_value="__MSG_sweden__"/>
  <EnumValue value="6" display_value="__MSG_switzerland__"/>
  <EnumValue value="7" display_value="__MSG_united_kingdom__"/>
</UserPref>
<Content type="html">
<![CDATA[
<style>body,td,a,p,.h{font-family:arial,sans-serif;font-size:13px}</style>
<script>var a="//maps.google.co.uk/maps",b="//maps.google.com.au/maps",d="//maps.google.com/maps",e="//maps.google.de/maps",f="//maps.google.nl/maps",g="//maps.google.se/maps",h="country",i="map_form",j=new _IG_Prefs,k=[d,b,"//maps.google.ca/maps",d,a,b,e,a,f,d,d,"//maps.google.dk/maps","//maps.google.fr/maps",g,e,"//maps.google.it/maps","//maps.google.co.jp/maps",d,d,f,g,d,"//maps.google.es/maps",g];_IG_RegisterOnloadHandler(function(){var c=_gel(i);null==c||null==c.action||(c.action=k[j.getString(h)])});</script>
<form action=//maps.google.com/maps id=map_form name=v1Form target=_blank>
<table id=directions_form width=100%>
<tr>
<td align=left rowspan=2 valign=top width=60px>
<img src=//www.gstatic.com/ig/modules/driving_directions/driving_directions_content/driving_directions-icon.cache.png>
</td>
<td style=text-align:right width=40px>__MSG_from__ </td>
<td>
<input id=saddr maxlength=1024 name=saddr style=width:100% value="__UP_from__">
</td>
<tr>
<td style=text-align:right width=40px>__MSG_to__ </td>
<td>
<input id=daddr maxlength=1024 name=daddr style=width:100% value="__UP_to__">
</td>
</table>
<input style=float:right;margin-right:3px;margin-bottom:5px type=submit value="__MSG_get_dirs__">
</form>
]]>
</Content>
<Content type="html" view="home">
<![CDATA[
<style>body,td,a,p{font-family:arial,sans-serif;font-size:13px;text-align:left}.dd-submit{float:right;margin:0 3px 5px}#error-msg{color:red;font-size:11px}.dd-default{color:#ccc}</style>
<script>var a="",e="//maps.google.ca/maps",h="//maps.google.co.jp/maps",i="//maps.google.co.uk/maps",j="//maps.google.com.au/maps",k="//maps.google.com/maps",l="//maps.google.de/maps",m="//maps.google.dk/maps",n="//maps.google.es/maps",o="//maps.google.fr/maps",p="//maps.google.it/maps",q="//maps.google.nl/maps",r="//maps.google.se/maps",u="block",v="canvas",w="country",x="daddr",y="destination",z="error-msg",A="field_missing",B="fields_equal",C="from",D="mapInputForm",E="none",F="profile",G="saddr",H="source",
I="to",J=new _IG_Prefs;
function K(){var c=[k,j,e,k,i,j,l,i,q,k,k,m,o,r,l,p,h,k,k,q,r,k,n,r],f=_gel(G),b=f.value,s=_gel(x),d=s.value,g=_gel(z),t=J.getMsg(A);if(!b||b==J.getMsg(H))g.style.display=u,g.innerHTML=t,f.focus(),_IG_AdjustIFrameHeight();else if(!d||d==J.getMsg(y))g.style.display=u,g.innerHTML=t,s.focus(),_IG_AdjustIFrameHeight();else if(_trim(b.toLowerCase())==_trim(d.toLowerCase()))g.style.display=u,f.focus(),g.innerHTML=J.getMsg(B),_IG_AdjustIFrameHeight();else if(J.getString(I)!=d&&J.getString(C)!=b?J.set(I,
d,C,b):(J.getString(I)!=d&&J.set(I,d),J.getString(C)!=b&&J.set(C,b)),(f=gadgets.views.getCurrentView())&&f.getName().toLowerCase()!=F)c={src:b,dest:d},gadgets.views.requestNavigateTo(new gadgets.views.View(v),c);else if((b=_gel(D))&&b.action)b.action=c[J.getString(w)],b.submit(),g.style.display=E}function L(c){c.value==c.defaultValue&&(c.value=a);c.className=a}function M(){var c=_gel(G),f=_gel(x);c.value=J.getString(C);f.value=J.getString(I)}_IG_RegisterOnloadHandler(M);window.clearInputOnFocus=L;
window.validate=K;</script>
<form action=//maps.google.com/maps id=mapInputForm onSubmit="validate();return false;" target=_blank>
<table border=0 cellpadding=0 cellspacing=0 width=100%>
<tr>
<td align=left valign=top width=60px>
<img src=//www.gstatic.com/ig/modules/driving_directions/driving_directions_content/driving_directions-icon.cache.png>
</td>
<td valign=top>
<table border=0 width=100%>
<tr>
<td width=40px></td>
<td colspan=2 id=error-msg></td>
<tr>
<td width=40px>__MSG_from__</td>
<td><input id=saddr maxlength=1024 name=saddr onFocus=clearInputOnFocus(this) style=width:100%>
</td>
<tr>
<td width=40px>__MSG_to__</td>
<td>
<input id=daddr maxlength=1024 name=daddr onFocus=clearInputOnFocus(this) style=width:100%>
</td>
</table>
</td>
</table>
<input class=dd-submit type=submit value="__MSG_get_dirs__">
</form>
]]>
</Content>

<Content type="html" view="canvas">
<![CDATA[
<style>body{position:relative}body,a,p,td,div{font-family:arial,sans-serif;font-size:13px}table{border-collapse:collapse}#dd-view-panel{border:1px solid;height:295px;position:relative}#dd-panel{border:1px solid #000;height:290px;position:relative}#dd-street-status{background-color:#fff;color:#666;font-size:15px;position:absolute;text-align:center;top:120px;width:100%}#dd-search-error{background-color:#fff;color:red;font-size:15px;left:5px;position:absolute;top:10px}#dd-route-steps{font-size:13px;position:absolute;text-align:center;top:2px;width:100%}#dd-street-view{height:295px;left:0;position:absolute;top:0}#dd-map{height:100%;position:relative;width:100%}#dd-canvas-directions{height:290px;overflow:auto;overflow-x:hidden;position:relative;width:100%}.dd-letter{background-color:#fff;border-bottom:1px solid #cdcdcd;padding:2px;position:relative}.dd-icon{height:38px;width:24px}.dd-waypoint{left:32px;position:absolute;top:5px}#dd-summary{font-weight:bold;padding:4px}.dd-popup,.dd-current-step{margin-left:4px;margin-right:4px;padding:4px 4px 8px}.dd-current-step{background-color:#fff;border-bottom:1px solid #cdcdcd;cursor:pointer}.dd-button{border:1px solid #000;border-top-width:0}.dd-txtlabel{padding:0 3px 0 5px}.dd-message,.dd-heading{background-color:#e4ebfd;border:1px solid #000;height:27px}.dd-message{border-bottom-width:0}.dd-heading{line-height:23px}.dd-links{color:#00c;cursor:pointer;text-decoration:underline}.dd-step-number{border-bottom:1px solid #cdcdcd;padding:4px 0 0 9px;vertical-align:top}.dd-canvas{border:1px solid #000;border-bottom-width:0;border-top-width:0}</style>
<script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;client=google-mapsearch-gadget"></script>
<script src="http://gmaps-utility-library.googlecode.com/svn/trunk/extmaptypecontrol/release/src/extmaptypecontrol.js"></script>
<script>var prefs=new _IG_Prefs;var mapControl;var pano;var svClient;var directions;var route;var vertices;var vertexMap;var stepToVertex;var stepMap;var currentLatLng;var panoMetaData;var close;var bearing;var nextBearing;var nextVertexId;var nextVertex;var progressArray;var progressDistance;var currentStep;var carMarker;var selectedStep;var isDriving;var advanceTimer;var isPanorama;var trafficInfo;var toggleTrafficState;
var errorType={SERVER_ERR:500,LOC_ERR:600,FLASH_ERR:603};
function load(){GEvent.addListener(window,"unload",GUnload);var homePrefs=gadgets.views.getParams();if(GBrowserIsCompatible()){var start=new GLatLng(37.09024,-95.712891);mapControl=new GMap2(_gel("dd-map"));mapControl.setCenter(start,15);mapControl.addControl(new GLargeMapControl);mapControl.addControl(new ExtMapTypeControl({showTraffic:true,showTrafficKey:true}));carMarker=getCarMarker(start);mapControl.addOverlay(carMarker);var source=_gel("source");var destination=_gel("destination");carMarker.hide();
svClient=new GStreetviewClient;pano=new GStreetviewPanorama(_gel("dd-street-view"));GEvent.addDomListener(source,"keyup",handleKeyEvent);GEvent.addDomListener(destination,"keyup",handleKeyEvent);GEvent.addListener(pano,"initialized",function(loc){panoMetaData=loc;moveCar(0)});GEvent.addListener(pano,"error",function(errorCode){showStatus(prefs.getMsg(errorCode==errorType.FLASH_ERR?"flash_error":"street_error"))});directions=new GDirections(mapControl);GEvent.addListener(directions,"load",function(){isPanorama=
1;drawRouteMap()});GEvent.addListener(directions,"error",function(){var statusCode=directions.getStatus().code;var ERROR_MSG=prefs.getMsg("err_code");switch(statusCode){case G_GEO_UNKNOWN_ADDRESS:showErrMsg(prefs.getMsg("no_location_found")+"\n"+ERROR_MSG+statusCode);break;case G_GEO_SERVER_ERROR:showErrMsg(prefs.getMsg("geocoding_request_failed")+"\n"+ERROR_MSG+gdir.getStatus().code);break;case G_GEO_MISSING_QUERY:showErrMsg(prefs.getMsg("param_missing")+"\n"+ERROR_MSG+statusCode);break;case G_GEO_BAD_REQUEST:showErrMsg(prefs.getMsg("dir_not_parsed")+
"\n"+ERROR_MSG+statusCode);break;default:showErrMsg(prefs.getMsg("unknown_err"));break}showStatus(prefs.getMsg("error"));_gel("dd-canvas-directions").innerHTML="";_gel("stopAndGo").disabled=true;carMarker.hide()});if(!homePrefs.src||!homePrefs.dest){source.value=prefs.getString("from");destination.value=prefs.getString("to")}else{source.value=homePrefs.src;destination.value=homePrefs.dest}}var mapNode=_gel("dd-map").lastChild;if(mapNode&&mapNode.firstChild&&mapNode.firstChild.firstChild)mapNode.firstChild.firstChild.onclick=
toggleTraffic;generateRoute()}function handleKeyEvent(event){event=event||window.event;var keyEvent=event.keyCode||event.which||event.charCode;if(keyEvent==13)validate()}function toggleTraffic(){if(toggleTrafficState){mapControl.removeOverlay(trafficInfo);toggleTrafficState=0}else{var trafficOptions={incidents:true};trafficInfo=new GTrafficOverlay(trafficOptions);mapControl.addOverlay(trafficInfo);toggleTrafficState=1}}function getCarMarker(start){return new GMarker(start,getArrowIcon(0))}
function setCarMarkerImage(bearing){carMarker.setImage(getArrowUrl(bearing))}function generateRoute(){mapControl.closeInfoWindow();var from=_gel("source").value;var to=_gel("destination").value;directions.load("from: "+from+" to: "+to,{getSteps:true})}function drawRouteMap(){route=directions.getRoute(0);collapseVertices(directions.getPolyline());renderTextDirections();checkCoverage(0);currentLatLng=vertices[0];carMarker.setLatLng(currentLatLng);jumpToVertex(0)}
function checkCoverage(step){if(step>route.getNumSteps()){isPanorama=0;hideStatus();stopDriving();jumpToVertex(0)}else{var latLong=step==route.getNumSteps()?route.getEndLatLng():route.getStep(step).getLatLng();svClient.getNearestPanorama(latLong,function(svData){if(svData.code==errorType.SERVER_ERR)setTimeout("checkCoverage("+step+")",4E3);else if(svData.code==errorType.LOC_ERR){showStatus(prefs.getMsg("street_error"));jumpToVertex(0)}else checkCoverage(step+1)})}}
function jumpToVertex(idx){hideStatus();mapControl.closeInfoWindow();currentLatLng=vertices[idx];nextVertex=vertices[idx+1];nextVertexId=idx+1;bearing=getBearingFromVertex(idx);nextBearing=getBearingFromVertex(idx+1);if(bearing){setCarMarkerImage(bearing);carMarker.setLatLng(currentLatLng);carMarker.show();currentStep=stepMap[idx];constructProgressArray(idx);setProgressDistance();if(idx)mapControl.panTo(currentLatLng,16);highlightStep(currentStep);checkDistanceFromNextVertex();if(!isPanorama){pano.setLocationAndPOV(currentLatLng,
{yaw:bearing,pitch:0});svClient.getNearestPanorama(currentLatLng,function(loc){if(loc.code==errorType.SERVER_ERR)setTimeout("jumpToVertex("+idx+")",1E3);else if(loc.code==errorType.LOC_ERR){showStatus(prefs.getMsg("street_error"));jumpToVertex(0)}else{panoMetaData=loc.location;panoMetaData.pov.yaw=bearing;moveCar(idx)}})}else showStatus(prefs.getMsg("street_error"))}if(!bearing&&!nextBearing){carMarker.setLatLng(route.getEndLatLng());carMarker.show();if(idx)mapControl.panTo(currentLatLng,16);endReached()}}
function moveCar(carFlag){currentLatLng=panoMetaData.latlng;carMarker.setLatLng(currentLatLng);if(carFlag)mapControl.panTo(currentLatLng);svClient.getNearestPanorama(panoMetaData.latlng,function(svData){if(svData.code==errorType.SERVER_ERR)setTimeout("moveCar(0)",4E3);else if(svData.code==errorType.LOC_ERR){showStatus(prefs.getMsg("street_error"));jumpToVertex(0)}else{panoMetaData.links=svData.links;checkDistanceFromNextVertex();if(isDriving)advanceTimer=setTimeout("selectBestRoute()",1E3)}});var panoramaObj=
_gel("panoflash1");if(panoramaObj)panoramaObj.style.width="100%"}function checkDistanceFromNextVertex(){close=false;var dist=currentLatLng.distanceFrom(nextVertex);var bearingNumber=getBearing(currentLatLng,nextVertex);if(getYawDelta(bearing,bearingNumber)>90){incrementVertex();if(isDriving)checkDistanceFromNextVertex()}else{if(isDriving)updateViewerDirections(progressDistance-dist);if(dist<10)close=true}}function checkPanoMetaData(){if(!panoMetaData||!panoMetaData.links)return 1;return 0}
function selectBestRoute(){mapControl.closeInfoWindow();if(checkPanoMetaData())return;var selected=selectLink(bearing);if(checkPanoMetaData())return;if(close&&nextBearing){var selectedTurn=selectLink(nextBearing);if(selectedTurn.delta<15){selected=selectedTurn;incrementVertex()}}if(selected.delta>40)jumpToVertex(nextVertexId);else{if(checkPanoMetaData())return;var panAngle=getYawDelta(panoMetaData.pov.yaw,panoMetaData.links[selected.idx].yaw);pano.panTo({yaw:panoMetaData.links[selected.idx].yaw,pitch:0});
setTimeout(function(){if(checkPanoMetaData())return;pano.followLink(panoMetaData.links[selected.idx].yaw)},panAngle*10)}}function selectLink(yaw){var nextSelectedLink=[];var metaDataLength=panoMetaData.links.length;for(var i=0;i<metaDataLength;i++){var yawDelta=getYawDelta(yaw,panoMetaData.links[i].yaw);if(!nextSelectedLink.delta||yawDelta<nextSelectedLink.delta){nextSelectedLink.idx=i;nextSelectedLink.delta=yawDelta}}return nextSelectedLink}
function incrementVertex(){if(!vertices[nextVertexId+1])endReached();else{nextVertexId++;nextVertex=vertices[nextVertexId];bearing=getBearingFromVertex(nextVertexId-1);nextBearing=getBearingFromVertex(nextVertexId);setCarMarkerImage(bearing);if(stepMap[nextVertexId-1]==currentStep)progressArray.push(nextVertex);else{currentStep=stepMap[nextVertexId-1];highlightStep(currentStep);progressArray=[currentLatLng,nextVertex]}setProgressDistance()}}
function endReached(){stopDriving();showInstruction(prefs.getMsg("reached"));_gel("step"+selectedStep).style.backgroundColor="#fff";_gel("stepid"+selectedStep).style.backgroundColor="#fff";_gel("stopAndGo").disabled=true;selectedStep=null}function getBearingFromVertex(stepNumber){var origin=vertices[stepNumber];var destination=vertices[stepNumber+1];return destination?getBearing(origin,destination):null}
function updateViewerDirections(distanceFromStartOfStep){var lengthOfStep=route.getStep(currentStep).getDistance().meters;var distanceFromEndOfStep=lengthOfStep-distanceFromStartOfStep;distanceFromEndOfStep*=3.2808399;var uiDistance,unit,sUnit=prefs.getMsg("mile");switch(Math.floor(distanceFromEndOfStep/660)){case 0:uiDistance=Math.round(distanceFromEndOfStep/10)*10;unit=prefs.getMsg("ft");break;case 1:case 2:uiDistance="&frac14;";unit=sUnit;break;case 3:case 4:uiDistance="&frac12;";unit=sUnit;break;
case 5:case 6:uiDistance="&frac34;";unit=sUnit;break;case 7:uiDistance="1";unit=sUnit;break;default:distanceFromEndOfStep/=5280;uiDistance=distanceFromEndOfStep.toFixed(0);unit=prefs.getMsg("miles");break}if(route.getStep(currentStep+1))showInstruction("In "+uiDistance+" "+unit+":"+route.getStep(currentStep+1).getDescriptionHtml());else showInstruction("In "+uiDistance+" "+unit+" : "+prefs.getMsg("will_reach"))}
function constructProgressArray(vertexId){progressArray=[];var vCount=vertexId+1;for(var i=stepToVertex[currentStep];i<=vCount;i++)progressArray.push(vertices[i])}function setProgressDistance(){var polyline=new GPolyline(progressArray);progressDistance=polyline.getLength()}function getYawDelta(yawParamOne,yawParamTwo){var deflDelta=Math.abs(sanitiseYaw(yawParamOne)-sanitiseYaw(yawParamTwo));return deflDelta>180?360-deflDelta:deflDelta}function sanitiseYaw(yaw){return yaw!=360?yaw%360:yaw}
function getArrowIcon(bearing){var icon=new GIcon;icon.image=getArrowUrl(bearing);icon.iconSize=new GSize(24,24);icon.iconAnchor=new GPoint(12,12);return icon}function getArrowUrl(bearing){var id=3*Math.round(bearing/3)%120;return"//maps.google.com/mapfiles/dir_"+id+".png"}
function collapseVertices(path){vertices=[path.getVertex(0)];vertexMap=new Array(path.getVertexCount());vertexMap[0]=0;var vertexCount=path.getVertexCount();for(var i=1;i<vertexCount;i++){var getPathVertex=path.getVertex(i);if(!getPathVertex.equals(vertices[vertices.length-1]))vertices.push(getPathVertex);vertexMap[i]=vertices.length-1}stepToVertex=new Array(route.getNumSteps());stepMap=new Array(vertices.length);var getRouteSteps=route.getNumSteps();for(var j=0;j<getRouteSteps;j++)stepToVertex[j]=
vertexMap[route.getStep(j).getPolylineIndex()];var step=0,verticeLength=vertices.length;for(var k=0;k<verticeLength;k++){if(stepToVertex[step+1]==k)step++;stepMap[k]=step}}
function renderTextDirections(){var startAddress=route.getStartGeocode().address;var endAddress=route.getEndGeocode().address;var html=[];html.push(getDivHtml("dd-summary","",route.getSummaryHtml()));html.push(getDirectionsWaypointHtml(startAddress,"A"));html.push('<table border="0" width ="100%">');for(var n=0;n<route.getNumSteps();n++)html.push('<tr class="dd-current-step" ','onclick="selectStep(',n,')">','<td id="stepid',n,'" class="dd-step-number">&nbsp;',n+1,".</td>",'<td id="step',n,'" ','class="dd-current-step">',
route.getStep(n).getDescriptionHtml(),"</td></tr>");html.push("</table>");html.push(getDirectionsWaypointHtml(endAddress,"B"));var directionElement=_gel("dd-canvas-directions");directionElement.innerHTML=html.join("");directionElement.style.display="";_gel("dd-search-error").style.display="none";setWaypointIcon("A");setWaypointIcon("B")}
function getDirectionsWaypointHtml(address,letter){var content=[];var divHtml=getDivHtml("letter"+letter,"dd-icon","");content.push(divHtml,'<span class="dd-waypoint"> ',address," </span>");return getDivHtml("wayPoint"+letter,"dd-letter",content.join(""))}function setWaypointIcon(letter){var png="//maps.google.com/intl/en_us/mapfiles/icon_green"+letter+".png";_gel("letter"+letter).style.backgroundImage="url("+png+")"}
function getDivHtml(id,cssClass,content){var html=["<div"];if(id)html.push(' id="',id,'"');if(cssClass)html.push(' class="',cssClass,'"');html.push(">",content,"</div>");return html.join("")}function selectStep(stepNumber){var vertex=vertexMap[route.getStep(stepNumber).getPolylineIndex()];stopDriving();jumpToVertex(vertex)}
function highlightStep(stepNumber){if(selectedStep!=null){_gel("step"+selectedStep).style.backgroundColor="#fff";_gel("stepid"+selectedStep).style.backgroundColor="#fff"}var popUpHtml=['<div class="dd-popup">',route.getStep(stepNumber).getDescriptionHtml(),'</div><div class="dd-popup">',prefs.getMsg("jump_to"),'<span class="dd-links" onclick = "selectStep'];if(!stepNumber){popUpHtml.push("(",stepNumber+1,')">',prefs.getMsg("next"),"</span></div>");mapControl.openInfoWindowHtml(currentLatLng,popUpHtml.join(""))}else if(stepNumber>
0&&stepNumber<route.getNumSteps()-1){popUpHtml.push("(",stepNumber-1,')">',prefs.getMsg("prev"),'</span>&nbsp;&nbsp;<span class="dd-links" onclick="'+"selectStep(",stepNumber+1,')">',prefs.getMsg("next"),"</span></div>");mapControl.openInfoWindowHtml(currentLatLng,popUpHtml.join(""))}else{popUpHtml.push("(",stepNumber-1,')">',prefs.getMsg("prev"),"</span></div>");mapControl.openInfoWindowHtml(currentLatLng,popUpHtml.join(""))}_gel("stepid"+stepNumber).style.backgroundColor="#eee";_gel("step"+stepNumber).style.backgroundColor=
"#eee";selectedStep=stepNumber}function startDriving(){hideInstruction();mapControl.closeInfoWindow();var stopAndGoElement=_gel("stopAndGo");stopAndGoElement.value=prefs.getMsg("stop");stopAndGoElement.onclick=stopDriving;isDriving=true;selectBestRoute()}
function stopDriving(){isDriving=false;if(advanceTimer){clearTimeout(advanceTimer);advanceTimer=null}var stopAndGoElement=_gel("stopAndGo");stopAndGoElement.disabled=false;stopAndGoElement.value=prefs.getMsg("drive");stopAndGoElement.onclick=startDriving;showInstruction(prefs.getMsg("drive_instructions"))}
function showStatus(message){hideInstruction();var svStatusElement=_gel("dd-street-status");svStatusElement.innerHTML=message;svStatusElement.style.display="";_gel("dd-street-view").style.display="none";_gel("stopAndGo").disabled=true}function showErrMsg(message){var errorElement=_gel("dd-search-error");errorElement.innerHTML=message;errorElement.style.display="";_gel("dd-canvas-directions").style.display="none"}
function hideStatus(){_gel("dd-street-status").style.display="none";_gel("dd-street-view").style.display=""}function showInstruction(message){var driveElement=_gel("dd-route-steps");driveElement.style.display="";driveElement.innerHTML=message}function hideInstruction(){_gel("dd-route-steps").style.display="none"}
function getBearing(origin,destination){if(origin.equals(destination))return null;var srcLatitude=degreesToRadians(origin.lat());var destLatitude=degreesToRadians(destination.lat());var dLong=degreesToRadians(destination.lng()-origin.lng());var y=Math.sin(dLong)*Math.cos(destLatitude);var x=Math.cos(srcLatitude)*Math.sin(destLatitude)-Math.sin(srcLatitude)*Math.cos(destLatitude)*Math.cos(dLong);return degreesToBrng(Math.atan2(y,x))}function degreesToRadians(degree){return degree*Math.PI/180}
function radiansToDegree(radian){return radian*180/Math.PI}function degreesToBrng(degree){return(radiansToDegree(degree)+360)%360}function clearAllMarkers(){mapControl.clearOverlays();mapControl.addOverlay(carMarker);carMarker.hide();if(toggleTrafficState){toggleTrafficState=0;toggleTraffic()}}
function clearPrevResults(){carMarker.hide();selectedStep=null;mapControl.closeInfoWindow();stopDriving();_gel("dd-canvas-directions").innerHTML="";_gel("dd-street-status").innerHTML="";_gel("dd-street-view").innerHTML="";hideInstruction();_gel("stopAndGo").disabled=true}
function validate(){var origin=_gel("source");var destination=_gel("destination");clearPrevResults();if(!origin.value){showErrMsg(prefs.getMsg("source"));origin.focus();clearAllMarkers()}else if(!destination.value){showErrMsg(prefs.getMsg("destination"));destination.focus();clearAllMarkers()}else if(_trim(origin.value.toLowerCase())==_trim(destination.value.toLowerCase())){origin.value="";destination.value="";origin.focus();showErrMsg(prefs.getMsg("same_error"));clearAllMarkers()}else{prefs.set("to",
_trim(destination.value),"from",_trim(origin.value));generateRoute()}}function swapLocations(){var srcElement=_gel("source");var destElement=_gel("destination");var temp=srcElement.value;srcElement.value=destElement.value;destElement.value=temp}_IG_RegisterOnloadHandler(load);window.startDriving=startDriving;window.validate=validate;</script>
<div id=main-div>
<table border=0 cellpadding=2 cellspacing=2 height=100% valign=top width=100%>
<tr>
<td valign=top width=70%>
<div id=dd-map></div>
</td>
<td width=1%></td>
<td valign=top width=20%>
<div class=dd-heading width=100%>
&nbsp;__MSG_driving_directions__
</div>
<table border=0 cellpadding=0 cellspacing=0 class=dd-canvas height=105px width=100%>
<tr>
<td class=dd-txtlabel style=padding-top:3px;>__MSG_from__</td>
<td style=padding-top:4px;><input id=source size=30 value=""></td>
<td align=left rowspan=3 valign=middle width=10%>
<span style=vertical-align:middle;>
<img alt="__MSG_swap__" id=swap onclick=swapLocations(); src=//www.gstatic.com/ig/modules/driving_directions/driving_directions_content/swap.cache.png style=cursor:pointer;>
</span>
</td>
<tr>
<td colspan=2></td>
<tr>
<td class=dd-txtlabel>__MSG_to__</td>
<td><input id=destination size=30 value=""></td>
<tr>
<td width=10%></td>
<td>
<input id=dd-route onclick="validate();return false;" type=button value="__MSG_get_dirs__">
</td>
<td>&nbsp;</td>
</table>
<div id=dd-panel>
<div id=dd-canvas-directions></div>
<div id=dd-search-error></div>
</div>
<div id=dd-blank-div style="padding: 2%"></div>
<table width=100%>
<tr>
<td class=dd-message>&nbsp;__MSG_drive_location__</td>
</table>
<div id=dd-view-panel>
<div id=dd-street-view style="width: 100%; height: 295px;"></div>
<div id=dd-street-status>__MSG_street_error__</b></div>
<div id=dd-route-steps></div>
</div>
<table class=dd-button width=100%>
<tr>
<td align=center style="padding-top: 2px;padding-bottom: 2px;">
<input id=stopAndGo onclick=startDriving(); style=width:70px; type=button value="__MSG_drive__">
</td>
</table>
</td>
</table>
</div>
]]>
</Content>
</Module>
