var a,MapIconMaker={};
MapIconMaker.createMarkerIcon=function(c){var b=c.width||32,d=c.height||32,e=c.primaryColor||"#ff0000",f=c.strokeColor||"#000000",g=c.cornerColor||"#ffffff",k="http://chart.apis.google.com/chart?cht=mm&chs="+b+"x"+d+"&chco="+g.replace("#","")+","+e.replace("#","")+","+f.replace("#","")+"&ext=.png";c=new GIcon(G_DEFAULT_ICON);c.image=k;c.iconSize=new GSize(b,d);c.shadowSize=new GSize(Math.floor(b*1.6),d);c.iconAnchor=new GPoint(b/2,d);c.infoWindowAnchor=new GPoint(b/2,Math.floor(d/12));c.printImage=
k+"&chof=gif";c.mozPrintImage=k+"&chf=bg,s,ECECD8&chof=gif";k="http://chart.apis.google.com/chart?cht=mm&chs="+b+"x"+d+"&chco="+g.replace("#","")+","+e.replace("#","")+","+f.replace("#","");c.transparent=k+"&chf=a,s,ffffff11&ext=.png";c.imageMap=[b/2,d,0.4375*b,0.625*d,0.3125*b,0.4375*d,0.21875*b,0.3125*d,0.3125*b,0.125*d,0.5*b,0,0.6875*b,0.125*d,0.78125*b,0.3125*d,0.6875*b,0.4375*d,0.5625*b,0.625*d];for(b=0;b<c.imageMap.length;b++)c.imageMap[b]=parseInt(c.imageMap[b]);return c};
function LabeledMarker(c,b){this.latlng_=c;this.opts_=b;this.labelText_=b.labelText||"";this.labelClass_=b.labelClass||"LabeledMarker_markerLabel";this.labelOffset_=b.labelOffset||new GSize(0,0);this.clickable_=b.clickable||true;this.title_=b.title||"";this.labelVisibility_=true;if(b.draggable)b.draggable=false;GMarker.apply(this,arguments)}LabeledMarker.prototype=new GMarker(new GLatLng(0,0));a=LabeledMarker.prototype;
a.initialize=function(c){GMarker.prototype.initialize.apply(this,arguments);this.map_=c;this.div_=document.createElement("div");this.div_.className=this.labelClass_;this.div_.innerHTML=this.labelText_;this.div_.style.position="absolute";this.div_.style.cursor="pointer";this.div_.title=this.title_;c.getPane(G_MAP_MARKER_PANE).appendChild(this.div_);if(this.clickable_){function b(g,k){return function(){GEvent.trigger(g,k)}}for(var d=["click","dblclick","mousedown","mouseup","mouseover","mouseout"],
e=0;e<d.length;e++){var f=d[e];GEvent.addDomListener(this.div_,f,b(this,f))}}};a.redraw=function(){GMarker.prototype.redraw.apply(this,arguments);this.redrawLabel_()};a.redrawLabel_=function(){var c=this.map_.fromLatLngToDivPixel(this.latlng_),b=GOverlay.getZIndex(this.latlng_.lat());this.div_.style.left=c.x+this.labelOffset_.width+"px";this.div_.style.top=c.y+this.labelOffset_.height+"px";this.div_.style.zIndex=b};
a.remove=function(){GEvent.clearInstanceListeners(this.div_);if(this.div_.outerHTML)this.div_.outerHTML="";this.div_.parentNode&&this.div_.parentNode.removeChild(this.div_);this.div_=null;GMarker.prototype.remove.apply(this,arguments)};a.copy=function(){return new LabeledMarker(this.latlng_,this.opts_)};a.show=function(){GMarker.prototype.show.apply(this,arguments);this.labelVisibility_?this.showLabel():this.hideLabel()};a.hide=function(){GMarker.prototype.hide.apply(this,arguments);this.hideLabel()};
a.setLatLng=function(c){this.latlng_=c;GMarker.prototype.setLatLng.apply(this,arguments);this.redrawLabel_()};a.setLabelVisibility=function(c){this.labelVisibility_=c;this.isHidden()||(this.labelVisibility_?this.showLabel():this.hideLabel())};a.getLabelVisibility=function(){return this.labelVisibility_};a.hideLabel=function(){this.div_.style.visibility="hidden"};a.showLabel=function(){this.div_.style.visibility="visible"};
function parseGeocode(c){if(!c||c.Status.code==602)alert("Didn't recognize that location");else if(!(!c||c.Status.code!=200))if(c.Placemark[0].AddressDetails.Accuracy==9){reverseLatLong=new google.maps.LatLng(c.Placemark[0].Point.coordinates[1],c.Placemark[0].Point.coordinates[0]);geocoder.getLocations(reverseLatLong,function(f){if(f.Status.code!=200)alert("reverse geocoder failed to find an address for "+latlng.toUrlValue());else{address=f.Placemark[0];geocoder.getLocations(address.address,parseGeocode)}})}else{var b=
marker=point=place="",d="",e="";latlong=country=zip=streetLine=city=county=state="";place=c.Placemark[0];if(b=place.AddressDetails.Country.AdministrativeArea){state=b.AdministrativeAreaName;if(d=b.SubAdministrativeArea){county=d.SubAdministrativeAreaName;if(e=d.Locality){city=e.LocalityName;if(e.Thoroughfare)streetLine=e.Thoroughfare.ThoroughfareName;if(e.PostalCode)zip=e.PostalCode.PostalCodeNumber}else{if(d.Thoroughfare)streetLine=d.Thoroughfare.ThoroughfareName;if(d.PostalCode)zip=d.PostalCode.PostalCodeNumber}}else if(e=
b.Locality){city=e.LocalityName;if(e.Thoroughfare)streetLine=e.Thoroughfare.ThoroughfareName;if(e.PostalCode)zip=e.PostalCode.PostalCodeNumber}else{if(b.Thoroughfare)streetLine=b.Thoroughfare.ThoroughfareName;if(b.PostalCode)zip=b.PostalCode.PostalCodeNumber}}if(city==""&&typeof b!="undefined")if(typeof b.AddressLine!="undefined")city=String(b.AddressLine);if(typeof city=="undefined"){addy=place.address;city=addy.split(",",1)}placeName=place.address;lat=place.Point.coordinates[1];lng=place.Point.coordinates[0];
latlong=lat+","+lng;point=new google.maps.LatLng(lat,lng);country=place.AddressDetails.Country.CountryNameCode;geoResult={lat:lat,lng:lng,coor:latlong,place:placeName,street_address:streetLine,city:city,state:state,zip_code:zip,county:county,country:country};postGeoSuccess()}}
function multiGeocode(c,b){this.locations=c;this.callback=function(){alert("tripping out, use the talkback")};multiArray=typeof c=="object"&&c instanceof Array?c:arguments;geoString="";geoResults=[];postGeoSuccess=function(){geoResults[geoResults.length]=geoResult;if(geoResults.length<multiArray.length)geocoder.getLocations(multiArray[geoResults.length],parseGeocode);else{for(i=0;i<geoResults.length;i++){var d=jQuery.param(geoResults[i]).replace(/=/g,"[]=");geoString+="&"+d}b(geoResults)}};geocoder.getLocations(multiArray[0],
parseGeocode)}
function updateRidePosting(){if($("updateRideOrigin").value)rideLocations=$("updateRideDest").value?[$("updateRideOrigin").value,$("updateRideDest").value]:[$("updateRideOrigin").value];else{alert("You must enter a start location.");return false}new multiGeocode(rideLocations,function(c){x=0;c.each(function(b){if(x==0){$("placeFrom").value=b.place;$("cityFrom").value=b.city;$("stateFrom").value=b.state;$("coorFrom").value=b.coor;$("countryFrom").value=b.country}else{$("placeTo").value=b.place;$("cityTo").value=
b.city;$("stateTo").value=b.state;$("coorTo").value=b.coor;$("countryTo").value=b.country}x++});if(x==1){$("placeTo").value="";$("cityTo").value="";$("stateTo").value="";$("coorTo").value="";$("countryTo").value=""}$("rideConfirmDetails").innerHTML="Post your ride from <strong>"+$("placeFrom").value+"</strong> to <strong>"+$("placeTo").value+"</strong>"})}
function mainSearch(c){toMark=c.search(/ to /i);if(toMark!=-1||tripUsername==""){fromPlace=c.slice(0,toMark);toPlace=c.slice(toMark+4);tripUsername==""&&toMark==-1?travel(fromPlace):travel(fromPlace,toPlace)}else $("origin").value?travel("current",c):updateLocation(c)}
function talkback(){tb_div=document.createElement("div");tb_div.setAttribute("title","talkback");tb_div.innerHTML="loading...";jQuery(tb_div).dialog({bgiframe:true,height:430,width:500,close:function(){tb_div.innerHTML=""},modal:true});new Ajax.Updater(tb_div,"/talkBackForm",{evalScripts:true})}
function post_new_ride(){jQuery(".date-pick").datepicker({dateFormat:"yy-mm-dd",minDate:null,maxDate:0,showOn:"button",buttonImage:"/images/calendar.png",buttonImageOnly:true,buttonText:"choose date"});jQuery("#start_arrival_date_early").datepicker("option",{onClose:function(c,b){jQuery("#start_arrival_date_late").datepicker("option",{minDate:new Date(c)});jQuery("#start_d_date_early").datepicker("option",{minDate:new Date(c),maxDate:null});jQuery("#start_d_date_late").datepicker("option",{minDate:new Date(c),
maxDate:null})}});jQuery("#start_arrival_date_late").datepicker("option",{onClose:function(c,b){jQuery("#start_arrival_date_early").datepicker("option",{maxDate:new Date(c)})}});jQuery("#start_d_date_early").datepicker("option",{minDate:0,maxDate:null,onClose:function(c,b){jQuery("#start_d_date_late").datepicker("option",{minDate:new Date(c)});jQuery("#end_arrival_date_early").datepicker("option",{minDate:new Date(c)});jQuery("end_arrival_date_early").value=$("start_d_date_early").value}});jQuery("#start_d_date_late").datepicker("option",
{minDate:0,maxDate:null,onClose:function(c,b){jQuery("#start_d_date_early").datepicker("option",{maxDate:new Date(c)})}});jQuery("#end_arrival_date_early").datepicker("option",{minDate:0,maxDate:null,onClose:function(c,b){jQuery("#end_arrival_date_late").datepicker("option",{minDate:new Date(c)})}});jQuery("#end_arrival_date_late").datepicker("option",{minDate:0,maxDate:null,onClose:function(c,b){jQuery("#end_arrival_date_early").datepicker("option",{maxDate:new Date(c)})}});jQuery("#here_yes").bind("click",
function(c){jQuery("#start_arrival_date_early").datepicker("option",{minDate:null,maxDate:0});jQuery("#start_arrival_date_late").datepicker("option",{minDate:null,maxDate:0});jQuery("#start_d_date_early").datepicker("option",{minDate:null,maxDate:null});jQuery("#start_d_date_late").datepicker("option",{minDate:null,maxDate:null})});jQuery("#not_here").bind("click",function(c){jQuery("#start_arrival_date_early").datepicker("option",{minDate:0,maxDate:null});jQuery("#start_arrival_date_early").value=
"";jQuery("#start_arrival_date_late").datepicker("option",{minDate:0,maxDate:null});jQuery("#start_d_date_early").datepicker("option",{minDate:0,maxDate:null});jQuery("#start_d_date_late").datepicker("option",{minDate:0,maxDate:null})})}function in_array(c,b){for(i=0;i<b.length;i++)if(b[i]==c)return true;return false}
function updateLocation(c){mainTabs("homeLink","home");postGeoSuccess=function(){locationArr=null;locationArr=[];in_future=false;jQuery.get("locations_xml?username="+tripUsername,{},function(b){var d=0,e=place.address;jQuery("location",b).each(function(g){locationArr[d]={place:jQuery(this).find("place").text(),id:jQuery(this).find("id").text(),number:jQuery(this).find("number").text(),type:jQuery(this).find("type").text(),mpg:jQuery(this).find("mpg").text()};if(locationArr[d].place==e&&in_future==
false){in_future=true;future_arr_key=d}d+=1});if(in_future==true)edit_location_dialog(locationArr[future_arr_key].number,"arrived");else{$("statusDiv").style.display="none";$("dash_container").hide();jQuery("#map").fadeIn("slow");jQuery("#profileTabs").fadeOut("fast");$("content").style.width="500px";typeof map=="undefined"&&oonLoad();sizeMap();updateMarker=new google.maps.Marker(point);map.addOverlay(updateMarker);updateMarker.openInfoWindowHtml("<strong>"+place.address+"</strong>");jQuery(".date-pick").datepicker({dateFormat:"yy-mm-dd",
minDate:null,maxDate:0,showOn:"button",buttonImage:"/images/calendar.png",buttonImageOnly:true,buttonText:"choose date"});jQuery("#start_date").datepicker("option",{onClose:function(g,k){jQuery("#end_date").datepicker("option",{minDate:new Date(g)});jQuery("#d_start_date").datepicker("option",{minDate:new Date(g),maxDate:null});jQuery("#d_end_date").datepicker("option",{minDate:new Date(g),maxDate:null})}});jQuery("#end_date").datepicker("option",{onClose:function(g,k){jQuery("#start_date").datepicker("option",
{maxDate:new Date(g)})}});jQuery("#d_start_date").datepicker("option",{maxDate:null,onClose:function(g,k){jQuery("#d_end_date").datepicker("option",{minDate:new Date(g)})}});jQuery("#d_end_date").datepicker("option",{maxDate:null,onClose:function(g,k){jQuery("#d_start_date").datepicker("option",{maxDate:new Date(g)})}});jQuery("#r_current").bind("click",function(g){jQuery("#start_date").datepicker("option",{minDate:null,maxDate:0});jQuery("#end_date").datepicker("option",{minDate:null,maxDate:0});
jQuery("#d_start_date").datepicker("option",{minDate:null,maxDate:null});jQuery("#d_end_date").datepicker("option",{minDate:null,maxDate:null})});jQuery("#r_future").bind("click",function(g){jQuery("#start_date").datepicker("option",{minDate:0,maxDate:null});jQuery("#start_date").value="";jQuery("#end_date").datepicker("option",{minDate:0,maxDate:null});jQuery("#d_start_date").datepicker("option",{minDate:0,maxDate:null});jQuery("#d_end_date").datepicker("option",{minDate:0,maxDate:null})});b=$("newPlace");
var f=document.createElement("div");f.innerHTML="<strong>"+place.address+"</strong>";b.replaceChild(f,b.firstChild);$("destForRide").innerHTML="<strong>"+place.address+"</strong>";document.updateFullForm.latlong.value=latlong;document.updateFullForm.place.value=place.address;if(typeof city!="undefined")document.updateFullForm.city.value=city;if(typeof state!="undefined")document.updateFullForm.state.value=state;document.updateFullForm.country.value=country;$("fillInfo").show()}})};geocoder.getLocations(c,
parseGeocode)}
function futureUpdateRefresh(c){var b=document.updateFullForm.from_home.value;if(b!=""){postGeoSuccess=function(){var d="";d+="&ride_latlong="+latlong;d+="&ride_place="+place.address;if(typeof city!="undefined")d+="&ride_city="+city;if(typeof state!="undefined")d+="&ride_state="+state;d+="&ride_country="+country;new Ajax.Updater("profileContainer","/homeFunctions?"+$(c).serialize()+d,{onComplete:function(e){new Ajax.Updater("dash","/dash.php");jQuery("#map").fadeOut("slow");jQuery("#profileTabs").fadeIn("fast");$("content").style.width=
"100%"}})};geocoder.getLocations(b,parseGeocode)}else new Ajax.Updater("profileContainer","/homeFunctions?"+$(c).serialize(),{onComplete:function(d){new Ajax.Updater("dash","/dash.php",{onComplete:function(e){jQuery("#map").fadeOut("slow");jQuery("#profileTabs").fadeIn("fast");$("content").style.width="100%"}})}})}
function stayTip(c){var b=$F(c.stayAddress2);if(b!=""){postGeoSuccess=function(){var d="";d+="&stay_latlong="+latlong;d+="&stay_lat="+lat;d+="&stay_lng="+lng;d+="&stay_place="+place.address;if(typeof streetline!="undefined")d+="&stay_streetline="+streetline;if(typeof city!="undefined")d+="&stay_city="+city;if(typeof state!="undefined")d+="&stay_state="+state;d+="&stay_country="+country;advAJAX("/homeFunctions?"+c.serialize()+d,c)};geocoder.getLocations(b,parseGeocode)}else alert("Location not recognized")}
function userMap(c){if(c=="current")c=tripUsername;new Ajax.Request("/userMap?username="+c,{onSuccess:function(b){eval(b.responseText)}})}function showHitchSpots(c,b,d){new Ajax.Request("/hitchSpots?lat="+c+"&lng="+b+"&distance="+d,{onSuccess:function(e){eval(e.responseText)}})}function showStaySpots(c,b,d){new Ajax.Request("/staySpots?lat="+c+"&lng="+b+"&distance="+d,{onSuccess:function(e){eval(e.responseText)}})}
function rideLoad(c){if($("tripDiv")){location.hash="rides/"+c;$("alertBorder").className="alertBorderActive";$("taskStatus").innerHTML="loading ride...";$("taskStatus").style.display="inline";new Ajax.Request("/rideContent.php?id="+c,{onSuccess:function(b){rideResult=b.responseText;javaHtmlSplit=rideResult.split("####ride javascript####");rideStops=[];for(x=1;x<javaHtmlSplit.length;x++)eval(javaHtmlSplit[x]);mainTabs("travelLink","travel");toggleDivs("travOptionDiv","tripDiv");tripDivContent="<a href=\"#\" onclick=\"toggleDivs('travOptionDiv', 'optionContainer'); sizeMap(); map.clearOverlays(); addStartEndMarkers(); ridesToMap()\">&laquo;Back to rides</a><br /><br />"+
javaHtmlSplit[0];sizeMap();$("tripDiv").innerHTML=tripDivContent;map.clearOverlays();pausePoint=[];for(i=0;i<rideStops.length;i++){pausePoint[i]=new google.maps.LatLng(rideStops[i].lat,rideStops[i].lng);map.addOverlay(createRegMarker(pausePoint[i],"Stopping here",iconStop))}rideStartPoint=new google.maps.LatLng(rideInfo.current.start_lat,rideInfo.current.start_lng);map.addOverlay(createRegMarker(rideStartPoint,"<strong>starting "+rideInfo.current.start_city+"</strong><br>Going to: "+rideInfo.current.end_city+
"<br>leaving on: "+rideInfo.current.leave_date+"<br>posted by:"+rideInfo.current.username+"<br>"+rideInfo.current.cost+"",iconStart));rideEndPoint=new google.maps.LatLng(rideInfo.current.end_lat,rideInfo.current.end_lng);map.addOverlay(createRegMarker(rideEndPoint,"This is where it ends",iconEnd));b=rideInfo.current.start_city+", "+rideInfo.current.start_state;var d=rideInfo.current.end_city+", "+rideInfo.current.end_state;tripDirections=[];for(i=0;i<=rideStops.length&&rideStops.length!=0;){iOffset=
i-1;startDir=i==0?b:rideStops[iOffset].city+", "+rideStops[iOffset].state;endDir=i==rideStops.length?d:rideStops[i].city+", "+rideStops[i].state;dirFill=startDir+" to "+endDir;tripDirections[i]=new google.maps.Directions;tripDirections[i].load(dirFill,{getPolyline:true,getSteps:true});i==rideStops.length&&google.maps.Event.addListener(tripDirections[i],"load",onTripDirectionsLoad);i++}if(i==0){tripDirections=null;tripDirections=new google.maps.Directions;tripDirections.load(b+" to "+d,{getPolyline:true,
getSteps:true});google.maps.Event.addListener(tripDirections,"load",onTripDirectionsLoad)}$("alertBorder").className="alertBorderFinish";$("taskStatus").innerHTML="Finished Loading Ride!";setTimeout("$('alertBorder').className = 'alertBorder'; $('taskStatus').style.display='none'",500)}})}else new Ajax.Updater("travelInfo","/travelContent.php",{onComplete:function(b){rideLoad(c)}})}
function dialog_box(c,b){d_div=document.createElement("div");d_div.setAttribute("title",b);d_div.innerHTML="loading...";jQuery(d_div).dialog({bgiframe:true,height:430,width:500,close:function(){d_div.innerHTML=""},modal:true});new Ajax.Updater(d_div,c,{evalScripts:true})}
function onTripDirectionsLoad(){tripSeconds=tripMeters=0;goodPoly=[];for(i=0;i<=rideStops.length&&rideStops.length!=0;){goodPoly[i]=tripDirections[i].getPolyline();map.addOverlay(goodPoly[i]);tripMeters+=tripDirections[i].getDistance().meters;tripSeconds+=tripDirections[i].getDuration().seconds;var c=tripDirections[i].getBounds();map.setCenter(c.getCenter(),map.getBoundsZoomLevel(c));i++}if(i==0){goodPoly=null;goodPoly=tripDirections.getPolyline();map.addOverlay(goodPoly);c=tripDirections.getBounds();
map.setCenter(c.getCenter(),map.getBoundsZoomLevel(c));tripMeters=tripDirections.getDistance().meters;tripSeconds=tripDirections.getDuration().seconds}c.extend(rideStartPoint);c.extend(rideEndPoint);map.setCenter(c.getCenter(),map.getBoundsZoomLevel(c));totalMiles=Math.round(tripMeters/1609.344);totalHours=Math.floor(tripSeconds/60/60);extraMinutes=Math.floor(tripSeconds/60)%60;if(totalHours>23){totalDays=Math.floor(totalHours/24);totalHours=totalHours%24+Math.round(extraMinutes/60);totalTime=totalDays+
" days "+totalHours+" hours"}else totalTime=totalHours+" hours "+extraMinutes+" minutes";carMPG=rideInfo.current.mpg;gallonCost=2.5;costTrip=Math.round(totalMiles/carMPG*gallonCost);$("justDistance").innerHTML="<span class='simpetext'> <strong>Total:</strong> "+totalMiles+" miles ("+totalTime+"). Around $"+costTrip+" for gas at $"+gallonCost+" a gallon getting "+carMPG+"mpg (<strong>"+rideInfo.current.cost+" for you</strong>)</span>"}
function transitLocationAdd(){if(!$("transitOrigin").value||!$("transitDestination").value){alert("You must enter a start and end location.");return false}else transitLocations=[$("transitOrigin").value,$("transitDestination").value];new multiGeocode(transitLocations,function(c){x=0;c.each(function(d){if(x==0){$("aPlace").value+=d.place+";";transit_place1=d.place;$("aAddress").value+=d.street_address+";";$("aCity").value+=d.city+";";$("aState").value+=d.state+";";$("aCountry").value+=d.country+";";
$("aPoint").value+=d.coor+";";$("oneCost").value+=$("onewayCost").value+";";$("roundCost").value+=$("roundtripCost").value+";";$("flowAll").value+=$("flow").value+";"}else{$("bPlace").value+=d.place+";";transit_place2=d.place;$("bAddress").value+=d.street_address+";";$("bCity").value+=d.city+";";$("bState").value+=d.state+";";$("bCountry").value+=d.country+";";$("bPoint").value+=d.coor+";"}x++});$("saveButton").disabled=false;$("saveButton").value="Save";c=$("addedRoutes");var b=document.createElement("div");
$("flow").value=="round"?(flow="To/From"):(flow="To");b.innerHTML=transit_place1+" <strong>"+flow+"</strong> "+transit_place2;c.appendChild(b)})}
function addTransitAddressToMap(c){if(!c||c.Status.code!=200)alert("Sorry, we were unable to geocode that address");else{place=c.Placemark[0];point=new google.maps.LatLng(place.Point.coordinates[1],place.Point.coordinates[0]);marker=new google.maps.Marker(point);var b,d;if(c=place.AddressDetails.Country.AdministrativeArea){state=c.AdministrativeAreaName;if(b=c.SubAdministrativeArea){county=b.SubAdministrativeAreaName;if(d=b.Locality){city=d.LocalityName;if(d.Thoroughfare)streetLine=d.Thoroughfare.ThoroughfareName;
if(d.PostalCode)zip=d.PostalCode.PostalCodeNumber}else{if(b.Thoroughfare)streetLine=b.Thoroughfare.ThoroughfareName;if(b.PostalCode)zip=b.PostalCode.PostalCodeNumber}}else if(d=c.Locality){city=d.LocalityName;if(d.Thoroughfare)streetLine=d.Thoroughfare.ThoroughfareName;if(d.PostalCode)zip=d.PostalCode.PostalCodeNumber}else{if(c.Thoroughfare)streetLine=c.Thoroughfare.ThoroughfareName;if(c.PostalCode)zip=c.PostalCode.PostalCodeNumber}}country=place.AddressDetails.Country.CountryNameCode;point=place.Point.coordinates[1]+
","+place.Point.coordinates[0];var e=$("aPlace"),f=$("aAddress"),g=$("aCity"),k=$("aState"),j=$("aCountry"),l=$("aPoint"),m=$("bPlace"),r=$("bAddress"),n=$("bCity"),o=$("bState"),q=$("bCountry"),u=$("bPoint");d=$("oneCost");b=$("roundCost");c=$("flowAll");if(x!=1){map.addOverlay(marker);marker.openInfoWindowHtml("<strong>"+place.address+"</strong>");place1=place.address;e.value+=place.address+";";FromString="?style=script";if(typeof streetLine!="undefined"){FromString+="&address1="+streetLine;f.value+=
streetLine+";"}else f.value+="n/a;";if(typeof city!="undefined"){FromString+="&city1="+city;g.value+=city+";"}else g.value+="n/a;";if(typeof state!="undefined"){FromString+="&state1="+state;k.value+=state+";"}else k.value+="n/a;";if(typeof country!="undefined"){FromString+="&country1="+country;j.value+=country+";"}else j.value+="n/a;";if(typeof point!="undefined"){FromString+="&point1="+point;l.value+=point+";"}else l.value+="n/a;";e=$("onewayCost");d.value+=typeof e.value!="undefined"&&e.value!=
""?$("onewayCost").value+";":"n/a;";d=$("roundtripCost");b.value+=typeof d.value!="undefined"&&d.value!=""?$("roundtripCost").value+";":"n/a;";b=$("flow");c.value+=b.value=="round"?"round;":"one;";c=$("aCheck");$("saveButton").disabled=false;$("saveButton").value="Save";x=1;document.transitSearchForm.destination.value!=""?geocoder.getLocations(document.transitSearchForm.destination.value,addTransitAddressToMap):alert("enter a destination")}else{map.addOverlay(marker);place2=place.address;m.value+=
place.address+";";ToString="";if(typeof streetLine!="undefined"){ToString+="&address2="+streetLine;r.value+=streetLine+";"}else r.value+="n/a;";if(typeof city!="undefined"){ToString+="&city2="+city;n.value+=city+";"}else n.value+="n/a;";if(typeof state!="undefined"){ToString+="&state2="+state;o.value+=state+";"}else o.value+="n/a;";if(typeof country!="undefined"){ToString+="&country2="+country;q.value+=country+";"}else q.value+="n/a;";if(typeof point!="undefined"){ToString+="&point2="+point;u.value+=
point+";"}else u.value+="n/a;";c=$("addedRoutes");d=document.createElement("div");b=document.transitSearchForm.flow.value=="round"?"To/From":"To";d.innerHTML=place1+" <strong>"+b+"</strong> "+place2;c.appendChild(d)}}}function showTransitLocation(){x=0;geocoder.getLocations(document.transitSearchForm.origin.value,addTransitAddressToMap)}function loading_show(c,b){if(typeof b=="undefined"||b=="simple")var d='<img src="/images/th_loader.gif" />';jQuery("#"+c).innerHTML=d}
function advAJAX(c,b,d,e){loadingMsg="loading...";endLength="200";$("alertBorder").className="alertBorderActive";$("taskStatus").innerHTML=loadingMsg;$("taskStatus").style.display="inline";new Ajax.Request(c,{onSuccess:function(f){$("alertBorder").className="alertBorderFinish";$("taskStatus").innerHTML="finished!";freshResponseContent="loading...";var g=typeof b=="string"?$(b):b;if(typeof d!="undefined"&&d!="")new Ajax.Request(d,{onSuccess:function(k){freshResponseContent=k.responseText;g.innerHTML=
freshResponseContent}});else freshResponseContent=f.responseText;g.innerHTML=freshResponseContent;setTimeout("$('alertBorder').className = 'alertBorder'; $('taskStatus').style.display='none'",endLength)}})}function toggleItems(c,b,d,e){tabSelectors=$$("#"+b+" a");for(i=0;i<tabSelectors.length;i++)tabSelectors[i].style.fontWeight="normal";if(c!="none")c.style.fontWeight="bold"}
function toggleDivs(c,b){divSelectors=$$("div."+c);for(i=0;i<divSelectors.length;i++)divSelectors[i].style.display="none";$(b).style.display="block"}
function edit_location_dialog(c,b){if(typeof b=="undefined"||b=="edit")var d="Edit this location",e="editLocationBeta?id="+c;else if(b=="arrived"){d="Update this location";e="editLocationBeta?just_arrived=yes&id="+c}dia_div=document.createElement("div");dia_div.setAttribute("title",d);dia_div.innerHTML="loading...";jQuery(dia_div).dialog({bgiframe:true,height:430,width:500,close:function(){dia_div.innerHTML=""},modal:true});new Ajax.Updater(dia_div,e,{evalScripts:true})}
function loadProfile(c){var b=true;location.hash="people/"+c;if(c.toLowerCase()==2){var d=$("profileContainer");$("memberContainer").innerHTML="";if(d.innerHTML.length>1E3)b=false;else if(typeof usersProfileTemp!="undefined"){b=false;d.innerHTML=usersProfileTemp}else d.innerHTML='<img src="/images/kangourousLoad.gif" > ...hopping to it.';mainTabs("homeLink","home");$$("#homeContent > div").invoke("hide");$("profileContainer").show()}else{$("memberSelect").innerHTML=c;if($("profileContainer").innerHTML.length>
1E3){usersProfileTemp=$("profileContainer").innerHTML;$("profileContainer").innerHTML=""}d=$("memberContainer");d.innerHTML='<img src="/images/kangourousLoad.gif" > ...hopping to it.';mainTabs("peopleLink","people");toggleItems($("memberSelect"),"peopleSelect");toggleDivs("peopleDivs","memberContainer")}map.clearOverlays();userMap(c);jQuery("#map").fadeOut("fast");$("content").style.width="100%";if(b==true){$("alertBorder").className="alertBorderActive";$("taskStatus").innerHTML="loading profile...";
$("taskStatus").style.display="inline";new Ajax.Updater(d,"/profileContent.php?name="+c,{evalScripts:true,onComplete:function(e){$("alertBorder").className="alertBorderFinish";$("taskStatus").innerHTML="finished!";setTimeout("$('alertBorder').className = 'alertBorder'; $('taskStatus').style.display='none'","10")}})}}
function tipLoad(c){new Ajax.Request("/tipPage?id="+c,{onSuccess:function(b){toggleDivs("travOptionDiv","tipDiv");$("tipDiv").innerHTML="<a href=\"#\" onclick=\"toggleDivs('travOptionDiv', 'optionContainer'); sizeMap(); map.clearOverlays(); addStartEndMarkers(); ridesToMap()\">&laquo;Back to rides</a><br /><br />"+b.responseText}})}
function handleEnter(c,b,d){if((b.keyCode?b.keyCode:b.which?b.which:b.charCode)==13){if(d=="go")travel($("originT").value,$("destT").value);else if(d=="stay")stay($("stayT").value);else d=="explore"&&explore($("exploreT").value);for(b=0;b<c.form.elements.length;b++)if(c==c.form.elements[b])break;b=(b+1)%c.form.elements.length;c.form.elements[b].focus();return false}else return true}
function dateRangeToggle(c,b){b=$(b);if(c.selectedIndex==1){b.disabled=false;b.style.visibility="visible"}else{b.disabled="disabled";b.style.visibility="hidden"}}function showCraigContent(c){var b=$("craigFull");b.show();var d=document.createElement("div");d.innerHTML=c;b.replaceChild(d,b.firstChild);sizeMap()}function showMap(){$("craigFull").hide();sizeMap()}
function mainTabs(c,b){typeof map!="undefined"&&clearGooglebar();if(c=="homeLink"){jQuery("#profileTabs").fadeIn("fast");jQuery("#map").fadeOut("fast");$("content").style.width="100%"}else if(c=="peopleLink"){jQuery("#map").fadeOut("fast");$("content").style.width="100%";if($("memberSelect").style.fontWeight=="bold"||$("peopleContent").innerHTML.length<100)$("friend_feed")?jQuery("#friend_feed").click():jQuery("#everybodySelect").click();else $("friend_feed")&&$("friend_feed").style.fontWeight=="bold"&&
jQuery("#friend_feed").click()}else{$("map").show();typeof map=="undefined"&&oonLoad();$("content").style.width="500px"}recentToggleLink=c;recentToggleDiv=b;$$("#mainNav > li").invoke("removeClassName","selectedTab");$(c).addClassName("selectedTab");$$("#content > div").invoke("hide");jQuery("."+b).each(function(d){jQuery(this).show()});sizeMap()}function titleToggle(c,b){$$("#"+b+" > a").invoke("removeClassName","selectedSecond");c.addClassName("selectedSecond")}
function toggleRecent(c){tabSelectors=$$("#recentFilter a");for(i=0;i<tabSelectors.length;i++)tabSelectors[i].className="";c.className="filterSelected"}function saveCheck(){var c=$("rideCheck"),b=$("rideSaveButton");if(c.checked==true){b.disabled=false;b.value="Save"}else{b.disabled=true;b.value="Check the box first!"}}
function radio_checker(){if(document.ridePostForm.custom_amount.checked){document.ridePostForm.custom_donation.disabled=false;document.ridePostForm.custom_donation.focus();$("mpgDiv").style.display="none"}else if(document.ridePostForm.gasSplit.checked){document.ridePostForm.custom_donation.disabled=true;$("mpgDiv").style.display="block"}else{document.ridePostForm.custom_donation.disabled=true;$("mpgDiv").style.display="none"}}
function csGroups(c,b,d){csIDs=null;csIDs=[];groupURL="http://www.couchsurfing.org/feeds/group_rss.php?gid="+c;b.innerHTML="";c=new google.feeds.Feed(groupURL);c.includeHistoricalEntries();c.setNumEntries(d);c.setResultFormat(google.feeds.Feed.JSON_FORMAT);c.load(function(e){if(!e.error)for(var f=0;f<e.feed.entries.length;f++){var g=e.feed.entries[f],k=["title","link","publishedDate","contentSnippet","content"];csC=g.content;k=csC.replace(/(<([^>]+)>)/ig,"");k="<strong>"+g.title+"</strong><br /><br />"+
k;csIDs[csIDs.length]=k;var j=document.createElement("div");j.className="craigEntrye";j.innerHTML="<div><strong class='simpetext'><a href=\""+g.link+"\" target=\"_blank\" onmouseover=\"jQuery(this).next().stop(true, true).animate({opacity: 'show', top: '120'}, 'normal')\" onmouseout=\"jQuery(this).next().animate({opacity: 'hide', top: '-70'}, 'fast')\">"+g.title+"</a><span>"+k+"</span></strong><div class=\"simpetext\"><img src='/images/cs.png' align='absmiddle' /> <a href='"+g.link+"' class='resultLink' style='color:#006600'>"+
e.feed.title+"</a> - "+g.contentSnippet+"</div></div><br />";b.appendChild(j)}})}
function search_csGroups(c,b,d,e){csIDs=null;csIDs=[];num_entries=300;var f=false;groupURL=e==true?"http://www.couchsurfing.org/feeds/group_rss.php?replies=1&gid="+c:"http://www.couchsurfing.org/feeds/group_rss.php?gid="+c;b.innerHTML="";c=new google.feeds.Feed(groupURL);c.includeHistoricalEntries();c.setNumEntries(num_entries);c.setResultFormat(google.feeds.Feed.JSON_FORMAT);c.load(function(g){if(!g.error){for(var k=0;k<g.feed.entries.length;k++){var j=g.feed.entries[k],l=["title","link","publishedDate",
"contentSnippet","content"],m=new RegExp(d,"i");l=j.title.search(m);m=j.content.search(m);if(l!=-1||m!=-1){var r=true;csC=j.content;l=csC.replace(/(<([^>]+)>)/ig,"");csIDs[csIDs.length]="<strong>"+j.title+"</strong><br /><br />"+l;l=document.createElement("div");l.className="craigEntry";l.setAttribute("onmouseover","showCraigContent(csIDs["+(csIDs.length-1)+"])");l.setAttribute("onmouseout","showMap()");l.innerHTML="<img src='/images/cs.png' align='absmiddle' /> <span class='simpetext'><strong><a href='"+
j.link+"' target='_blank' onmouseover='showCraigContent(csIDs["+(csIDs.length-1)+"])' onmouseout='showMap()'>"+j.title+"</a></strong> - "+j.contentSnippet+"</span><br /><a href='"+j.link+"' class='resultLink' style='color:#006600'>"+g.feed.title+" ("+j.publishedDate.substr(0,11)+")</a><br /><br />";b.appendChild(l)}}if(r==false&&e==true)search_csGroups($("csSelect").value,$("CS_group_content"),$("cs_g_q").value,false);else if(b.innerHTML=="")b.innerHTML='no results found for "'+d+'" in recent discussions'}})}
function externalRidesTest(c,b){content_display=typeof b=="undefined"?"full":"short";csRideArray=null;csRideArray=[];areasSearched=allRideArrayCount=0;b=false;if(allRideArray.length>0)b=true;allRideArray[allRideArray.length]={fullURL:"http://welcomehere.org/cgi-bin/yabb2/YaBB.pl?action=RSSboard;board=need;",urlID:"need",site:"WH",origin_distance:"300",destination_distance:"300",type:2};allRideArray[allRideArray.length]={fullURL:"http://welcomehere.org/cgi-bin/yabb2/YaBB.pl?action=RSSboard;board=got;",
urlID:"need",site:"WH",origin_distance:"300",destination_distance:"300",type:3};allRideArray[allRideArray.length]={urlID:"658",site:"CS",origin_distance:"300",destination_distance:"300",type:1};if(typeof entriesShown=="undefined")entriesShown=20;b==true&&parseAllRides(c)}
function parseAllRides(c){divToFill=$("newIdea");divToFill=c;var b=allRideArray[allRideArrayCount].urlID,d=allRideArray[allRideArrayCount].site,e=allRideArray[allRideArrayCount].type,f=allRideArray[allRideArrayCount].origin_distance;allRideArrayCount++;if(d=="CS"){var g="http://www.couchsurfing.org/feeds/group_rss.php?gid="+b;b=30;var k=14}else{if(d=="CL")g="http://"+b+".craigslist.org/rid/index.rss";b=100;k=14}if(allRideArray[allRideArrayCount-1].fullURL!=""&&typeof allRideArray[allRideArrayCount-
1].fullURL!="undefined")g=allRideArray[allRideArrayCount-1].fullURL;g=new google.feeds.Feed(g);g.includeHistoricalEntries();g.setNumEntries(b);g.setResultFormat(google.feeds.Feed.JSON_FORMAT);g.load(function(j){if(!j.error){for(var l=0;l<j.feed.entries.length;l++){var m=j.feed.entries[l],r=["title","link","publishedDate","contentSnippet","content"],n=d=="CS"?e==1?true:false:true;offerPhrases=null;offerPhrases=new Array("offering a ride","can give you a lift","anyone need a lift","anyone need a ride",
"offering a lift","can drive you","can drive someone","im driving","i'm driving","if you need a ride","ride offered","i'll drive my car","rideshare offered","give you a ride","i will be driving","need a ride?","ride offer:");requestPhrases=null;requestPhrases=new Array("requesting a ride","i need a ride","i need a lift","can someone drive","i'm looking for a ride","can drive me","ride needed:","give me a ride","i am looking for a ride","is anybody driving","i would love a ride","ride wanted:","give me a ride",
"need ride","i am seeking a ride");ridePhrases=null;ridePhrases=new Array(" ride ","anyone need a lift","anyone needs a lift","offering a lift","drive","road trip","need a ride");for(x=0;x<offerPhrases.length;x++){var o=new RegExp(offerPhrases[x],"i"),q=m.title.search(o);o=m.content.search(o);if(q!=-1||o!=-1){var u=true;n=true;break}else u=false}for(x=0;x<requestPhrases.length;x++){o=new RegExp(requestPhrases[x],"i");q=m.title.search(o);o=m.content.search(o);if(q!=-1||o!=-1){var t=true;n=true;break}else t=
false}for(x=0;x<ridePhrases.length;x++){o=new RegExp(ridePhrases[x],"i");q=m.title.search(o);o=m.content.search(o);if(q!=-1||o!=-1){n=true;break}}if(e==2){t=true;u=false}else if(e==3){u=true;t=false}q=31536E6;q=Date.parse(m.publishedDate);if((Date.parse(Date())-q)/864E5>k)n=false;if(n==true){q=new RegExp(cityFrom,"i");n=m.title.search(q);q=m.content.search(q);if(cityTo!=""){var s=new RegExp(cityTo,"i");o=m.title.search(s);s=m.content.search(s)}else s=o=-1;n=1+(n!=-1||q!=-1||f<30?2:f<80?1:0)+(o!=-1||
s!=-1||0?3:0);if(d=="CS")n+=0.5;cRaN=csRideArray.length;csRideArray[cRaN]=[];q=Date.parse(m[r[2]]);if(n>2&&m[r[2]]!=""){csRideArray[cRaN][0]=n*1E15+q;csRideArray[cRaN][1]=m[r[1]];csRideArray[cRaN][2]=m[r[2]];csRideArray[cRaN][3]=m[r[3]];csRideArray[cRaN][4]=m[r[0]];csRideArray[cRaN][5]=j.feed.title;csRideArray[cRaN][6]=m[r[4]];csRideArray[cRaN][8]=u==true?"offer":t==true?"request":"burn";if(d=="CS")csRideArray[cRaN][9]="/images/cs.png";else if(d=="CL")csRideArray[cRaN][9]="/images/craigslist.png";
else if(d=="WH")csRideArray[cRaN][9]="/images/welcomehere.png"}}}areasSearched++;divToFill.innerHTML="<img src='/images/loading_green_sway.gif' align='absmiddle' /> Searching "+areasSearched+" of "+allRideArray.length+" resources";if(allRideArray.length>allRideArrayCount)parseAllRides(c);else{csIDs=null;csIDs=[];divToFill.innerHTML="";csRideArray.sort();csRideArray.reverse();forCount=csRideArray.length<=entriesShown?csRideArray:entriesShown;for(h=0;h<forCount;h++){j=csRideArray[h][6].replace(/(<([^>]+)>)/ig,
"");j="<strong>"+csRideArray[h][4]+"</strong><br /><br />"+j;csIDs[csIDs.length]=j;l=document.createElement("div");l.className="craigEntrye";m=csRideArray[h][8]=="request"?"/images/thumb_up.png":csRideArray[h][8]=="offer"?"/images/car.png":"/images/bullet_green.gif";l.innerHTML=content_display=="short"?"<img src='"+m+"' align='absmiddle' /> <strong class='simpetext'><a href=\""+csRideArray[h][1]+"\" target=\"_blank\" onmouseover=\"jQuery(this).next().stop(true, true).animate({opacity: 'show', top: '120'}, 'normal')\" onmouseout=\"jQuery(this).next().animate({opacity: 'hide', top: '-70'}, 'fast')\">"+
csRideArray[h][4]+"</a><span>"+j+"</span></strong><br /><!--<img src='"+csRideArray[h][9]+"' align='absmiddle' /> --\><a href='"+csRideArray[h][1]+"' class='resultLink' style='color:#006600'><strong>posted "+csRideArray[h][2].substr(0,11)+" to "+csRideArray[h][5]+"</a><br /><br />":"<img src='"+csRideArray[h][9]+"' align='absmiddle' /> <img src='"+m+"' align='absmiddle' /> <strong class='simpetext'><a href=\""+csRideArray[h][1]+"\" target=\"_blank\" onmouseover=\"jQuery(this).next().stop(true, true).animate({opacity: 'show', top: '120'}, 'normal')\" onmouseout=\"jQuery(this).next().animate({opacity: 'hide', top: '-70'}, 'fast')\">"+
csRideArray[h][4]+"</a><span>"+j+"</span> - "+csRideArray[h][3]+" (posted on "+csRideArray[h][2].substr(0,11)+")</strong> <a href='"+csRideArray[h][1]+"' class='resultLink' style='color:#006600'><strong>"+csRideArray[h][5]+"</strong></a><br /><br />";divToFill.appendChild(l)}}}})}
function CSridesharePull(c){csHits=null;csHits=[];c=new google.feeds.Feed(c);c.includeHistoricalEntries();c.setNumEntries(30);c.setResultFormat(google.feeds.Feed.JSON_FORMAT);c.load(function(b){if(!b.error)for(var d=0;d<b.feed.entries.length;d++){var e=b.feed.entries[d],f=["title","link","publishedDate","contentSnippet","content"],g=new RegExp(cityFrom,"i");f=e.title.search(g);g=e.content.search(g);if(cityTo!=""){var k=new RegExp(cityTo,"i"),j=e.title.search(k);k=e.content.search(k)}else k=j=-1;csC=
e.content;var l=csC.replace(/(<([^>]+)>)/ig,"");csHits[csHits.length]="<strong>"+e.title+"</strong><br /><br />"+l;if(f!=-1||g!=-1||j!=-1||k!=-1){f=document.createElement("div");f.className="craigEntry";f.setAttribute("onmouseover","showCraigContent(csHits["+(csHits.length-1)+"])");f.setAttribute("onmouseout","showMap()");f.innerHTML="<img src='/images/cs.png' align='absmiddle' /> <span class='simpetext'><strong><a href='"+e.link+"' target='_blank' onmouseover='showCraigContent(csHits["+(csHits.length-
1)+"])' onmouseout='showMap()'>"+e.title+"</a></strong> - "+e.contentSnippet+"</span><br /><a href='"+e.link+"' class='resultLink' style='color:#006600'>"+e.link+"</a><br /><br />";$("CS_rides").appendChild(f)}}})}
function craigUpdate(c){var b=[];if(typeof c=="undefined")c=cityFrom.toLowerCase().replace(/ /gi,"");b[0]="http://"+c+".craigslist.org/rid/index.rss";if(cityTo!=""){feedStrTo=cityTo.toLowerCase().replace(/ /gi,"");b[1]="http://"+feedStrTo+".craigslist.org/rid/index.rss"}var d=[],e=[],f=$("feed"),g=b.length;for(f=pp=0;f<b.length;f++){pp++;var k=new google.feeds.Feed(b[f]);k.setNumEntries(75);k.setResultFormat(google.feeds.Feed.JSON_FORMAT);k.load(function(j){if(!j.error)for(var l=0;l<j.feed.entries.length;l++){var m=
j.feed.entries[l],r=["title","link","publishedDate","contentSnippet","content"],n=d.length;d[n]=[];d[n][0]=Date.parse(m[r[2]]);d[n][1]=m[r[1]];d[n][2]=m[r[2]];d[n][3]=m[r[3]];d[n][4]=m[r[0]];d[n][5]=j.feed.title;d[n][6]=m[r[4]]}g--;if(g==0){for(j=0;j<d.length;j++){var o=e.length,q=d[j][6];l=d[j][4];m=d[j][1];r=d[j][2];n=d[j][3];var u=d[j][5];possibleWaste=false;if(b.length==1)t=1;else{var t=2,s=new RegExp(c,"i"),w=new RegExp(feedStrTo,"i");if(m.search(s)!=-1){s=cityTo;w=cityFrom;t+=1}else{s=cityFrom;
possibleWaste=true}s=new RegExp(s,"i");if(q.search(s)!=-1){t+=2;possibleWaste=false}if(l.search(s)!=-1){t+=2;possibleWaste=false}}if(possibleWaste==false){e[o]=[];e[o][0]=t*1.0E27+Date.parse(r);e[o][1]=m;e[o][2]=r;e[o][3]=n;e[o][4]=l;e[o][5]=u;e[o][6]=q}}e.sort();e.reverse();o=$("craigListings");o.innerHTML="";craigHits=null;craigHits=[];for(j=0;j<10;j++){l=e[j][4];q=e[j][6].replace(/(<([^>]+)>)/ig,"");craigHits[craigHits.length]="<strong>"+l+"</strong><br /><br />"+q;cityFromRe=new RegExp(cityFrom,
"gi");stateFromRe=new RegExp(stateFrom,"gi");l=l.replace(cityFromRe,"<strong>"+cityFrom+"</strong>");if(cityTo){cityToRe=new RegExp(cityTo,"gi");stateToRe=new RegExp(stateTo,"gi");l=l.replace(cityToRe,"<strong>"+cityTo+"</strong>")}m=e[j][1];r=e[j][2];n=e[j][3];q=document.createElement("div");q.className="craigEntry";q.setAttribute("onmouseover","showCraigContent(craigHits["+(craigHits.length-1)+"])");q.setAttribute("onmouseout","showMap()");q.innerHTML="<a href='"+m+"' target='_blank' onmouseover='showCraigContent(craigHits["+
(craigHits.length-1)+"])' onmouseout='showMap()'>"+l+"</a> - <span class='simpetext'>"+n+"(posted on "+r.substr(0,11)+")</span><br /><a href='"+m+"' class='resultLink' style='color:#006600'>"+m+"</a><br /><br />";o.appendChild(q)}j=document.createElement("div");j.innerHTML="<span class='simpetext'><strong><a href='http://"+c+".craigslist.org/rid' target='_blank'>More Craigslist Listings...</a></strong></span><br /><div style='clear:both'></div>";o.appendChild(j)}})}}
function GSCLoad(c,b){if(b=="stay"){restrictionCode="013602994325965359162:k0lk9u5lei4";searchDiv="staySearchControl"}else{restrictionCode="000519232147513413721:7awm5yzfdai";searchDiv="searchcontrol"}b=new google.search.SearchControl;var d=new google.search.WebSearch;d.setSiteRestriction(restrictionCode);b.addSearcher(d);d.setResultSetSize(google.search.Search.LARGE_RESULTSET);d=new google.search.DrawOptions;d.setDrawMode(google.search.SearchControl.DRAW_MODE_TABBED);b.draw($(searchDiv),d);b.execute(c)}
function saveCheck2(){if($("aCheck").checked==true){$("saveButton").disabled=false;$("saveButton").value="Save"}else{$("saveButton").disabled=true;$("saveButton").value="Check the box first!"}}
function onChange(){if(document.transitSearchForm.date_type.selectedIndex==1){document.transitSearchForm.second_date.disabled=false;document.transitSearchForm.second_date.style.visibility="visible"}else{document.transitSearchForm.second_date.disabled="disabled";document.transitSearchForm.second_date.style.visibility="hidden"}}
function saveCheck22(){if($("aCheck2").checked==true){$("saveButton2").disabled=false;$("saveButton2").value="Save"}else{$("saveButton2").disabled=true;$("saveButton2").value="Check the box first!"}}
function addHitchAddressToMap(c){if(!c||c.Status.code!=200)alert("Sorry, we were unable to geocode that address");else{place=c.Placemark[0];point=new google.maps.LatLng(place.Point.coordinates[1],place.Point.coordinates[0]);marker=new google.maps.Marker(point);var b,d;if(c=place.AddressDetails.Country.AdministrativeArea){state=c.AdministrativeAreaName;if(b=c.SubAdministrativeArea){county=b.SubAdministrativeAreaName;if(d=b.Locality){city=d.LocalityName;if(d.Thoroughfare)streetLine=d.Thoroughfare.ThoroughfareName;
if(d.PostalCode)zip=d.PostalCode.PostalCodeNumber}else{if(b.Thoroughfare)streetLine=b.Thoroughfare.ThoroughfareName;if(b.PostalCode)zip=b.PostalCode.PostalCodeNumber}}else if(d=c.Locality){city=d.LocalityName;if(d.Thoroughfare)streetLine=d.Thoroughfare.ThoroughfareName;if(d.PostalCode)zip=d.PostalCode.PostalCodeNumber}else{if(c.Thoroughfare)streetLine=c.Thoroughfare.ThoroughfareName;if(c.PostalCode)zip=c.PostalCode.PostalCodeNumber}}country=place.AddressDetails.Country.CountryNameCode;coor=place.Point.coordinates[1]+
","+place.Point.coordinates[0];c=$("hitchPlace");b=$("hitchAddress");d=$("hitchCity");var e=$("hitchState"),f=$("hitchCountry"),g=$("hitchPoint");map.addOverlay(marker);marker.openInfoWindowHtml("<strong>"+place.address+"</strong>");place1=place.address;c.value+=place.address+";";FromString="?style=script";if(typeof streetLine!="undefined"){FromString+="&address1="+streetLine;b.value+=streetLine+";"}else b.value+="n/a;";if(typeof city!="undefined"){FromString+="&city1="+city;d.value+=city+";"}else d.value+=
"n/a;";if(typeof state!="undefined"){FromString+="&state1="+state;e.value+=state+";"}else e.value+="n/a;";if(typeof country!="undefined"){FromString+="&country1="+country;f.value+=country+";"}else f.value+="n/a;";if(typeof coor!="undefined"){FromString+="&point1="+coor;g.value+=coor+";"}else g.value+="n/a;";$("aCheck2").disabled=false;$("saveButton2").value="Check the box before saving";c=$("routeHitchList");b=document.createElement("div");b.innerHTML=place1;c.appendChild(b)}}
function showHitchLocation(){var c=document.hitchForm.hitchOrigin.value;document.hitchForm.hitchOrigin.value="";geocoder.getLocations(c,addHitchAddressToMap)}function onChange2(){if(document.hitchForm.date_type2.selectedIndex==1){document.hitchForm.second_date2.disabled=false;document.hitchForm.second_date2.style.visibility="visible"}else{document.hitchForm.second_date2.disabled="disabled";document.hitchForm.second_date2.style.visibility="hidden"}}
function addCityOnEnter(c,b){if((b.keyCode?b.keyCode:b.which?b.which:b.charCode)==13){showHitchLocation();return false}else return true}function subwaySelect(){var c=$("subwayDiv"),b=$(countyFrom),d=$(countyTo+"a");b.selected=true;d.selected=true;c.style.display="block"}
function metroNorth(){for(var c=1;c<3;){j="no";for(var b=c==1?$("orig_station"):$("dest_station"),d=0;j=="no";){b.options[d].selected="1";var e=b.options[b.selectedIndex].text;if(c==1)var f=cityFrom,g=countyFrom;else{f=cityTo;g=countyTo}if(f=="New York"||g=="Queens"||g=="Bronx"||g=="Brooklyn"||g=="Staten Island")f="Grand Central Terminal";if(e==f){j="stay";if(c==1)var k=f}d++;if(e=="Yonkers"){j="stay";if(f!=e){b.options[34].selected="1";f=$("metrodiv");f.style.display="none"}}}c++}if(k==e){f=$("metrodiv");
f.style.display="none"}now=new Date;hour=now.getHours();if(hour>12){hour-=12;ampm="PM"}else{hour=hour;ampm="AM"}if(hour==12)ampm="PM";if(hour==0)hour="12";var j="no";c=0;for(b=$("currentTime");j=="no";){b.options[c].selected="1";if(b.options[b.selectedIndex].text==hour+":00")j="stay";c++}j=$("ampm");if(j.options[j.selectedIndex].text!=ampm)b.options[c].selected="1"}
function longIsland(){for(var c=1;c<3;){decide2="no";for(var b=c==1?$("county1"):$("county2"),d=0;decide2=="no";){b.options[d].selected="1";var e=b.options[b.selectedIndex].text,f=c==1?cityFrom+", NY":cityTo+", NY";if(e==f)decide2="stay";d++;if(e=="Yaphank, NY"){decide2="stay";if(f!=e)$("LI").style.display="none"}}c++}}currentLocationIcon=new google.maps.Icon;currentLocationIcon.image="/images/current_location.png";currentLocationIcon.shadow="/images/current_location_shadow.png";
currentLocationIcon.iconSize=new google.maps.Size(48,48);currentLocationIcon.shadowSize=new google.maps.Size(73,48);currentLocationIcon.iconAnchor=new google.maps.Point(24,50);currentLocationIcon.infoWindowAnchor=new google.maps.Point(5,1);tripStartIcon=new google.maps.Icon;tripStartIcon.image="/images/tripStart.png";tripStartIcon.shadow="/images/flagShadow.png";tripStartIcon.iconSize=new google.maps.Size(48,48);tripStartIcon.shadowSize=new google.maps.Size(73,48);
tripStartIcon.iconAnchor=new google.maps.Point(31,45);tripStartIcon.infoWindowAnchor=new google.maps.Point(5,1);tripEndIcon=new google.maps.Icon;tripEndIcon.image="/images/tripEnd.png";tripEndIcon.shadow="/images/flagShadow.png";tripEndIcon.iconSize=new google.maps.Size(48,48);tripEndIcon.shadowSize=new google.maps.Size(73,48);tripEndIcon.iconAnchor=new google.maps.Point(31,45);tripEndIcon.infoWindowAnchor=new google.maps.Point(5,1);iconStart=new google.maps.Icon;iconStart.image="http://triphopping.com/images/start.png";
iconStart.shadow="http://labs.google.com/ridefinder/images/mm_20_shadow.png";iconStart.iconSize=new google.maps.Size(21,34);iconStart.shadowSize=new google.maps.Size(22,20);iconStart.iconAnchor=new google.maps.Point(10,34);iconStart.infoWindowAnchor=new google.maps.Point(5,1);iconEnd=new google.maps.Icon;iconEnd.image="http://triphopping.com/images/end.png";iconEnd.shadow="http://labs.google.com/ridefinder/images/mm_20_shadow.png";iconEnd.iconSize=new google.maps.Size(21,34);
iconEnd.shadowSize=new google.maps.Size(22,20);iconEnd.iconAnchor=new google.maps.Point(10,34);iconEnd.infoWindowAnchor=new google.maps.Point(5,1);iconStop=new google.maps.Icon;iconStop.image="http://triphopping.com/images/pause.png";iconStop.shadow="http://labs.google.com/ridefinder/images/mm_20_shadow.png";iconStop.iconSize=new google.maps.Size(21,34);iconStop.shadowSize=new google.maps.Size(22,20);iconStop.iconAnchor=new google.maps.Point(10,34);
iconStop.infoWindowAnchor=new google.maps.Point(5,1);function friends_to_map(){if(typeof friendKML=="undefined")friendKML=new google.maps.GeoXml("http://www.triphopping.com/friendKML.php?friendType=all&n="+tripUsername);map.addOverlay(friendKML)}function TextualZoomControl(){}TextualZoomControl.prototype=new google.maps.Control;
TextualZoomControl.prototype.initialize=function(c){var b=document.createElement("div");if(coorFrom){var d=document.createElement("div");this.setButtonStyle_(d);b.appendChild(d);d.appendChild(document.createTextNode("Zoom to "+cityFrom));google.maps.Event.addDomListener(d,"click",function(){c.setCenter(new google.maps.LatLng(latFrom,lngFrom),11)})}if(coorTo){d=document.createElement("div");this.setButtonStyle_(d);b.appendChild(d);d.appendChild(document.createTextNode(cityTo));google.maps.Event.addDomListener(d,
"click",function(){c.setCenter(new google.maps.LatLng(latTo,lngTo),11)})}if(tripUsername!=""){friendsLayerVisible=false;friendOverlay=document.createElement("div");this.setButtonStyle_(friendOverlay);friendOverlay.style.fontWeight="normal";b.appendChild(friendOverlay);friendOverlay.appendChild(document.createTextNode("Friends"));google.maps.Event.addDomListener(friendOverlay,"click",function(){if(friendsLayerVisible==false){friends_to_map();friendsLayerVisible=true;this.style.fontWeight="bold"}else{friendsLayerVisible=
false;this.style.fontWeight="normal";c.removeOverlay(friendKML)}});justYouVisible=false;justYouDiv=document.createElement("div");this.setButtonStyle_(justYouDiv);justYouDiv.style.fontWeight="normal";b.appendChild(justYouDiv);justYouDiv.appendChild(document.createTextNode("You"));google.maps.Event.addDomListener(justYouDiv,"click",function(){if(justYouVisible==false){if(typeof youKML=="undefined"){youKML=new google.maps.GeoXml("http://www.triphopping.com/userKML.php?n="+tripUsername);youLineKML=new google.maps.GeoXml("http://www.triphopping.com/userLineKML.php?n="+
tripUsername)}c.addOverlay(youKML);c.addOverlay(youLineKML);justYouVisible=true;this.style.fontWeight="bold"}else{justYouVisible=false;this.style.fontWeight="normal";c.removeOverlay(youKML);c.removeOverlay(youLineKML)}})}c.getContainer().appendChild(b);return b};TextualZoomControl.prototype.getDefaultPosition=function(){return new google.maps.ControlPosition(G_ANCHOR_TOP_RIGHT,new google.maps.Size(180,3))};
TextualZoomControl.prototype.setButtonStyle_=function(c){c.style.color="#0000cc";c.style.backgroundColor="white";c.style.font=".8em Arial";c.style.border="1px solid black";c.style.padding="2px";c.style.marginBottom="0px";c.style.textAlign="center";c.style.width="58px";c.style.cursor="pointer";c.style.cssFloat="left"};var timer,chosen=[],layers=[{name:"Pano",obj:new GLayer("com.panoramio.all")},{name:"Tube",obj:new GLayer("com.youtube.all")},{name:"Wiki",obj:new GLayer("org.wikipedia.en")}];
function hideAll(){for(var c=document.getElementsByName("mark"),b=0;b<c.length;b++)if(c[b].checked){c[b].checked=false;switchLayer(false,layers[b].obj);chosen.push(b)}}function checkChecked(){for(var c=document.getElementsByName("mark"),b=0;b<c.length;b++)if(c[b].checked)return true;return false}
function switchLayer(c,b){var d=document.getElementById("box"),e=document.getElementById("boxlink"),f=document.getElementById("more_inner");if(c){map.addOverlay(b);chosen.length=0;e.className="highlight";d.className="highlight";f.className="highlight"}else{map.removeOverlay(b);if(!checkChecked()){e.blur();e.className="";d.className="";f.className=""}}}
function showLayerbox(){var c=document.getElementById("box");(new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(90,25))).apply(c);window.timer&&clearTimeout(timer);c.style.display="block"}function setClose(c){if(!c)c=window.event;var b=document.getElementById("box");if(checkMouseLeave(b,c))timer=window.setTimeout(function(){b.style.display="none"},400)}
function checkMouseLeave(c,b){if(c.contains&&b.toElement)return!c.contains(b.toElement);else if(b.relatedTarget)return!containsDOM(c,b.relatedTarget)}function containsDOM(c,b){var d=false;do{if(d=c==b)break;b=b.parentNode}while(b!=null);return d}function toggleLayers(){if(chosen.length>0)for(var c=chosen.slice(),b=0;b<c.length;b++){var d=parseInt(c[b]);switchLayer(true,layers[d].obj);document.getElementsByName("mark")[d].checked=true}else hideAll()}function MoreControl(){}MoreControl.prototype=new GControl;
MoreControl.prototype.initialize=function(c){var b=document.createElement("div");b.style.border="1px solid black";b.title="Show/Hide Layers";var d=document.createElement("div");d.id="more_inner";d.appendChild(document.createTextNode("More..."));b.appendChild(d);b.onmouseover=showLayerbox;b.onmouseout=setClose;b.onclick=toggleLayers;c.getContainer().appendChild(b);return b};MoreControl.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(90,7))};
var map,geocoder;function searchGooglebar(c){if($(":0:inputId")){$(":0:inputId").value=c;$(":0:buttonId").click()}}function clearGooglebar(){searchGooglebar(" ")}
function oonLoad(){var c={googleBarOptions:{style:"new",adsOptions:{client:"partner-pub-2873728022126830",channel:"5772561365",adsafe:"high",language:"en"},searchFormHint:"local search...",onSearchCompleteCallback:function(b){var d="<span></span>";b=b.results;for(i=0;i<b.length;i++)d+='<p><a href="'+b[i].url+'">'+b[i].titleNoFormatting+"</a><br />"+b[i].streetAddress+"</p>";$("stay_results").innerHTML=d}}};map=new google.maps.Map2($("map"),c);map.setCenter(new google.maps.LatLng(35.493138,-97.459141),
3);map.enableDoubleClickZoom();map.enableContinuousZoom();map.addControl(new google.maps.LargeMapControl3D);map.addControl(new google.maps.ScaleControl,new google.maps.ControlPosition(G_ANCHOR_BOTTOM_RIGHT,new google.maps.Size(10,10)));map.addControl(new TextualZoomControl);map.addMapType(G_SATELLITE_3D_MAP);map.addMapType(G_PHYSICAL_MAP);map.addControl(new GMenuMapTypeControl);map.addControl(new MoreControl);map.getContainer().appendChild(document.getElementById("box"));if(google.loader.ClientLocation&&
$("origin").value==""){ipCity=google.loader.ClientLocation.address.city;ipRegion=google.loader.ClientLocation.address.region;ipCountry=google.loader.ClientLocation.address.country;ipVis=ipCity+", "+ipRegion+", "+ipCountry;$("origin").value=ipVis;map.setCenter(new google.maps.LatLng(google.loader.ClientLocation.latitude,google.loader.ClientLocation.longitude),6)}map.enableGoogleBar();(new google.maps.AdsManager(map,"ca-pub-2873728022126830")).enable();contextmenu=document.createElement("div");contextmenu.style.visibility=
"hidden";contextmenu.style.background="#ffffff";contextmenu.style.border="1px solid #8888FF";contextmenu.className="contextmenu";contextDefault='<a href="javascript:reverseit(\'end\', clickedPixel)">Travel To</a><br /><a href="javascript:reverseit(\'start\', clickedPixel)">Travel From</a><br /><a href="javascript:zoomInHere()">Zoom In</a><br /><a href="javascript:addHitchhikingSpot()">Add Hitchhiking Spot</a><br /><a href="javascript:addStaySpot()">Add place to stay (like a campsite)</a><br />';contextmenu.innerHTML=
contextDefault;map.getContainer().appendChild(contextmenu);google.maps.Event.addListener(map,"singlerightclick",function(b,d){clickedPixel=b;d=b.x;b=b.y;if(d>map.getSize().width-200)d=map.getSize().width-200;if(b>map.getSize().height-100)b=map.getSize().height-100;(new google.maps.ControlPosition(G_ANCHOR_TOP_LEFT,new google.maps.Size(d,b))).apply(contextmenu);contextmenu.innerHTML=contextDefault;latlngClick=map.fromContainerPixelToLatLng(clickedPixel);geocoder.getLocations(latlngClick,function(e){if(e.Status.code!=
200)alert("reverse geocoder failed to find an address for "+latlngClick.toUrlValue());else{structureAd=e.Placemark[0];structureClick=structureAd.address;directionsClick=new google.maps.Directions;directionsClick.load(structureFrom+" to "+structureClick,{getPolyline:true,getSteps:true});google.maps.Event.addListener(directionsClick,"load",function(){contextmenu.innerHTML=contextDefault+"<br /><strong>"+structureClick+"</strong><br /><span class='simpetext'>"+directionsClick.getDistance().html+" from "+
structureFrom+" ("+directionsClick.getDuration().html+")</span>"})}});contextmenu.style.visibility="visible"});google.maps.Event.addListener(map,"click",function(){contextmenu.style.visibility="hidden"});mapLoaded=true}
function reverseit(c,b){if(mapLoaded==true){if(c=="start"){if(typeof b=="undefined")latlng=new google.maps.LatLng(startMarker.getPoint().lat(),startMarker.getPoint().lng());else{contextmenu.style.visibility="hidden";latlng=map.fromContainerPixelToLatLng(b)}locBox=$("origin")}else{if(typeof b=="undefined")latlng=new google.maps.LatLng(endMarker.getPoint().lat(),endMarker.getPoint().lng());else{contextmenu.style.visibility="hidden";latlng=map.fromContainerPixelToLatLng(b)}locBox=$("destination")}geocoder.getLocations(latlng,
function(d){if(d.Status.code!=200)alert("reverse geocoder failed to find an address for "+latlng.toUrlValue());else{address=d.Placemark[0];locBox.value=address.address;showLocation()}})}}
function addHitchhikingSpot(){contextmenu.style.visibility="hidden";var c=map.fromContainerPixelToLatLng(clickedPixel);postGeoSuccess=function(){var b=new Date;thisMonthNum=b.getMonth();dateMonthSelect='<select name="month_there" id="month_there">';var d=[],e=[];d[0]="January";d[1]="February";d[2]="March";d[3]="April";d[4]="May";d[5]="June";d[6]="July";d[7]="August";d[8]="September";d[9]="October";d[10]="November";d[11]="December";e[0]="01";e[1]="02";e[2]="03";e[3]="04";e[4]="05";e[5]="06";e[6]="07";
e[7]="08";e[8]="09";e[9]="10";e[10]="11";e[11]="12";for(i=0;i<12;i++){select="";if(i==thisMonthNum)select=' selected="selected"';dateMonthSelect+='<option value="'+e[i]+'"'+select+">"+d[i]+"</option>"}dateMonthSelect+="</select>";thisYear=b.getFullYear();lastYear=thisYear-1;dateYearSelect='<select name="year_there" id="year_there"><option selected="selected">'+thisYear+"</option>";for(i=lastYear;i>1900;i--)dateYearSelect+="<option>"+i+"</option>";dateYearSelect+="</select>";hitchWindowContent='<div id="hitchSpotAdd"><form name="hitchhiking_spots_form" id="hitchhiking_spots_form" action="/homeFunctions.php" onsubmit="advAJAX(\'/homeFunctions?\' + $(\'hitchhiking_spots_form\').serialize(), \'hitchSpotAdd\'); return false;">Rate this spot: <select name="spot_rating" id="spot_rating"><option value="0">DANGER!</option><option value="1">Negative</option><option value="2" selected="selected">OK</option><option value="3">Positive</option></select><br />Your experience: <select name="experience" id="experience"><option selected="selected">I hitchhiked from here!</option><option>I picked someone up here</option><option>I heard about it or saw someone here</option><option>Just a hunch</option></select><br />Time experienced:'+
dateMonthSelect+dateYearSelect+'<span class="simpetext">optional</span><br />Spot Type: <select name="spot_type" id="spot_type"><option>Freeway Shoulder</option><option selected="selected">Ramp</option><option>Gas Station or Truck Stop</option></select><br /><textarea name="spot_description" id="spot_description" cols="30" rows="4"></textarea><br /><div style="display:none"><input type="text" name="place" value="'+placeName+'" /><br /><input type="text" name="lat" value="'+lat+'" /><br /><input type="text" name="lng" value="'+
lng+'" /><br /><input type="text" name="city" value="'+city+'" /><br /><input type="text" name="state" value="'+state+'" /><br /><input type="text" name="country" value="'+country+'" /><br /></div><input type="submit" name="button" id="button" value="Add This Spot!" onclick="this.style.display=\'none\'; $(\'hitchSpin\').style.display=\'block\';" /><span id="hitchSpin" style="display:none"><img src="/images/loading.gif" /></span><input type="hidden" name="MM_insert" value="hitchhiking_spots_form" /></form></div>';
map.openInfoWindow(c,hitchWindowContent)};geocoder.getLocations(c,parseGeocode)}function addStaySpot(){contextmenu.style.visibility="hidden";var c=map.fromContainerPixelToLatLng(clickedPixel);map.openInfoWindow(c,"<div id='mapStayAdd' style='height:200px'>loading...</div>");advAJAX("/neededHead?draw=drawAddStay&ref=map&addy="+c,"mapStayAdd")}function zoomInHere(){contextmenu.style.visibility="hidden";var c=map.fromContainerPixelToLatLng(clickedPixel);map.zoomIn(c,true)}
function attachInfoWindow(c,b){GEvent.addListener(c,"click",function(){c.openInfoWindowHtml(b)})}
function grabWeatherAddToMap(c){var b=c[p].lat,d=c[p].lng,e=new google.feeds.Feed("http://weather.yahooapis.com/forecastrss?p="+c[p].zip_code);e.setResultFormat(google.feeds.Feed.XML_FORMAT);e.load(function(f){if(!f.error){f=f.xmlDocument.getElementsByTagName("item");for(var g=0;g<f.length;g++){var k=f[g].getElementsByTagName("title")[0].firstChild.nodeValue,j=f[g].getElementsByTagName("description")[0].firstChild.nodeValue;k=k+"<br />"+j;j=j.split('img src="')[1].split(".gif")[0]+".gif";weatherIcon=
new google.maps.Icon;weatherIcon.image=j;weatherIcon.shadow="images/friend_map_shadow.png";weatherIcon.iconSize=new google.maps.Size(26,26);weatherIcon.shadowSize=new google.maps.Size(26,26);weatherIcon.iconAnchor=new google.maps.Point(13,13);weatherIcon.infoWindowAnchor=new google.maps.Point(5,1);j=new google.maps.LatLng(b,d);weatherMarker[p]=new google.maps.Marker(j,{icon:weatherIcon});map.addOverlay(weatherMarker[p]);attachInfoWindow(weatherMarker[p],k)}}p++;p<c.length&&grabWeatherAddToMap(c)})}
function directionsLoad(c){if(c=="latlong"){latlngFrom=new google.maps.LatLng(startMarker.getPoint().lat(),startMarker.getPoint().lng());latlngTo=new google.maps.LatLng(endMarker.getPoint().lat(),endMarker.getPoint().lng());geocoder.getLocations(latlngFrom,function(b){if(b.Status.code!=200)alert("reverse geocoder failed to find an address for "+latlngFrom.toUrlValue());else structureFrom=b.Placemark[0]});geocoder.getLocations(latlngTo,function(b){if(b.Status.code!=200)alert("reverse geocoder failed to find an address for "+
latlngTo.toUrlValue());else structureTo=b.Placemark[0]})}routeBox=$("dirBox");directions=new google.maps.Directions;directions.load(structureFrom+" to "+structureTo,{getPolyline:true,getSteps:true});google.maps.Event.addListener(directions,"load",function(){var b=directions.getPolyline();midPointNum=Math.round(b.getVertexCount()/2);midPoint=b.getVertex(midPointNum);midPoints=Array();vertexCount=5;for(v=0;vertexCount<b.getVertexCount();v++){midPoints[v]=b.getVertex(vertexCount);vertexCount+=500}midPoints!=
""&&new multiGeocode(midPoints,function(e){weatherMarker=Array();p=0;grabWeatherAddToMap(e);jQuery.getScript("http://www.automotive.com/gas-prices/gaspricewidgetfeed.html?zip="+e[0].zip_code,function(){var f=$("spPrice").innerHTML;f=parseFloat(f.substr(1));f=directions.getDistance().meters/1609.344/25*f;f=Math.round(f);$("total_gas_price").innerHTML="$"+f})});b.weight=10;map.addOverlay(b);b=directions.getBounds();map.setCenter(b.getCenter(),map.getBoundsZoomLevel(b));b="";for(x=0;x<directions.getRoute(0).getNumSteps();x+=
1)b=b+directions.getRoute(0).getStep(x).getDescriptionHtml()+"<br />";$("dirBox").innerHTML=b;b=$("directionsLink");var d=$("distanceData");b.innerHTML="Directions <span class='simpetext'>"+directions.getDistance().html+" ("+directions.getDuration().html+")</span>";d.innerHTML=directions.getDistance().html+" ("+directions.getDuration().html+")"})}
function addStartEndMarkers(){mapLoaded=false;directionsLoad("place");if(typeof latFrom!="undefined"){var c=tripStartIcon,b=new google.maps.LatLng(latFrom,lngFrom);startMarker=new google.maps.Marker(b,{icon:c,draggable:true});map.addOverlay(startMarker);google.maps.Event.addListener(startMarker,"click",function(){map.setCenter(new google.maps.LatLng(latFrom,lngFrom),11);startMarker.openInfoWindowHtml(cityFrom)});google.maps.Event.addListener(startMarker,"dragstart",function(){map.closeInfoWindow()});
google.maps.Event.addListener(startMarker,"dragend",function(){reverseit("start")})}if(typeof latTo!="undefined"&&latTo!=""){c=tripEndIcon;var d=new google.maps.LatLng(latTo,lngTo);endMarker=new google.maps.Marker(d,{icon:c,draggable:true});map.addOverlay(endMarker);c=map.getBounds();c.extend(b);c.extend(d);map.setCenter(c.getCenter(),map.getBoundsZoomLevel(c));google.maps.Event.addListener(endMarker,"click",function(){map.setCenter(new google.maps.LatLng(latTo,lngTo),11);endMarker.openInfoWindowHtml(cityTo)});
google.maps.Event.addListener(endMarker,"dragstart",function(){map.closeInfoWindow()});google.maps.Event.addListener(endMarker,"dragend",function(){reverseit("end")})}mapLoaded=true}function createRegMarker(c,b,d){var e=new google.maps.Marker(c,d);google.maps.Event.addListener(e,"click",function(){e.openInfoWindowHtml(b)});return e}
function createLocationMarker(c,b,d,e){var f=new LabeledMarker(c,{icon:d,labelText:e,labelOffset:new google.maps.Size(-4,-30)});google.maps.Event.addListener(f,"click",function(){f.openInfoWindowHtml(b)});google.maps.Event.addListener(f,"mouseover",function(){f.openInfoWindowHtml(b)});return f}
function createYouMarker(c,b,d,e,f){youMarker[e]=new LabeledMarker(c,{icon:d,labelText:f,labelOffset:new google.maps.Size(-4,-30)});youMarker[e].mycategory="userYou";var g=youMarker[e];google.maps.Event.addListener(g,"click",function(){g.openInfoWindowHtml(b)});google.maps.Event.addListener(g,"mouseover",function(){g.openInfoWindowHtml(b)});return youMarker[e]}
function ridesToMap(){var c=new google.maps.Icon;c.image="http://triphopping.com/images/ride_end.png";c.shadow="http://labs.google.com/ridefinder/images/mm_20_shadow.png";c.iconSize=new google.maps.Size(16,16);c.shadowSize=new google.maps.Size(22,20);c.iconAnchor=new google.maps.Point(8,8);c.infoWindowAnchor=new google.maps.Point(5,1);var b=new google.maps.Icon;b.image="http://triphopping.com/images/pause.png";b.shadow="http://labs.google.com/ridefinder/images/mm_20_shadow.png";b.iconSize=new google.maps.Size(21,
34);b.shadowSize=new google.maps.Size(22,20);var d=new google.maps.Icon;d.image="http://triphopping.com/images/car.png";d.shadow="http://labs.google.com/ridefinder/images/mm_20_shadow.png";d.iconSize=new google.maps.Size(16,16);d.shadowSize=new google.maps.Size(22,20);d.iconAnchor=new google.maps.Point(8,8);d.infoWindowAnchor=new google.maps.Point(5,1);var e=new google.maps.Icon;e.image="http://triphopping.com/images/thumb_up.png";e.shadow="http://labs.google.com/ridefinder/images/mm_20_shadow.png";
e.iconSize=new google.maps.Size(16,16);e.shadowSize=new google.maps.Size(22,20);e.iconAnchor=new google.maps.Point(8,8);e.infoWindowAnchor=new google.maps.Point(5,1);b.iconAnchor=new google.maps.Point(10,34);b.infoWindowAnchor=new google.maps.Point(5,1);rideDirections=[];for(b=0;b<rideInfo.length;b++){if(rideInfo[b].type=="offer")var f="#009900",g=d;else{f="#ff3300";g=e}if(typeof rideInfo[b].end_lat!="undefined"&&rideInfo[b].end_lat!=""){rideDirections[b]=new google.maps.Directions;rideDirections[b].load(rideInfo[b].start_place+
" to "+rideInfo[b].end_place,{getPolyline:true,getSteps:true});google.maps.Event.addListener(rideDirections[b],"load",function(j,l){return function(m){try{rideDirections[j].getPolyline().color=l;map.addOverlay(rideDirections[j].getPolyline())}catch(r){}}}(b,f));google.maps.Event.addListener(rideDirections[b],"error",function(){})}f='<a href="#/people/'+rideInfo[b].username+'" onclick="loadProfile(\''+rideInfo[b].username+'\')"><img src="'+rideInfo[b].pic_url+'" align="left" hspace="5px" /></a>'+rideInfo[b].type+
' <span class="startPlace">'+rideInfo[b].start_place+'</span> to <span class="endPlace">'+rideInfo[b].end_place+"</span><br>Leaving on: <strong>"+rideInfo[b].leave_date+'</strong><br>posted by: <a href="#/people/'+rideInfo[b].username+'" onclick="loadProfile(\''+rideInfo[b].username+"')\">"+rideInfo[b].name+"</a><br>Your cost: "+rideInfo[b].cost+' - <a href="#" onclick="rideLoad(\''+rideInfo[b].entry_id+"')\">more info&raquo;</a>";var k=new google.maps.LatLng(rideInfo[b].start_lat,rideInfo[b].start_lng);
map.addOverlay(createRegMarker(k,f,g));if(typeof rideInfo[b].end_lat!="undefined"&&rideInfo[b].end_lat!=""){g=new google.maps.LatLng(rideInfo[b].end_lat,rideInfo[b].end_lng);map.addOverlay(createRegMarker(g,f,c))}}}
function flashLines(c){var b=rideInfo[c].type=="offer"?"#009900":"#ff3300";map.removeOverlay(rideDirections[c].getPolyline());rideDirections[c].getPolyline().color="#000";map.addOverlay(rideDirections[c].getPolyline());window.setTimeout(function(){map.removeOverlay(rideDirections[c].getPolyline());rideDirections[c].getPolyline().color=b;map.addOverlay(rideDirections[c].getPolyline())},300)}function greyLocation(c,b){currentGHID=b;geocoder.getLocations(c,addGreyToMap)}
function addGreyToMap(c){if(!c||c.Status.code!=200)alert("Sorry, we were unable to geocode that address");else{place=c.Placemark[0];point=new google.maps.LatLng(place.Point.coordinates[1],place.Point.coordinates[0]);marker=new google.maps.Marker(point)}map.addOverlay(marker);marker.openInfoWindowHtml("<strong>Greyhound Station</strong><br />"+place.address+"<br /><a href='http://www.greyhound.com/home/TicketCenter/en/terminal.asp?city="+currentGHID+"'>More Info</a>");map.setCenter(new google.maps.LatLng(place.Point.coordinates[1],
place.Point.coordinates[0]),13)}
function showLocation(){typeof map=="undefined"&&oonLoad();if(document.mapSearchForm.origin.value!=""&&document.mapSearchForm.origin.value!="From"){x=0;address=document.mapSearchForm.origin.value;postGeoSuccess=function(){if(x!=1){structureFrom="";FromString="?style=script";structureFrom=place.address;FromString+="&structure1="+structureFrom;if(typeof streetLine!="undefined")FromString+="&address1="+streetLine;if(typeof city!="undefined"){FromString+="&city1="+city;cityFrom=city}if(typeof zip!="undefined"){FromString+=
"&zip1="+zip;zipFrom=zip}if(typeof county!="undefined"){FromString+="&county1="+county;countyFrom=county}if(typeof state!="undefined"){FromString+="&state1="+state;stateFrom=state}if(typeof country!="undefined"){FromString+="&country1="+country;countryFrom=country}if(typeof point!="undefined"){FromString+="&point1="+latlong;latFrom=place.Point.coordinates[1];lngFrom=place.Point.coordinates[0]}x=1;if(document.mapSearchForm.destination.value!=""&&document.mapSearchForm.destination.value!="To"){address=
document.mapSearchForm.destination.value;geocoder.getLocations(address,parseGeocode)}else{getString=FromString;updateTravelContent(getString)}}else{ToString=structureTo="";structureTo=place.address;ToString+="&structure2="+structureTo;if(typeof streetLine!="undefined")ToString+="&address2="+streetLine;if(typeof city!="undefined"){ToString+="&city2="+city;cityTo=city}if(typeof zip!="undefined"){ToString+="&zip2="+zip;zipTo=zip}if(typeof state!="undefined"){ToString+="&state2="+state;stateTo=state}if(typeof county!=
"undefined"){ToString+="&county2="+county;countyTo=county}if(typeof country!="undefined"){ToString+="&country2="+country;countryTo=country}if(typeof point!="undefined"){ToString+="&point2="+latlong;latTo=place.Point.coordinates[1];lngTo=place.Point.coordinates[0]}var c="http://www.triphopping.com/"+$("geoPageLink").value;getString=FromString+"&"+ToString;updateTravelContent(getString)}};lngTo=latTo=lngFrom=latFrom=structureTo=structureFrom=countryTo=countryFrom=stateTo=stateFrom=cityTo=cityFrom="";
geocoder.getLocations(address,parseGeocode)}else updateTravelContent("?style=script")}
function updateTravelContent(c,b){preLoaded=false;if(recentToggleDiv=="explore"){if(exploreLoaded==c)preLoaded=true;else{var d="/exploreContent.php"+c;mateDiv="exploreDiv";exploreLoaded=c}map.clearOverlays();map.setCenter(new google.maps.LatLng(latFrom,lngFrom),13);c=currentLocationIcon;b=new google.maps.LatLng(latFrom,lngFrom);exploreMarker=new google.maps.Marker(b,{icon:c,draggable:true});map.addOverlay(exploreMarker)}else if(recentToggleDiv=="stay"){if(stayLoaded==c)preLoaded=true;else{d="/stayContent.php"+
c;mateDiv="stayDiv";stayLoaded=c}map.clearOverlays();latTo!=""&&map.setCenter(new google.maps.LatLng(latTo,lngTo),13)}else{map.clearOverlays();if(travelLoaded==c){preLoaded=true;mainTabs("travelLink","travel");ridesToMap();addStartEndMarkers()}else{d="/travelContent.php"+c;mateDiv="travelInfo";travelLoaded=c}}travelURL=d=d+"&sid="+Math.random();if(preLoaded!=true){$(mateDiv).innerHTML='<img src="/images/earth_spin.gif" /> ah, travel...';$("alertBorder").className="alertBorderLoading";$("taskStatus").innerHTML=
"loading...";$("taskStatus").style.display="inline";if(recentToggleDiv!="travel"&&recentToggleDiv!="explore"&&recentToggleDiv!="stay"){recentToggleLink="travelLink";recentToggleDiv="travel"}mainTabs(recentToggleLink,recentToggleDiv);new Ajax.Request(d,{onSuccess:function(e){updatedResult=e.responseText;javaHtmlSplit=updatedResult.split("####ride javascript####");if(javaHtmlSplit[0]!="")$(mateDiv).innerHTML=javaHtmlSplit[0];else $(mateDiv).innerHTML=updatedResult;sizeMap();if(recentToggleDiv=="travel"){$("optionContainer").show();
latFrom&&latTo&&jQuery("#gas_and_directions").show();map.clearOverlays();if(latFrom||latTo){rideInfo=null;rideInfo=[];e="ride_xml?lat_from="+latFrom+"&lng_from="+lngFrom;if(latTo)e+="&lat_to="+latTo+"&lng_to="+lngTo;jQuery.get(e,{},function(f){var g=0;jQuery("ride",f).each(function(k){k=jQuery(this).find("entry_id").text();rideInfo[g]={start_lat:jQuery(this).find("start_lat").text(),start_lng:jQuery(this).find("start_lng").text(),end_lat:jQuery(this).find("end_lat").text(),end_lng:jQuery(this).find("end_lng").text(),
start_place:jQuery(this).find("start_place").text(),end_place:jQuery(this).find("end_place").text(),start_city:jQuery(this).find("start_city").text(),end_city:jQuery(this).find("end_city").text(),start_state:jQuery(this).find("start_state").text(),end_state:jQuery(this).find("end_state").text(),leave_date:jQuery(this).find("leave_date").text(),username:jQuery(this).find("username").text(),name:jQuery(this).find("name").text(),pic_url:jQuery(this).find("pic_url").text(),cost:jQuery(this).find("cost").text(),
entry_id:jQuery(this).find("entry_id").text(),type:jQuery(this).find("type").text(),mpg:jQuery(this).find("mpg").text()};g+=1});ridesToMap();addStartEndMarkers()});for(x=1;x<javaHtmlSplit.length;x++)eval(javaHtmlSplit[x]);entriesShown=20;externalRidesTest($("newIdea"));GSCLoad(structureFrom+" to "+structureTo,"travel");new Ajax.Request("/expediaJavascript.php"+getString,{onSuccess:function(f){eval(f.responseText)}})}}else if(recentToggleDiv=="stay"){if(latTo!=""){searchGooglebar("hotels OR hostels");
GSCLoad(structureTo,"stay");new Ajax.Request("/expediaJavascript.php"+getString+"&dealType=hotel",{onSuccess:function(f){eval(f.responseText)}});showStaySpots(latTo,lngTo,100)}}else if(recentToggleDiv=="explore"){csGroups($("csSelect").value,$("CS_group_content"),30);e=[];e[0]=latFrom+","+lngFrom;new multiGeocode(e,function(f){f=new google.feeds.Feed("http://weather.yahooapis.com/forecastrss?p="+f[0].zip_code);f.setResultFormat(google.feeds.Feed.XML_FORMAT);f.load(function(g){if(!g.error){g=g.xmlDocument.getElementsByTagName("item");
for(var k=0;k<g.length;k++){var j=g[k].getElementsByTagName("title")[0].firstChild.nodeValue,l=g[k].getElementsByTagName("description")[0].firstChild.nodeValue;j=j+"<br />"+l;l=l.split('img src="')[1].split(".gif")[0]+".gif";j=l='<img src="'+l+'" />';$("exploreWeather").innerHTML=l}}})})}$("alertBorder").className="alertBorderFinish";$("taskStatus").innerHTML="Finished!";setTimeout("$('alertBorder').className = 'alertBorder'; $('taskStatus').style.display='none'",100)}})}}
function travel(c,b){if(c!="current")document.mapSearchForm.origin.value=c;if(typeof b!="undefined"){location.hash="travel/"+c+"/"+b;document.mapSearchForm.destination.value=b}else location.hash="travel/"+c;mainTabs("travelLink","travel");showLocation()}function explore(c){$("origin").value=c;if(!$("origin").value)$("origin").value=c;mainTabs("exploreLink","explore");showLocation()}
function stay(c){$("destination").value=c;if(!$("origin").value)$("origin").value=c;mainTabs("stayLink","stay");showLocation()}
function addHubToList(){var c=$("route_list"),b=document.createElement("div");b.innerHTML='<table style="background-color:#fff; border:1px solid #a5c98b; display:block; margin-top:11px"><tr><td><span class="form_items">Name</span><br /><input name="station_name[]" type="text" size="20" onkeypress="return handleEnter(this, event)" /><br /><span class="simpetext">"Grand Central"</span></td><td><span class="form_items">Address *</span><br /><input name="station_address[]" type="text" size="35" onkeypress="return handleEnter(this, event)" /><br /><span class="simpetext">"15 Vanderbilt Ave, New York, NY"</span></td></tr><tr><td colspan=2><span class="form_items" style="color:#4d7f5d">URL Value</span>: <input name="URL_value[]" type="text" size="10" onkeypress="return handleEnter(this, event)" />\t<span class="simpetext">"New York, NY"</span><input type="hidden" name="station_street[]" /><input type="hidden" name="station_city[]" /><input type="hidden" name="station_state[]" /><input type="hidden" name="station_country[]" /><input type="hidden" name="station_lat[]" /><input type="hidden" name="station_lng[]" /><input type="hidden" name="station_id[]" /></td></tr><tr><td></td></tr></table><a href="#" onclick="$(this).previous(0).innerHTML=\'\'; $(this).hide()">remove</a>';c.appendChild(b)}
function displayRoutes(){var c="",b=document.getElementsByName("station_name[]"),d=document.getElementsByName("station_address[]"),e=document.getElementsByName("URL_value[]"),f=document.getElementsByName("station_street[]"),g=document.getElementsByName("station_city[]"),k=document.getElementsByName("station_state[]"),j=document.getElementsByName("station_country[]"),l=document.getElementsByName("station_lat[]"),m=document.getElementsByName("station_lng[]");e=document.getElementsByName("station_ID[]");
addysToGeo=[];for(h=0;h<d.length;h++)addysToGeo[h]=d[h].value;new multiGeocode(addysToGeo,function(r){x=0;r.each(function(n){f[x].value=n.street_address;g[x].value=n.city;k[x].value=n.state;j[x].value=n.country;l[x].value=n.lat;m[x].value=n.lng;x++});new Ajax.Request("/neededHead?function=add_hubs&c_id="+$("company_select").value,{onSuccess:function(n){eval(n.responseText)}});for(i=0;i<b.length;i++)for(x=i+1;x<b.length;x++)c+="<table><tr><td><strong>"+b[i].value+'</strong><br /><span class="simpetext">'+
g[i].value+", "+k[i].value+"</span></td><td><></td><td><strong>"+b[x].value+'</strong><br /><span class="simpetext">'+g[x].value+", "+k[x].value+'</span></td></tr><tr><td colspan=3><span class="form_items">Cost one way: </span><input name="cost_ow[]" type="text" size="8" /> <span class="form_items">Cost roundtrip: </span><input name="cost_rt[]" type="text" size="8" /></td></tr></table><a href="#" onclick="$(this).previous(0).innerHTML=\'\'; $(this).hide()">remove route</a><br /><br />';$("routeList").innerHTML=
c})}function IsNumeric(c){var b=true,d;for(i=0;i<c.length&&b==true;i++){d=c.charAt(i);if("0123456789".indexOf(d)==-1)b=false}return b}function clearTextBox(c){document.getElementById(c).value=""}function defaultSubmit(c,b){if(c.keyCode==13){c.keyCode=null;window.document.getElementById(b).click()}return true}
function automotiveRedirect(c){c=document.getElementById(c).value;window.open=IsNumeric(c)?"http://www.automotive.com/gas-prices/results.html?zip="+c:"http://www.automotive.com/gas-prices/index.html"};