var rfs=["client_id","name","street","town","pc","lat","lon"];var homeGeocodeLocation;function initialiseMap(b){mapviewer=MMFactory.createViewer(document.getElementById(b));mapviewer.goToPosition(new MMLocation(new MMLatLon(MULTIMAP_DEFAULT_LAT,MULTIMAP_DEFAULT_LON),15));var a=new MMPanZoomWidget();mapviewer.addWidget(a);markers=new Array()}function initialiseDealershipMap(b){dealerMapViewer=MMFactory.createViewer(document.getElementById(b));dealerMapViewer.goToPosition(new MMLocation(new MMLatLon(MULTIMAP_DEFAULT_LAT,MULTIMAP_DEFAULT_LON),15));var a=new MMPanZoomWidget();dealerMapViewer.addWidget(a);markers=new Array()}function initialiseAmbiguousMap(a){ambiguousMap=MMFactory.createViewer(document.getElementById(a));ambiguousMap.goToPosition(new MMLocation(new MMLatLon(MULTIMAP_DEFAULT_LAT,MULTIMAP_DEFAULT_LON),15));markers=new Array()}function search(b,c,a){cachedLocation=b;searcher=MMFactory.createSearchRequester(resultsLoaded);search=new MMSearch();search.data_source=MULTIMAP_CLIENT_KEY;search.address=new MMAddress({qs:b,country_code:c});search.radius_units=MULTIMAP_DISTANCE_UNIT;search.route_modes="walking,driving";search.max_distance=Number(MULTIMAP_MAXIMUM_DISTANCE);search.min_distance=Number(MULTIMAP_MINIMUM_DISTANCE);search.count=Number(MULTIMAP_RESULTS_COUNT);search.start_index=Number(1);search.order_by_fields="driving_distance";search.order_by_order="asc";search.result_set_size=MULTIMAP_RESULTS_COUNT;search.filters=new Array();for(i=0;i<a.length;i++){search.filters.push(new MMSearchFilter(a[i][0],"eq",a[i][1]))}searcher.search(search)}function searchAgain(b,d,a){searcher=MMFactory.createSearchRequester(resultsLoaded);search=new MMSearch();search.data_source=MULTIMAP_CLIENT_KEY;var c=new String(b).split(",");search.point=new MMLatLon(c[0],c[1]);search.address=new MMAddress({country_code:d});search.radius_units=MULTIMAP_DISTANCE_UNIT;search.route_modes="walking,driving";search.max_distance=Number(MULTIMAP_MAXIMUM_DISTANCE);search.min_distance=Number(MULTIMAP_MINIMUM_DISTANCE);search.count=Number(MULTIMAP_RESULTS_COUNT);search.order_by_fields="driving_distance";search.order_by_order="asc";search.result_set_size=MULTIMAP_RESULTS_COUNT;search.filters=new Array();for(i=0;i<a.length;i++){search.filters.push(new MMSearchFilter(a[i][0],"eq",a[i][1]))}searcher.search(search)}function clearMarkers(){mapviewer.removeAllOverlays();markers=new Array()}function resultsLoaded(){var a=searcher;if(searcher.error_code){if(searcher.error_code=="MM_GEOCODE_MULTIPLE_MATCHES"){$("#duplicate-place-names").show();processGeocodingErrors(searcher.result_set)}else{if(searcher.error_code=="MM_GEOCODE_NO_MATCHES"){alert("No matches could be found for your input address.");history.back()}else{alert(searcher.error_code+": "+searcher.error_explanation)}}return}$("#results-container").show();init();reOrderResults(searcher.record_sets[0].records,cachedLocation,cachedLocation,false);if(markers.length>0){mapviewer.goToPosition(mapviewer.getAutoScaleLocation(markers))}}function addMarker(c,b,f,e){var d=new MMIcon(f);if(f.lastIndexOf("/")!=-1){var g=f.split("/");if(g[1]=="power"||g[1]=="atv"||g[1]=="energy"||g[1]=="garden"||g[1]=="marine"){d.iconSize=new MMDimensions(93,40);d.iconAnchor=new MMPoint(73,34)}else{d.iconSize=new MMDimensions(46,42);d.iconAnchor=new MMPoint(46,42)}}var a=mapviewer.createMarker(c,{icon:d});a.setVisibility(b);a.setInfoBoxContent(e);markers[markers.length]=a}function addHomeMarker(b,d){if((geocode!=null)&&(geocode!="")){var e=new String(geocode).split(",");var c=new MMIcon(MULTIMAP_ROOT+"_assets/presentation/location.gif");c.iconSize=new MMDimensions(16,23);c.iconAnchor=new MMPoint(16,23);var a=mapviewer.createMarker(new MMLocation(new MMLatLon(e[0],e[1])),{icon:c});a.setVisibility(true);markers.push(a);if(markers.length>0){mapviewer.goToPosition(mapviewer.getAutoScaleLocation(markers))}return}if(d){if(region=="IM"){homeGeocoder.geocode(new MMAddress({country_code:region}))}else{homeGeocoder.geocode(new MMAddress({qs:b,country_code:region}))}}else{var e=new String(b).split(",");var c=new MMIcon(MULTIMAP_ROOT+"_assets/presentation/location.gif");c.iconSize=new MMDimensions(16,23);c.iconAnchor=new MMPoint(16,23);var a=mapviewer.createMarker(new MMLocation(new MMLatLon(e[0],e[1])),{icon:c});a.setVisibility(true);markers.push(a);if(markers.length>0){mapviewer.goToPosition(mapviewer.getAutoScaleLocation(markers))}}}function handleHomeGeoCodingResponse(){geocode_results=homeGeocoder.result_set;var b=new MMIcon(MULTIMAP_ROOT+"_assets/presentation/location.gif");b.iconSize=new MMDimensions(16,23);b.iconAnchor=new MMPoint(16,23);var a=mapviewer.createMarker(new MMLocation(new MMLatLon(geocode_results[0].coords.lat,geocode_results[0].coords.lon)),{icon:b});a.setVisibility(true);markers.push(a);if(markers.length>0){mapviewer.goToPosition(mapviewer.getAutoScaleLocation(markers))}};
