
var map;var icon1;var icon2;var icon3;var icon4;var path;var active;var gmarkers;var addresses;var bounds;var gdir;var geo;var tempaddress;var pasajeros;var idamarcada;var vueltamarcada;var iconcoincidencia1;var iconcoincidencia2;var iconcoincidencia3;var iconcoincidencia4;var iconcoincidencia5;var pathStartCoincidencia1;var pathEndCoincidencia1;var pathStartCoincidencia2;var pathEndCoincidencia2;var pathStartCoincidencia3;var pathEndCoincidencia3;var pathStartCoincidencia4;var pathEndCoincidencia4;var pathStartCoincidencia5;var pathEndCoincidencia5;var gdir1;var gdir2;var gdir3;var gdir4;var gdir5;function obtenerCalle(point,idavuelta){var reversegeocoder=new GReverseGeocoder(map);GEvent.addListener(reversegeocoder,"load",function(placemark){var reverseaddress=reversegeocoder.getPlacemarkProperty(placemark,"ThoroughfareName");if(reverseaddress!=null){if(idavuelta==1){document.getElementById("dirida").value=reverseaddress;document.getElementById("diridahidden").value=document.getElementById("dirida").value;}
else if(idavuelta==2){document.getElementById("dirvuelta").value=reverseaddress;document.getElementById("dirvueltahidden").value=document.getElementById("dirvuelta").value;}}
else alert("No se pudo obtener una direccion del punto seleccionado. Ubique el punto sobre una calle para mayor precision");});reversegeocoder.reverseGeocode(point);}
function obtenerCalleNo(idavuelta){if(idavuelta==1){document.getElementById("dirida").value="Origen";document.getElementById("diridahidden").value=document.getElementById("dirida").value;}
else if(idavuelta==2){document.getElementById("dirvuelta").value="Destino";document.getElementById("dirvueltahidden").value=document.getElementById("dirvuelta").value;}}
function obtenerCalleDrag(point,idavuelta){var reversegeocoder=new GReverseGeocoder(map);GEvent.addListener(reversegeocoder,"load",function(placemark){var reverseaddress=reversegeocoder.getPlacemarkProperty(placemark,"ThoroughfareName");if(reverseaddress!=null){if(idavuelta==1){document.getElementById("dirida").value='';document.getElementById("diridahidden").value=reverseaddress;}
else if(idavuelta==2){document.getElementById("dirvuelta").value='';document.getElementById("dirvueltahidden").value=reverseaddress;}}});reversegeocoder.reverseGeocode(point);}
function crearViaje(){document.getElementById("lat_salida").value=path[0].lat();document.getElementById("long_salida").value=path[0].lng();document.getElementById("lat_destino").value=path[4].lat();document.getElementById("long_destino").value=path[4].lng();document.getElementById("formul").submit();}
function modificarViaje(){document.getElementById("lat_salida").value=path[0].lat();document.getElementById("long_salida").value=path[0].lng();document.getElementById("lat_destino").value=path[4].lat();document.getElementById("long_destino").value=path[4].lng();document.getElementById("formul").submit();}
function recuperarViaje(){var lat_salida=document.getElementById("lat_salida").value;var long_salida=document.getElementById("long_salida").value;var lat_destino=document.getElementById("lat_destino").value;var long_destino=document.getElementById("long_destino").value;var salida=new GLatLng(lat_salida,long_salida);var destino=new GLatLng(lat_destino,long_destino);doStart(salida);doEnd(destino);directions();}
function recuperarViajeOriginal(){var lat_salida=document.getElementById("lat_salida").value;var long_salida=document.getElementById("long_salida").value;var lat_destino=document.getElementById("lat_destino").value;var long_destino=document.getElementById("long_destino").value;var salida=new GLatLng(lat_salida,long_salida);var destino=new GLatLng(lat_destino,long_destino);doStartOriginal(salida);doEndOriginal(destino);directionsOriginal();}
function recuperarViajeCoincidencia(index){var lat_salida=document.getElementById("lat_salida"+index).value;var long_salida=document.getElementById("long_salida"+index).value;var lat_destino=document.getElementById("lat_destino"+index).value;var long_destino=document.getElementById("long_destino"+index).value;var salida=new GLatLng(lat_salida,long_salida);var destino=new GLatLng(lat_destino,long_destino);doStartCoincidencia(salida,index);doEndCoincidencia(destino,index);directionsCoincidencia(index);}
function recuperarViajeCoincidencia1(){var lat_salida=document.getElementById("lat_salida0").value;var long_salida=document.getElementById("long_salida0").value;var lat_destino=document.getElementById("lat_destino0").value;var long_destino=document.getElementById("long_destino0").value;var salida=new GLatLng(lat_salida,long_salida);var destino=new GLatLng(lat_destino,long_destino);doStartCoincidencia1(salida);doEndCoincidencia1(destino);directionsCoincidencia1();}
function recuperarViajeCoincidencia2(){var lat_salida=document.getElementById("lat_salida1").value;var long_salida=document.getElementById("long_salida1").value;var lat_destino=document.getElementById("lat_destino1").value;var long_destino=document.getElementById("long_destino1").value;var salida=new GLatLng(lat_salida,long_salida);var destino=new GLatLng(lat_destino,long_destino);doStartCoincidencia2(salida);doEndCoincidencia2(destino);directionsCoincidencia2();}
function recuperarViajeCoincidencia3(){var lat_salida=document.getElementById("lat_salida2").value;var long_salida=document.getElementById("long_salida2").value;var lat_destino=document.getElementById("lat_destino2").value;var long_destino=document.getElementById("long_destino2").value;var salida=new GLatLng(lat_salida,long_salida);var destino=new GLatLng(lat_destino,long_destino);doStartCoincidencia3(salida);doEndCoincidencia3(destino);directionsCoincidencia3();}
function recuperarViajeCoincidencia4(){var lat_salida=document.getElementById("lat_salida3").value;var long_salida=document.getElementById("long_salida3").value;var lat_destino=document.getElementById("lat_destino3").value;var long_destino=document.getElementById("long_destino3").value;var salida=new GLatLng(lat_salida,long_salida);var destino=new GLatLng(lat_destino,long_destino);doStartCoincidencia4(salida);doEndCoincidencia4(destino);directionsCoincidencia4();}
function recuperarViajeCoincidencia5(){var lat_salida=document.getElementById("lat_salida4").value;var long_salida=document.getElementById("long_salida4").value;var lat_destino=document.getElementById("lat_destino4").value;var long_destino=document.getElementById("long_destino4").value;var salida=new GLatLng(lat_salida,long_salida);var destino=new GLatLng(lat_destino,long_destino);doStartCoincidencia5(salida);doEndCoincidencia5(destino);directionsCoincidencia5();}
function recuperarMultiplesViajes(nroMapa){var lat_salidaVector="lat_salida"+nroMapa;var long_salidaVector="long_salida"+nroMapa;var lat_destinoVector="lat_destino"+nroMapa;var long_destinoVector="long_destino"+nroMapa;var lat_salida=document.getElementById(lat_salidaVector);var long_salida=document.getElementById(long_salidaVector);var lat_destino=document.getElementById(lat_destinoVector);var long_destino=document.getElementById(long_destinoVector);var salida=new GLatLng(lat_salida.value,long_salida.value);var destino=new GLatLng(lat_destino.value,long_destino.value);doStartSimple(salida);doEndSimple(destino);}
function clearMap(){map.clearOverlays();active[0]=false;addresses[0]="";active[4]=false;addresses[4]="";document.getElementById("dirida").value="";document.getElementById("dirvuelta").value="";document.getElementById("diridahidden").value="";document.getElementById("dirvueltahidden").value="";}
function actRutaAutom(){directions();}
function sumarCantPasaj(){}
function restarCantPasaj(){cant=+document.getElementById("cantpasaj").value;document.getElementById("cantpasaj").value=cant--;pasajeros=pasajeros--;}
function agregarPasajero(){if(pasajeros>=4)alert("Ya ingreso el maximo del 4 pasajeros, modifique o elimine alguno existente");else document.getElementById("pasajero").style.display="block";numP=pasajeros+1;alert(numP);var lat=(path[0].lat()*(4-numP)+path[4].lat()*numP)/4;var lng=(path[0].lng()*(4-numP)+path[4].lng()*numP)/4;var p=new GLatLng(lat,lng);createMarker(p,numP,icon4);path[numP]=p;}
function ajustarDistanciaDuracion(){if(gdir.getDistance()!=null){calcularDistanciaViaje();calcularTiempoViaje();clearInterval(calcth);}}
function calcularDistanciaViaje(){document.getElementById("distotal").value=gdir.getDistance().meters/1000+" Km.";document.getElementById("distotaltexto").value=gdir.getDistance().meters/1000+" Km.";}
function calcularTiempoViaje(){document.getElementById("tiemtotal").value=gdir.getDuration().html;document.getElementById("tiemtotaltexto").value=gdir.getDuration().html;}
function recorridoViaje(){var route=gdir.getRoute(0);var steps=route.getNumSteps();var rec='';for(i=0;i<steps;i++){if(i==0)rec=rec+route.getStep(i).getDescriptionHtml();else rec=rec+'##'+route.getStep(i).getDescriptionHtml();}
document.getElementById("recorrido").value=rec;}
function centrarMapaCiudad(){var cbociudad=document.getElementById("ciudades");var selindex=cbociudad.selectedIndex;var ciudadelegida=cbociudad.options[selindex].value;geo.getLatLng(ciudadelegida,function(point){if(point){map.setCenter(point,8);}
else{var result=geo.getCache().get(ciudadelegida);if(result){var reason="Code "+result.Status.code;if(reasons[result.Status.code]){reason=reasons[result.Status.code]}}else{var reason="";}
alert('Could not find "'+ciudadelegida+'" '+reason);}});}
function place(lat,lng,whichaddress,placeidavuelta){var search=tempaddress[whichaddress];if(placeidavuelta==1){addresses[0]=search;}
if(placeidavuelta==2){addresses[4]=search;}
geo.getLatLng(search,function(point){if(point){if(placeidavuelta==1){doStart(point)}
if(placeidavuelta==2){doEnd(point)}}
else{var result=geo.getCache().get(search);if(result){var reason="Code "+result.Status.code;if(reasons[result.Status.code]){reason=reasons[result.Status.code]}}else{var reason="";}
alert('Could not find "'+search+'" '+reason);}});document.getElementById("message").innerHTML="";}
function showAddress(idavuelta){var search;if(idavuelta==1){if(active[0]){undoStart();}
search=document.getElementById("dirida").value;document.getElementById("diridahidden").value=document.getElementById("dirida").value;addresses[0]=search;placeidavuelta=1;}
if(idavuelta==2){if(active[4]){undoEnd();}
search=document.getElementById("dirvuelta").value;document.getElementById("dirvueltahidden").value=document.getElementById("dirvuelta").value;addresses[4]=search;placeidavuelta=2;}
geo.setBaseCountryCode("br");geo.getLocations(search,function(result){if(result.Status.code==G_GEO_SUCCESS){if(result.Placemark.length>1){document.getElementById("message").innerHTML="Did you mean:";for(var i=0;i<result.Placemark.length;i++){var p=result.Placemark[i].Point.coordinates;document.getElementById("message").innerHTML+="<br>"+(i+1)+": <a href='javascript:place("+p[1]+","+p[0]+","+i+","+idavuelta+")'>"+result.Placemark[i].address+"</a>";tempaddress[i]=result.Placemark[i].address;}}else{geo.getLatLng(search,function(point){if(point){if(idavuelta==1){doStart(point)}
if(idavuelta==2){doEnd(point);}}else{var result=geo.getCache().get(search);if(result){var reason="Code "+result.Status.code;if(reasons[result.Status.code])reason=reasons[result.Status.code];}else{var reason="";}
alert('Could not find "'+search+'" '+reason);}});document.getElementById("message").innerHTML="";}}
else{var reason="Code "+result.Status.code;if(reasons[result.Status.code]){reason=reasons[result.Status.code]}
alert('Could not find "'+search+'" '+reason);}});}
function swapMarkers(i){map.removeOverlay(gmarkers[i]);createMarker(path[i],i,icon2);actRutaAutom();sumarCantPasaj();}
function createMarker(point,i,icon){var marker=new GMarker(point,{draggable:true,icon:icon});gmarkers[i]=marker;GEvent.addListener(marker,"dragend",function(){path[i]=marker.getPoint();if(!active[i]){setTimeout('swapMarkers('+i+')',1000);}
if(i==0){obtenerCalleDrag(path[i],1);document.getElementById("lat_salida").value=path[0].lat();document.getElementById("long_salida").value=path[0].lng();bounds.extend(path[0]);bounds.extend(path[4]);map.setZoom(map.getBoundsZoomLevel(bounds));map.setCenter(bounds.getCenter());}else if(i==4){obtenerCalleDrag(path[i],2);document.getElementById("lat_destino").value=path[4].lat();document.getElementById("long_destino").value=path[4].lng();bounds.extend(path[0]);bounds.extend(path[4]);map.setZoom(map.getBoundsZoomLevel(bounds));map.setCenter(bounds.getCenter());}
addresses[i]="";actRutaAutom();});map.addOverlay(marker);}
function destroyMarker(i){var marker=gmarkers[i];map.removeOverlay(marker);}
function createMarkerSimple(point,i,icon){var marker=new GMarker(point,{draggable:false,icon:icon});gmarkers[i]=marker;map.addOverlay(marker);}
function createMarkerCoincidencia(point,i,icon){var marker=new GMarker(point,{draggable:false,icon:icon});map.addOverlay(marker);}
function cleanDirIda(){document.getElementById("dirida").value="";}
function cleanDirVuelta(){document.getElementById("dirvuelta").value="";}
function doStart(point){createMarker(point,0,icon1);path[0]=point;active[0]=true;document.getElementById("lat_salida").value=path[0].lat();document.getElementById("long_salida").value=path[0].lng();map.setCenter(point,14);if(active[4])actRutaAutom();}
function undoStart(){if(active[0]){destroyMarker(0);gmarkers[0]=""
active[0]=false;addresses[0]="";path[0]="";document.getElementById("lat_salida").value="";document.getElementById("long_salida").value="";}}
function doEnd(point){createMarker(point,4,icon3);path[4]=point;active[4]=true;document.getElementById("lat_destino").value=path[4].lat();document.getElementById("long_destino").value=path[4].lng();bounds.extend(path[0]);bounds.extend(path[4]);map.setZoom(map.getBoundsZoomLevel(bounds));map.setCenter(bounds.getCenter());if(active[0])actRutaAutom();}
function undoEnd(){if(active[4]){destroyMarker(4);gmarkers[4]=""
active[4]=false;addresses[4]="";path[4]="";document.getElementById("lat_destino").value="";document.getElementById("long_destino").value="";}}
function doStartOriginal(point){createMarkerSimple(point,0,icon1);path[0]=point;map.setCenter(point,14);sumarCantPasaj();}
function doStartCoincidencia(point,index){createMarkerCoincidencia(point,0,iconcoincidencia);pathStartCoincidencia[index]=point;map.setCenter(point,14);}
function doStartCoincidencia1(point){createMarkerCoincidencia(point,0,iconcoincidencia1);pathStartCoincidencia1=point;map.setCenter(point,14);}
function doStartCoincidencia2(point){createMarkerCoincidencia(point,0,iconcoincidencia2);pathStartCoincidencia2=point;map.setCenter(point,14);}
function doStartCoincidencia3(point){createMarkerCoincidencia(point,0,iconcoincidencia3);pathStartCoincidencia3=point;map.setCenter(point,14);}
function doStartCoincidencia4(point){createMarkerCoincidencia(point,0,iconcoincidencia4);pathStartCoincidencia4=point;map.setCenter(point,14);}
function doStartCoincidencia5(point){createMarkerCoincidencia(point,0,iconcoincidencia5);pathStartCoincidencia5=point;map.setCenter(point,14);}
function doEndOriginal(point){createMarkerSimple(point,4,icon3);path[4]=point;bounds.extend(path[0]);bounds.extend(path[4]);map.setZoom(map.getBoundsZoomLevel(bounds));map.setCenter(bounds.getCenter());}
function doEndCoincidencia(point,index){createMarkerCoincidencia(point,4,iconcoincidencia);pathEndCoincidencia[index]=point;bounds.extend(pathStartCoincidencia[index]);bounds.extend(pathEndCoincidencia[index]);map.setZoom(map.getBoundsZoomLevel(bounds));map.setCenter(bounds.getCenter());}
function doEndCoincidencia1(point){createMarkerCoincidencia(point,4,iconcoincidencia1);pathEndCoincidencia1=point;bounds.extend(pathStartCoincidencia1);bounds.extend(pathEndCoincidencia1);map.setZoom(map.getBoundsZoomLevel(bounds));map.setCenter(bounds.getCenter());}
function doEndCoincidencia2(point){createMarkerCoincidencia(point,4,iconcoincidencia2);pathEndCoincidencia2=point;bounds.extend(pathStartCoincidencia2);bounds.extend(pathEndCoincidencia2);map.setZoom(map.getBoundsZoomLevel(bounds));map.setCenter(bounds.getCenter());}
function doEndCoincidencia3(point){createMarkerCoincidencia(point,4,iconcoincidencia3);pathEndCoincidencia3=point;bounds.extend(pathStartCoincidencia3);bounds.extend(pathEndCoincidencia3);map.setZoom(map.getBoundsZoomLevel(bounds));map.setCenter(bounds.getCenter());}
function doEndCoincidencia4(point){createMarkerCoincidencia(point,4,iconcoincidencia4);pathEndCoincidencia4=point;bounds.extend(pathStartCoincidencia4);bounds.extend(pathEndCoincidencia4);map.setZoom(map.getBoundsZoomLevel(bounds));map.setCenter(bounds.getCenter());}
function doEndCoincidencia5(point){createMarkerCoincidencia(point,4,iconcoincidencia5);pathEndCoincidencia5=point;bounds.extend(pathStartCoincidencia5);bounds.extend(pathEndCoincidencia5);map.setZoom(map.getBoundsZoomLevel(bounds));map.setCenter(bounds.getCenter());}
function doIntermediate(point){createMarker(point,pasajeros+1,icon2);path[pasajeros+1]=point;sumarCantPasaj();}
function directions(){if(addresses[0]){var a=addresses[0]+"@"+path[0].toUrlValue(6);}
else{var a=path[0].toUrlValue(6)}
if(addresses[4]){var b=addresses[4]+"@"+path[4].toUrlValue(6)}
else{var b=path[4].toUrlValue(6)}
for(var i=3;i>0;i--){if(active[i]){b=path[i].toUrlValue(6)+" to: "+b;}}
var a="from: "+a+" to: "+b;gdir.load(a,{getPolyline:true});calcth=setInterval("ajustarDistanciaDuracion()",1000);}
function directionsOriginal(){if(addresses[0]){var a=addresses[0]+"@"+path[0].toUrlValue(6);}
else{var a=path[0].toUrlValue(6)}
if(addresses[4]){var b=addresses[4]+"@"+path[4].toUrlValue(6)}
else{var b=path[4].toUrlValue(6)}
for(var i=3;i>0;i--){if(active[i]){b=path[i].toUrlValue(6)+" to: "+b;}}
var a="from: "+a+" to: "+b;gdir.load(a,{getPolyline:true});}
function directionsCoincidencia(index){var a=pathStartCoincidencia[index].toUrlValue(6);var b=pathEndCoincidencia[index].toUrlValue(6);var a="from: "+a+" to: "+b;gdir2.load(a,{getPolyline:true});}
function directionsCoincidencia1(){var a=pathStartCoincidencia1.toUrlValue(6);var b=pathEndCoincidencia1.toUrlValue(6);var a="from: "+a+" to: "+b;gdir1.load(a,{getPolyline:true});}
function directionsCoincidencia2(){var a=pathStartCoincidencia2.toUrlValue(6);var b=pathEndCoincidencia2.toUrlValue(6);var a="from: "+a+" to: "+b;gdir2.load(a,{getPolyline:true});}
function directionsCoincidencia3(){var a=pathStartCoincidencia3.toUrlValue(6);var b=pathEndCoincidencia3.toUrlValue(6);var a="from: "+a+" to: "+b;gdir3.load(a,{getPolyline:true});}
function directionsCoincidencia4(){var a=pathStartCoincidencia4.toUrlValue(6);var b=pathEndCoincidencia4.toUrlValue(6);var a="from: "+a+" to: "+b;gdir4.load(a,{getPolyline:true});}
function directionsCoincidencia5(){var a=pathStartCoincidencia5.toUrlValue(6);var b=pathEndCoincidencia5.toUrlValue(6);var a="from: "+a+" to: "+b;gdir5.load(a,{getPolyline:true});}
function positionOverview(x,y){var omap=document.getElementById("map_overview");omap.style.left=x+"px";omap.style.top=y+"px";omap.firstChild.style.border="1px solid gray";omap.firstChild.firstChild.style.left="4px";omap.firstChild.firstChild.style.top="4px";omap.firstChild.firstChild.style.width="190px";omap.firstChild.firstChild.style.height="190px";}
function centrarMapa(){if(document.getElementById("localemap").value=="pt_BR"){map.setCenter(new GLatLng(-18.271086109608863,-46.7138671875),5);}else if(document.getElementById("localemap").value=="es_AR"){map.setCenter(new GLatLng(-35.396799,-65.183085),5);}}
function initial_load(){if(GBrowserIsCompatible()){map=new GMap(document.getElementById("map"));map.addControl(new GLargeMapControl());map.addControl(new GMapTypeControl());centrarMapa();bounds=new GLatLngBounds();pasajeros=0;geo=new GClientGeocoder(new GGeocodeCache());tempaddress=[];var reasons=[];reasons[G_GEO_SUCCESS]="Success";reasons[G_GEO_MISSING_ADDRESS]="Missing Address: The address was either missing or had no value.";reasons[G_GEO_UNKNOWN_ADDRESS]="Unknown Address:  No corresponding geographic location could be found for the specified address.";reasons[G_GEO_UNAVAILABLE_ADDRESS]="Unavailable Address:  The geocode for the given address cannot be returned due to legal or contractual reasons.";reasons[G_GEO_BAD_KEY]="Bad Key: The API key is either invalid or does not match the domain for which it was given";reasons[G_GEO_TOO_MANY_QUERIES]="Too Many Queries: The daily geocoding quota for this site has been exceeded.";reasons[G_GEO_SERVER_ERROR]="Server error: The geocoding request could not be successfully processed.";reasons[G_GEO_BAD_REQUEST]="A directions request could not be successfully parsed.";reasons[G_GEO_MISSING_QUERY]="No query was specified in the input.";reasons[G_GEO_UNKNOWN_DIRECTIONS]="The GDirections object could not compute directions between the points.";var baseIcon=new GIcon(G_DEFAULT_ICON);baseIcon.iconSize=new GSize(24,38);icon1=G_START_ICON;icon2=G_PAUSE_ICON;icon3=G_END_ICON;icon4=new GIcon(baseIcon,"http://labs.google.com/ridefinder/images/mm_20_white.png");icon4.shadow="http://labs.google.com/ridefinder/images/mm_20_shadow.png";icon4.iconSize=new GSize(12,20);icon4.shadowSize=new GSize(22,20);icon4.iconAnchor=new GPoint(6,20);icon4.infoWindowAnchor=new GPoint(5,1);path=[];active=[false,false,false,false,false];gmarkers=[];addresses=[];idamarcada="no";vueltamarcada="no";GEvent.addListener(map,"click",function(overlay,point){if(point){if(!active[0]){obtenerCalle(point,1);doStart(point);}
else if(!active[4]){doEnd(point);obtenerCalle(point,2);}}});gdir=new GDirections(null,null);GEvent.addListener(gdir,"error",function(){var code=gdir.getStatus().code;var reason="Code "+code;if(reasons[code]){reason="Code "+code+" : "+reasons[code]}
alert("Failed to obtain directions, "+reason);});var poly;GEvent.addListener(gdir,"load",function(){if(poly)map.removeOverlay(poly);poly=gdir.getPolyline();map.addOverlay(poly);});}
else{alert("Sorry, the Google Maps API is not compatible with this browser");}}
function initial_modify_load(){if(GBrowserIsCompatible()){map=new GMap(document.getElementById("map"));map.addControl(new GLargeMapControl());map.addControl(new GMapTypeControl());map.setCenter(new GLatLng(-18.271086109608863,-46.7138671875),5);bounds=new GLatLngBounds();pasajeros=0;geo=new GClientGeocoder(new GGeocodeCache());tempaddress=[];var reasons=[];reasons[G_GEO_SUCCESS]="Success";reasons[G_GEO_MISSING_ADDRESS]="Missing Address: The address was either missing or had no value.";reasons[G_GEO_UNKNOWN_ADDRESS]="Unknown Address:  No corresponding geographic location could be found for the specified address.";reasons[G_GEO_UNAVAILABLE_ADDRESS]="Unavailable Address:  The geocode for the given address cannot be returned due to legal or contractual reasons.";reasons[G_GEO_BAD_KEY]="Bad Key: The API key is either invalid or does not match the domain for which it was given";reasons[G_GEO_TOO_MANY_QUERIES]="Too Many Queries: The daily geocoding quota for this site has been exceeded.";reasons[G_GEO_SERVER_ERROR]="Server error: The geocoding request could not be successfully processed.";reasons[G_GEO_BAD_REQUEST]="A directions request could not be successfully parsed.";reasons[G_GEO_MISSING_QUERY]="No query was specified in the input.";reasons[G_GEO_UNKNOWN_DIRECTIONS]="The GDirections object could not compute directions between the points.";var baseIcon=new GIcon(G_DEFAULT_ICON);baseIcon.iconSize=new GSize(24,38);icon1=G_START_ICON;icon2=G_PAUSE_ICON;icon3=G_END_ICON;icon4=new GIcon(baseIcon,"http://labs.google.com/ridefinder/images/mm_20_white.png");icon4.shadow="http://labs.google.com/ridefinder/images/mm_20_shadow.png";icon4.iconSize=new GSize(12,20);icon4.shadowSize=new GSize(22,20);icon4.iconAnchor=new GPoint(6,20);icon4.infoWindowAnchor=new GPoint(5,1);path=[];active=[false,false,false,false,false];gmarkers=[];addresses=[];GEvent.addListener(map,"click",function(overlay,point){if(point){if(!active[0]){doStart(point);obtenerCalle(point,1);}
else if(!active[4]){doEnd(point);obtenerCalle(point,2);}}});gdir=new GDirections(null,null);GEvent.addListener(gdir,"error",function(){var code=gdir.getStatus().code;var reason="Code "+code;if(reasons[code]){reason="Code "+code+" : "+reasons[code]}
alert("Failed to obtain directions, "+reason);});var poly;GEvent.addListener(gdir,"load",function(){if(poly)map.removeOverlay(poly);poly=gdir.getPolyline();map.addOverlay(poly);});var reversegeocoder=new GReverseGeocoder(map);GEvent.addListener(reversegeocoder,"load",function(placemark){var reverseaddress=reversegeocoder.getPlacemarkProperty(placemark,"ThoroughfareName");});recuperarViaje();}
else{alert("Sorry, the Google Maps API is not compatible with this browser");}}
function initial_simple_load(){if(GBrowserIsCompatible()){map=new GMap(document.getElementById("map"));map.addControl(new GLargeMapControl());map.addControl(new GMapTypeControl());map.setCenter(new GLatLng(-18.271086109608863,-46.7138671875),5);bounds=new GLatLngBounds();pasajeros=0;geo=new GClientGeocoder(new GGeocodeCache());tempaddress=[];var reasons=[];reasons[G_GEO_SUCCESS]="Success";reasons[G_GEO_MISSING_ADDRESS]="Missing Address: The address was either missing or had no value.";reasons[G_GEO_UNKNOWN_ADDRESS]="Unknown Address:  No corresponding geographic location could be found for the specified address.";reasons[G_GEO_UNAVAILABLE_ADDRESS]="Unavailable Address:  The geocode for the given address cannot be returned due to legal or contractual reasons.";reasons[G_GEO_BAD_KEY]="Bad Key: The API key is either invalid or does not match the domain for which it was given";reasons[G_GEO_TOO_MANY_QUERIES]="Too Many Queries: The daily geocoding quota for this site has been exceeded.";reasons[G_GEO_SERVER_ERROR]="Server error: The geocoding request could not be successfully processed.";reasons[G_GEO_BAD_REQUEST]="A directions request could not be successfully parsed.";reasons[G_GEO_MISSING_QUERY]="No query was specified in the input.";reasons[G_GEO_UNKNOWN_DIRECTIONS]="The GDirections object could not compute directions between the points.";var baseIcon=new GIcon(G_DEFAULT_ICON);baseIcon.iconSize=new GSize(24,38);icon1=G_START_ICON
icon2=G_PAUSE_ICON;icon3=G_END_ICON;path=[];active=[false,false,false,false,false];gmarkers=[];addresses=[];gdir=new GDirections(null,null);var poly;GEvent.addListener(gdir,"load",function(){if(poly)map.removeOverlay(poly);poly=gdir.getPolyline();map.addOverlay(poly);});recuperarViajeOriginal();iconcoincidencia=new GIcon(baseIcon,"http://www.viapool.com/public/images/globitos/coincidencia.png");var totalCoincidencias=document.getElementById("totalcoincidencias").value;for(i=1;i<=totalCoincidencias;i++){if(i==1){iconcoincidencia1=new GIcon(baseIcon,"http://www.viapool.com/public/images/globitos/coincidencia1.png");iconcoincidencia1.iconSize=new GSize(20,33);var polyCoincidencia1;gdir1=new GDirections(null,null);GEvent.addListener(gdir1,"load",function(){polyCoincidencia1=gdir1.getPolyline();map.addOverlay(polyCoincidencia1);polyCoincidencia1.setStrokeStyle({color:"#000000"});});recuperarViajeCoincidencia1();}else if(i==2){iconcoincidencia2=new GIcon(baseIcon,"http://www.viapool.com/public/images/globitos/coincidencia2.png");iconcoincidencia2.iconSize=new GSize(20,33);var polyCoincidencia2;gdir2=new GDirections(null,null);GEvent.addListener(gdir2,"load",function(){polyCoincidencia2=gdir2.getPolyline();map.addOverlay(polyCoincidencia2);polyCoincidencia2.setStrokeStyle({color:"#000000"});});recuperarViajeCoincidencia2();}else if(i==3){iconcoincidencia3=new GIcon(baseIcon,"http://www.viapool.com/public/images/globitos/coincidencia3.png");iconcoincidencia3.iconSize=new GSize(20,33);var polyCoincidencia3;gdir3=new GDirections(null,null);GEvent.addListener(gdir3,"load",function(){polyCoincidencia3=gdir3.getPolyline();map.addOverlay(polyCoincidencia3);polyCoincidencia3.setStrokeStyle({color:"#000000"});});recuperarViajeCoincidencia3();}else if(i==4){iconcoincidencia4=new GIcon(baseIcon,"http://www.viapool.com/public/images/globitos/coincidencia4.png");iconcoincidencia4.iconSize=new GSize(20,33);var polyCoincidencia4;gdir4=new GDirections(null,null);GEvent.addListener(gdir4,"load",function(){polyCoincidencia4=gdir4.getPolyline();map.addOverlay(polyCoincidencia4);polyCoincidencia4.setStrokeStyle({color:"#000000"});});recuperarViajeCoincidencia4();}else if(i==5){iconcoincidencia5=new GIcon(baseIcon,"http://www.viapool.com/public/images/globitos/coincidencia5.png");iconcoincidencia5.iconSize=new GSize(20,33);var polyCoincidencia5;gdir5=new GDirections(null,null);GEvent.addListener(gdir5,"load",function(){polyCoincidencia5=gdir5.getPolyline();map.addOverlay(polyCoincidencia5);polyCoincidencia5.setStrokeStyle({color:"#000000"});});recuperarViajeCoincidencia5();}}}
else{alert("Sorry, the Google Maps API is not compatible with this browser");}}
function initial_simple_load_varios(){if(GBrowserIsCompatible()){map=new GMap(document.getElementById("map"));map.addControl(new GLargeMapControl());map.addControl(new GMapTypeControl());map.setCenter(new GLatLng(-18.271086109608863,-46.7138671875),5);bounds=new GLatLngBounds();geo=new GClientGeocoder(new GGeocodeCache());tempaddress=[];var reasons=[];reasons[G_GEO_SUCCESS]="Success";reasons[G_GEO_MISSING_ADDRESS]="Missing Address: The address was either missing or had no value.";reasons[G_GEO_UNKNOWN_ADDRESS]="Unknown Address:  No corresponding geographic location could be found for the specified address.";reasons[G_GEO_UNAVAILABLE_ADDRESS]="Unavailable Address:  The geocode for the given address cannot be returned due to legal or contractual reasons.";reasons[G_GEO_BAD_KEY]="Bad Key: The API key is either invalid or does not match the domain for which it was given";reasons[G_GEO_TOO_MANY_QUERIES]="Too Many Queries: The daily geocoding quota for this site has been exceeded.";reasons[G_GEO_SERVER_ERROR]="Server error: The geocoding request could not be successfully processed.";reasons[G_GEO_BAD_REQUEST]="A directions request could not be successfully parsed.";reasons[G_GEO_MISSING_QUERY]="No query was specified in the input.";reasons[G_GEO_UNKNOWN_DIRECTIONS]="The GDirections object could not compute directions between the points.";var baseIcon=new GIcon(G_DEFAULT_ICON);baseIcon.iconSize=new GSize(20,33);var totalCoincidencias=document.getElementById("totalcoincidencias").value;for(i=1;i<=totalCoincidencias;i++){if(i==1){iconcoincidencia1=new GIcon(baseIcon,"http://www.viapool.com/public/images/globitos/coincidencia1.png");var polyCoincidencia1;gdir1=new GDirections(null,null);GEvent.addListener(gdir1,"load",function(){polyCoincidencia1=gdir1.getPolyline();map.addOverlay(polyCoincidencia1);polyCoincidencia1.setStrokeStyle({color:"#000000"});});recuperarViajeCoincidencia1();}else if(i==2){iconcoincidencia2=new GIcon(baseIcon,"http://www.viapool.com/public/images/globitos/coincidencia2.png");var polyCoincidencia2;gdir2=new GDirections(null,null);GEvent.addListener(gdir2,"load",function(){polyCoincidencia2=gdir2.getPolyline();map.addOverlay(polyCoincidencia2);polyCoincidencia2.setStrokeStyle({color:"#000000"});});recuperarViajeCoincidencia2();}else if(i==3){iconcoincidencia3=new GIcon(baseIcon,"http://www.viapool.com/public/images/globitos/coincidencia3.png");var polyCoincidencia3;gdir3=new GDirections(null,null);GEvent.addListener(gdir3,"load",function(){polyCoincidencia3=gdir3.getPolyline();map.addOverlay(polyCoincidencia3);polyCoincidencia3.setStrokeStyle({color:"#000000"});});recuperarViajeCoincidencia3();}else if(i==4){iconcoincidencia4=new GIcon(baseIcon,"http://www.viapool.com/public/images/globitos/coincidencia4.png");var polyCoincidencia4;gdir4=new GDirections(null,null);GEvent.addListener(gdir4,"load",function(){polyCoincidencia4=gdir4.getPolyline();map.addOverlay(polyCoincidencia4);polyCoincidencia4.setStrokeStyle({color:"#000000"});});recuperarViajeCoincidencia4();}else if(i==5){iconcoincidencia5=new GIcon(baseIcon,"http://www.viapool.com/public/images/globitos/coincidencia5.png");var polyCoincidencia5;gdir5=new GDirections(null,null);GEvent.addListener(gdir5,"load",function(){polyCoincidencia5=gdir5.getPolyline();map.addOverlay(polyCoincidencia5);polyCoincidencia5.setStrokeStyle({color:"#000000"});});recuperarViajeCoincidencia5();}}}
else{alert("Sorry, the Google Maps API is not compatible with this browser");}}
function initial_simple_load_multiple(cantmapas){if(GBrowserIsCompatible()){for(i=0;i<cantmapas;i++){var mapVector="map"+i;var pathVector="path"+i;map=new GMap(document.getElementById(mapVector));map.addControl(new GLargeMapControl());map.addControl(new GMapTypeControl());map.setCenter(new GLatLng(-18.271086109608863,-46.7138671875),5);bounds=new GLatLngBounds();pasajeros=0;geo=new GClientGeocoder(new GGeocodeCache());tempaddress=[];var reasons=[];reasons[G_GEO_SUCCESS]="Success";reasons[G_GEO_MISSING_ADDRESS]="Missing Address: The address was either missing or had no value.";reasons[G_GEO_UNKNOWN_ADDRESS]="Unknown Address:  No corresponding geographic location could be found for the specified address.";reasons[G_GEO_UNAVAILABLE_ADDRESS]="Unavailable Address:  The geocode for the given address cannot be returned due to legal or contractual reasons.";reasons[G_GEO_BAD_KEY]="Bad Key: The API key is either invalid or does not match the domain for which it was given";reasons[G_GEO_TOO_MANY_QUERIES]="Too Many Queries: The daily geocoding quota for this site has been exceeded.";reasons[G_GEO_SERVER_ERROR]="Server error: The geocoding request could not be successfully processed.";reasons[G_GEO_BAD_REQUEST]="A directions request could not be successfully parsed.";reasons[G_GEO_MISSING_QUERY]="No query was specified in the input.";reasons[G_GEO_UNKNOWN_DIRECTIONS]="The GDirections object could not compute directions between the points.";var baseIcon=new GIcon(G_DEFAULT_ICON);baseIcon.iconSize=new GSize(24,38);icon1=G_START_ICON;icon2=G_PAUSE_ICON;icon3=G_END_ICON;icon4=new GIcon(baseIcon,"http://labs.google.com/ridefinder/images/mm_20_white.png");icon4.shadow="http://labs.google.com/ridefinder/images/mm_20_shadow.png";icon4.iconSize=new GSize(12,20);icon4.shadowSize=new GSize(22,20);icon4.iconAnchor=new GPoint(6,20);icon4.infoWindowAnchor=new GPoint(5,1);path=[];active=[false,false,false,false,false];gmarkers=[];addresses=[];recuperarMultiplesViajes(i);}}
else{alert("Sorry, the Google Maps API is not compatible with this browser");}}