function addEvent(d,c,a){if(d.addEventListener){d.addEventListener(c,a,false);return true}else{if(d.attachEvent){var b=d.attachEvent("on"+c,a);return b}else{return false}}}addEvent(window,"load",loadMap);function loadMap(){if(GBrowserIsCompatible()){if(MSFLEET){MSFLEET.initMap()}}else{alert("Sorry, the Google Maps API is not compatible with this browser")}document.getElementById("maphelp").style.display="none";var a=document.getElementById("helpopen");addEvent(a,"click",function(){var d=document.getElementById("maphelp");d.style.display="block"});var c=document.getElementById("helpclose");addEvent(c,"click",function(){var d=document.getElementById("maphelp");d.style.display="none"});var b=document.getElementById("helpclose2");addEvent(b,"click",function(){var d=document.getElementById("maphelp");d.style.display="none"})}var isIE=0;if(navigator.appName=="Microsoft Internet Explorer"){isIE=1}var MSFLEET=function(){msfleet=this;msfleet.map_div="map";msfleet.x_y_ratio=5/4;msfleet.min_resolution=3;msfleet.max_resolution=17;msfleet.start_center_lat=45;msfleet.start_center_lng=-94;msfleet.start_map_zoom=3;msfleet.cgi_link=location.protocol+"//"+location.host+"/cgi-bin/truck_stop_map_inquiry.cgi?";msfleet.image_link=location.protocol+"//"+location.host+"/images/application/fleetmaps/lib/";msfleet.icon_zoom=13;msfleet.icon_zoom_grp1=6;msfleet.icon_zoom_grp2=13;msfleet.vcard_html={start:"<div class='vcard'>",image:"<img src='"+image_link+"blue-18x18.png' height='18' width='18'>",startlabel:"<div class='fn org'>",endlabel:"</div>",startadr:"<div class='adr'>",startstreet:"<div class='street-address'>",endstreet:"</div>",startcity:"<div><span class='locality'>",endcity:"</span>, ",startstate:"<span class='region'>",endstate:"</span></div>",endadr:"</div>",startlink:"<div class='zoomlink'>",endlink:"</div>",startphone:"<div class='tel'><span class='work'>TEL:</span><span class='value'>",endphone:"</span></div>",end:"</div>"};msfleet.list_html={start:"<div class='locationlist'><p>Stops at this location:</p><ul>",startloc:"<li class='locationlink'>",starthref:"<a id='location-",middlehref:"' href='' onclick='MSFLEET.showLocation(",endhref:"); return false;'>",closehref:"</a>",closeloc:"</li>",close:"</ul></div>"};msfleet.amenity_html={startamenities:"<div class='amenities'><div class='amenities heading'>Services:</div><div>",startamenity:"<span class='amenity'>",closeamenity:"</span> ",closeamenities:"</div></div>",startparking:"<div class='parking'><div class='parking heading'>Parking:</div><div>",closeparking:"</div></div>"};msfleet.group_html={startgroup:"<p style='font: 1em arial,helvetica,sans-serif;'><b>",endgroup:"</b> locations in this area</p>"};function getMarkers(){for(i=0;i<msfleet.gmarkers.length;i++){msfleet.map.removeOverlay(msfleet.gmarkers[i])}msfleet.gmarkers.splice(0,msfleet.gmarkers.length);var size=msfleet.map.getSize();var bounds=msfleet.map.getBounds();var southWest=bounds.getSouthWest();var northEast=bounds.getNorthEast();ne_x=northEast.lng();ne_y=northEast.lat();sw_x=southWest.lng();sw_y=southWest.lat();level=msfleet.map.getZoom();reduce_px=document.getElementById("reduce_px").value;var link=msfleet.cgi_link+"ne_x="+ne_x+"&ne_y="+ne_y+"&sw_x="+sw_x+"&sw_y="+sw_y+"&level="+level+"&x_y_ratio="+x_y_ratio+"&px="+size.width+"&py="+size.height+"&reduce_px="+reduce_px;GDownloadUrl(link,function(doc){var link_results=parseJSON(doc);var debug_text="";for(var i in link_results){if(i!="locations"){debug_text+=i+": "+link_results[i]+"<br>\n"}}if((link_results==undefined)||(link_results.locations==null)){return}for(var i=0;i<link_results.locations.length;i++){var marker;locations_count=link_results.locations[i].count;if(locations_count==1){marker=createSingleMarker(link_results.locations[i])}else{if(locations_count<9){marker=createListMarker(link_results.locations[i])}else{marker=createGroupMarker(link_results.locations[i])}}msfleet.gmarkers.push(marker);msfleet.map.addOverlay(marker)}})}function createListMarker(result_location){var lat=parseFloat(result_location.lat);var lng=parseFloat(result_location.lng);var point=new GLatLng(lat,lng);var locations_count=result_location.count;var locations_id=result_location.id;var level=msfleet.map.getZoom();var icon=msfleet.ms_group_sma;opts={icon:icon,clickable:true,labelText:locations_count,labelClass:"countstyle",labelOffset:icon.labelOffset};var marker=new LabeledMarker(point,opts);marker.locations_id=locations_id;GEvent.addListener(marker,"click",function(){var link=msfleet.cgi_link+"parent="+marker.locations_id;GDownloadUrl(link,function(data,responseCode){var link_results=parseJSON(data);if(link_results.locations==null){return}var list=msfleet.list_html.start;for(var i=0;i<link_results.locations.length;i++){list=list+msfleet.list_html.startloc;list_link=msfleet.list_html.starthref+link_results.locations[i].id+msfleet.list_html.middlehref+link_results.locations[i].id+msfleet.list_html.endhref+link_results.locations[i].name+msfleet.list_html.closehref;list=list+list_link+msfleet.list_html.closeloc}list=list+msfleet.list_html.close;msfleet.map.movetype="windowpan";marker.openInfoWindow(list)})});GEvent.addListener(marker,"dblclick",function(){msfleet.map.setCenter(point,msfleet.map.getZoom()+1,msfleet.map.getCurrentMapType())});GEvent.addListener(marker,"mouseover",function(){marker.setImage(marker.getIcon().imageOn)});GEvent.addListener(marker,"mouseout",function(){marker.setImage(marker.getIcon().image)});return marker}function createGroupMarker(result_location){var lat=parseFloat(result_location.lat);var lng=parseFloat(result_location.lng);var point=new GLatLng(lat,lng);var locations_count=result_location.count;var locations_id=result_location.id;var level=msfleet.map.getZoom();var icon;if(locations_count<10){icon=msfleet.ms_group_sma}else{if(locations_count<100){icon=msfleet.ms_group_med}else{icon=msfleet.ms_group_lrg}}opts={icon:icon,clickable:true,labelText:locations_count,labelClass:"countstyle",labelOffset:icon.labelOffset};var marker=new LabeledMarker(point,opts);marker.locations_id=locations_id;GEvent.addListener(marker,"click",function(){map.setCenter(point,map.getZoom()+1,map.getCurrentMapType())});GEvent.addListener(marker,"mouseover",function(count){marker.setImage(marker.getIcon().imageOn)});GEvent.addListener(marker,"mouseout",function(){marker.setImage(marker.getIcon().image)});return marker}function createSingleMarker(result_location){var lat=parseFloat(result_location.lat);var lng=parseFloat(result_location.lng);var point=new GLatLng(lat,lng);var locations_count=result_location.count;var locations_id=result_location.id;var level=msfleet.map.getZoom();var icon;if(level<msfleet.icon_zoom){icon=msfleet.ms_single}else{if(level<msfleet.icon_zoom_grp2&&level>msfleet.icon_zoom_grp1){icon=msfleet.ms_single_med}else{icon=msfleet.ms_single_lrg}}var marker=new GMarker(point,{icon:icon});marker.locations_id=locations_id;var link=cgi_link+"location="+marker.locations_id;GEvent.addListener(marker,"click",function(){GDownloadUrl(link,function(data,responseCode){var link_results=parseJSON(data);var zoomlink=msfleet.vcard_html.startlink+msfleet.list_html.starthref+link_results.locations[0].id+msfleet.list_html.middlehref+link_results.locations[0].id+msfleet.list_html.endhref+"Zoom In"+msfleet.list_html.closehref+msfleet.vcard_html.endlink;var location_html=msfleet.vcard_html.start+msfleet.vcard_html.image+msfleet.vcard_html.startlabel+link_results.locations[0].label+msfleet.vcard_html.endlabel+msfleet.vcard_html.startadr+msfleet.vcard_html.startstreet+link_results.locations[0].address+msfleet.vcard_html.endstreet+msfleet.vcard_html.startcity+link_results.locations[0].city+msfleet.vcard_html.endcity+msfleet.vcard_html.startstate+link_results.locations[0].state+msfleet.vcard_html.endstate+msfleet.vcard_html.endadr+msfleet.vcard_html.startphone+link_results.locations[0].phone+msfleet.vcard_html.endphone+msfleet.vcard_html.end;var amenity=msfleet.amenity_html.startamenities;if(link_results.amenities!=null){for(var i=0;i<link_results.amenities.length;i++){if(link_results.amenities[i]!=null){amenity=amenity+msfleet.amenity_html.startamenity+link_results.amenities[i].id+msfleet.amenity_html.closeamenity}}}amenity=amenity+msfleet.amenity_html.closeamenities;var parking="";if(link_results.parking!=null){parking=msfleet.amenity_html.startparking;for(var i=0;i<link_results.parking.length;i++){if(link_results.parking[i]!=null){parking=parking+msfleet.amenity_html.startamenity+link_results.parking[i]+msfleet.amenity_html.closeamenity}}parking=parking+msfleet.amenity_html.closeparking}amenity=amenity+parking;if(level<15){location_html=location_html+zoomlink}msfleet.map.movetype="windowpan";marker.openInfoWindowHtml(location_html+amenity)})});if(level>5&&isIE==1){GEvent.addListener(marker,"mouseover",function(){marker.setImage(marker.getIcon().imageOn);GDownloadUrl(link,function(data,responseCode){var link_results=parseJSON(data);var location_html=msfleet.vcard_html.start+msfleet.vcard_html.image+msfleet.vcard_html.startlabel+link_results.locations[0].label+msfleet.vcard_html.endlabel+msfleet.vcard_html.startphone+link_results.locations[0].phone+msfleet.vcard_html.endphone+msfleet.vcard_html.end;msfleet.map.movetype="windowpan";marker.openInfoWindowHtml(location_html)});if(isIE==1){marker.timerid=setTimeout(function(){GDownloadUrl(link,function(data,responseCode){var link_results=parseJSON(data);var zoomlink=msfleet.vcard_html.startlink+msfleet.list_html.starthref+link_results.locations[0].id+msfleet.list_html.middlehref+link_results.locations[0].id+msfleet.list_html.endhref+"Zoom In"+msfleet.list_html.closehref+msfleet.vcard_html.endlink;var location_html=msfleet.vcard_html.start+msfleet.vcard_html.image+msfleet.vcard_html.startlabel+link_results.locations[0].label+msfleet.vcard_html.endlabel+msfleet.vcard_html.startadr+msfleet.vcard_html.startstreet+link_results.locations[0].address+msfleet.vcard_html.endstreet+msfleet.vcard_html.startcity+link_results.locations[0].city+msfleet.vcard_html.endcity+msfleet.vcard_html.startstate+link_results.locations[0].state+msfleet.vcard_html.endstate+msfleet.vcard_html.endadr+msfleet.vcard_html.startphone+link_results.locations[0].phone+msfleet.vcard_html.endphone+msfleet.vcard_html.end;var amenity=msfleet.amenity_html.startamenities;if(link_results.amenities!=null){for(var i=0;i<link_results.amenities.length;i++){if(link_results.amenities[i]!=null){amenity=amenity+msfleet.amenity_html.startamenity+link_results.amenities[i].id+msfleet.amenity_html.closeamenity}}}amenity=amenity+msfleet.amenity_html.closeamenities;var parking="";if(link_results.parking!=null){parking=msfleet.amenity_html.startparking;for(var i=0;i<link_results.parking.length;i++){if(link_results.parking[i]!=null){parking=parking+msfleet.amenity_html.startamenity+link_results.parking[i]+msfleet.amenity_html.closeamenity}}parking=parking+msfleet.amenity_html.closeparking}amenity=amenity+parking;if(level<15){location_html=location_html+zoomlink}msfleet.map.movetype="windowpan";marker.openInfoWindowHtml(location_html+amenity)})},3000)}});GEvent.addListener(marker,"mouseout",function(){marker.setImage(marker.getIcon().image);clearTimeout(marker.timerid)})}if(level<=5&&isIE==1){GEvent.addListener(marker,"mouseover",function(){marker.setImage(marker.getIcon().imageOn);marker.timerid=setTimeout(function(){GDownloadUrl(link,function(data,responseCode){var link_results=parseJSON(data);var zoomlink=msfleet.vcard_html.startlink+msfleet.list_html.starthref+link_results.locations[0].id+msfleet.list_html.middlehref+link_results.locations[0].id+msfleet.list_html.endhref+"Zoom In"+msfleet.list_html.closehref+msfleet.vcard_html.endlink;var location_html=msfleet.vcard_html.start+msfleet.vcard_html.image+msfleet.vcard_html.startlabel+link_results.locations[0].label+msfleet.vcard_html.endlabel+msfleet.vcard_html.startadr+msfleet.vcard_html.startstreet+link_results.locations[0].address+msfleet.vcard_html.endstreet+msfleet.vcard_html.startcity+link_results.locations[0].city+msfleet.vcard_html.endcity+msfleet.vcard_html.startstate+link_results.locations[0].state+msfleet.vcard_html.endstate+msfleet.vcard_html.endadr+msfleet.vcard_html.startphone+link_results.locations[0].phone+msfleet.vcard_html.endphone+msfleet.vcard_html.end;var amenity=msfleet.amenity_html.startamenities;if(link_results.amenities!=null){for(var i=0;i<link_results.amenities.length;i++){if(link_results.amenities[i]!=null){amenity=amenity+msfleet.amenity_html.startamenity+link_results.amenities[i].id+msfleet.amenity_html.closeamenity}}}amenity=amenity+msfleet.amenity_html.closeamenities;var parking="";if(link_results.parking!=null){parking=msfleet.amenity_html.startparking;for(var i=0;i<link_results.parking.length;i++){if(link_results.parking[i]!=null){parking=parking+msfleet.amenity_html.startamenity+link_results.parking[i]+msfleet.amenity_html.closeamenity}}parking=parking+msfleet.amenity_html.closeparking}amenity=amenity+parking;if(level<15){location_html=location_html+zoomlink}msfleet.map.movetype="windowpan";marker.openInfoWindowHtml(location_html+amenity)})},3000)});GEvent.addListener(marker,"mouseout",function(){marker.setImage(marker.getIcon().image);clearTimeout(marker.timerid)})}return marker}function showLocation(locationid){var link=msfleet.cgi_link+"location="+locationid;GDownloadUrl(link,function(data,responseCode){var link_results=parseJSON(data);if(link_results==null){return}var lat=parseFloat(link_results.locations[0].lat);var lng=parseFloat(link_results.locations[0].lng);var point=new GLatLng(lat,lng);msfleet.map.setCenter(point,15);marker=createSingleMarker(link_results.locations[0]);msfleet.map.addOverlay(marker);msfleet.gmarkers.push(marker);GEvent.trigger(marker,"click")})}function setIcons(image_link){msfleet.ms_single=new GIcon();msfleet.ms_single.image=image_link+"blue-18x18.png";msfleet.ms_single.imageOn=image_link+"red-18x18.png";msfleet.ms_single.iconSize=new GSize(18,18);msfleet.ms_single.shadow=image_link+"shadow-18x33.png";msfleet.ms_single.shadowSize=new GSize(33,18);msfleet.ms_single.iconAnchor=new GPoint(9,18);msfleet.ms_single.infoWindowAnchor=new GPoint(9,9);msfleet.ms_single_med=new GIcon();msfleet.ms_single_med.image=image_link+"blue-23x23.png";msfleet.ms_single_med.imageOn=image_link+"red-23x23.png";msfleet.ms_single_med.iconSize=new GSize(23,23);msfleet.ms_single_med.shadow=image_link+"shadow-23x42.png";msfleet.ms_single_med.shadowSize=new GSize(42,23);msfleet.ms_single_med.iconAnchor=new GPoint(11,23);msfleet.ms_single_med.infoWindowAnchor=new GPoint(11,11);msfleet.ms_single_lrg=new GIcon();msfleet.ms_single_lrg.image=image_link+"blue-33x33.png";msfleet.ms_single_lrg.imageOn=image_link+"red-33x33.png";msfleet.ms_single_lrg.iconSize=new GSize(33,33);msfleet.ms_single_lrg.shadow=image_link+"shadow-33x60.png";msfleet.ms_single_lrg.shadowSize=new GSize(60,33);msfleet.ms_single_lrg.iconAnchor=new GPoint(16,33);msfleet.ms_single_lrg.infoWindowAnchor=new GPoint(16,16);msfleet.ms_group_sma=new GIcon();msfleet.ms_group_sma.image=image_link+"blue-grp-35x32-1.png";msfleet.ms_group_sma.imageOn=image_link+"red-grp-35x32-1-on.png";msfleet.ms_group_sma.iconSize=new GSize(35,32);msfleet.ms_group_sma.shadow=image_link+"shadow-42x32.png";msfleet.ms_group_sma.shadowSize=new GSize(35,32);msfleet.ms_group_sma.iconAnchor=new GPoint(16,35);msfleet.ms_group_sma.infoWindowAnchor=new GPoint(16,17);msfleet.ms_group_sma.labelOffset=new GSize(-1,-32);msfleet.ms_group_med=new GIcon();msfleet.ms_group_med.image=image_link+"blue-grp-35x32-2.png";msfleet.ms_group_med.imageOn=image_link+"red-grp-35x32-2-on.png";msfleet.ms_group_med.iconSize=new GSize(35,32);msfleet.ms_group_med.shadow=image_link+"shadow-42x32.png";msfleet.ms_group_med.shadowSize=new GSize(35,32);msfleet.ms_group_med.iconAnchor=new GPoint(16,35);msfleet.ms_group_med.infoWindowAnchor=new GPoint(16,17);msfleet.ms_group_med.labelOffset=new GSize(-2,-32);msfleet.ms_group_lrg=new GIcon();msfleet.ms_group_lrg.image=image_link+"blue-grp-35x32-3.png";msfleet.ms_group_lrg.imageOn=image_link+"red-grp-35x32-3-on.png";msfleet.ms_group_lrg.iconSize=new GSize(35,32);msfleet.ms_group_lrg.shadow=image_link+"shadow-42x32.png";msfleet.ms_group_lrg.shadowSize=new GSize(35,32);msfleet.ms_group_lrg.iconAnchor=new GPoint(16,35);msfleet.ms_group_lrg.infoWindowAnchor=new GPoint(16,17);msfleet.ms_group_lrg.labelOffset=new GSize(-4,-32)}function parseJSON(text){var JSON_data=!(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(text.replace(/\"(\\.|[^\"\\])*\"/g,"")))&&eval("("+text+")");return JSON_data}function initMap(){setIcons(msfleet.image_link);function extendMarker(marker,html,result){var div=document.createElement("div");div.innerHTML="<br><span style='color:green'>The above links take you away from the Multi Service website.</span>";html.appendChild(div);return html}msfleet.map=new GMap2(document.getElementById(msfleet.map_div));var options={searchFormHint:"Search by City, State, or Highway",resultList:google.maps.LocalSearch.RESULT_LIST_SUPPRESS,onGenerateMarkerHtmlCallback:extendMarker,suppressInitialResultSelection:true};msfleet.map.addControl(new google.maps.LocalSearch(options));msfleet.results=document.getElementById("results");var mt=msfleet.map.getMapTypes();for(var i=0;i<mt.length;i++){mt[i].getMinimumResolution=function(){return msfleet.min_resolution};mt[i].getMaximumResolution=function(){return msfleet.max_resolution}}msfleet.map.addControl(new GLargeMapControl());msfleet.map.setCenter(new GLatLng(msfleet.start_center_lat,msfleet.start_center_lng),msfleet.start_map_zoom,G_NORMAL_MAP);msfleet.gmarkers=new Array;GEvent.addListener(msfleet.map,"moveend",function(){if(msfleet.map.movetype!="windowpan"){for(i=0;i<msfleet.gmarkers.length;i++){msfleet.map.removeOverlay(msfleet.gmarkers[i])}getMarkers(msfleet.map)}msfleet.map.movetype=""});GEvent.addListener(msfleet.map,"zoomend",function(){for(i=0;i<msfleet.gmarkers.length;i++){msfleet.map.removeOverlay(msfleet.gmarkers[i])}getMarkers(msfleet.map)});getMarkers(msfleet.map)}return{showLocation:showLocation,initMap:initMap}}();
