    //<![CDATA[
	google.load("maps", "2");
	
	var windowOpen, map, mapDir, avonLatLng, geocoder;
	var pointArray = new Array();
	var marker = new Array();
	var iconList = new Array();
	var markerTabs = new Array();
	var infoTab, description;
	var hoursTab;
	var addressTab, locationName;
	var streetArray = new Array();
	var cityArray = new Array();
	var stateArray = new Array();
	var zipArray = new Array();
	var markerList;
	var avonLocation = "1471 W Henrietta Rd, Avon, NY 14414";
	var locationClicked = avonLocation;
	var destination = new Array();
	var stepHTMLPart1, stepHTMLPart2, stepHTMLPart3;
	var chooseStart, chooseEnd, custDest, lastDest;
	var destHTMLPart1, destHTMLPart2, destHTMLPart3, destHTMLPart4;
	var showSteps = new Array();
	
	function load() {
      if (google.maps.BrowserIsCompatible()) {
        map = new google.maps.Map2(document.getElementById("mapDiv"));
		daddress = document.getElementById("daddressDiv");
		dirLink = document.getElementById("dirLinkDiv");
        avonLatLng = new google.maps.LatLng(42.916674, -77.705109);
		map.setCenter(avonLatLng, 9);
		map.addMapType(G_SATELLITE_3D_MAP);
	    map.addControl(new google.maps.LargeMapControl());
		map.addControl(new google.maps.OverviewMapControl());
		map.addControl(new google.maps.MapTypeControl());
		
		geocoder = new google.maps.ClientGeocoder();
		
		createIcon("GVPS", "../marketplace/images/Map Icons/gvps.png", 40, 40, "../marketplace/images/Map Icons/gvps_s.png", 74);
		createIcon("TCA", "../marketplace/images/Map Icons/tca.png", 40, 40, "../marketplace/images/Map Icons/house_s.png", 59);
		createIcon("Default", "../marketplace/images/Map Icons/dk-grn-pushpin.png", 32, 32, "../marketplace/images/Map Icons/default_s.png", 59);
		createIcon("Start", "../marketplace/images/Map Icons/flag_green.png", 32, 32, "../marketplace/images/Map Icons/flag_s.png", 59);
		createIcon("MidRoute", "../marketplace/images/Map Icons/flag_yellow.png", 32, 32, "../marketplace/images/Map Icons/flag_s.png", 59);
		createIcon("Finish", "../marketplace/images/Map Icons/flag_checkered.png", 32, 32, "../marketplace/images/Map Icons/flag_s.png", 59);
		
		resetMap();
      }
    }

	function resetMap(){
		map.clearOverlays();
		
		addMarkerToMap(43.2160719, -77.938034, "TCA", "15 Main St.", "Brockport", "NY", "14420", "Our Tri-County Advertiser Office in Brockport", null);
		addMarkerToMap(42.9970444, -78.1796753, "GVPS", "222 E. Main St.", "Batavia", "NY", "14020", "Our Batavia Sales Office", null);
		addMarkerToMap(42.8847262, -77.2793051, "GVPS", "202 S. Main St.", "Canandaigua", "NY", "14424", "Our Canandaigua Sales Office", null);
		addMarkerToMap(42.917711, -77.702708, "GVPS", "1471 W. Henrietta Rd.", "Avon", "NY", "14414", "Our Main Office in Avon", null);
		
		locationClicked = avonLocation;
		windowOpen = 0;
		chooseStart = false;
		chooseEnd = false;
		custDest = false;
		destination[0] = null;
		destination[1] = avonLocation;
		lastDest = 1;
		showSteps[0] = true;
		
		map.setCenter(avonLatLng, 9, G_NORMAL_MAP);
	}
	
	function createIcon(iconID, iconImage, iconWidth, iconHeight, iconShadow, shadowWidth){
		markerList = new google.maps.MarkerManager(map);
		iconList[iconID] = new google.maps.Icon();
		iconList[iconID].image = iconImage;
		iconList[iconID].iconSize = new google.maps.Size(iconWidth, iconHeight);
		iconList[iconID].shadow = iconShadow;
		iconList[iconID].shadowSize = new google.maps.Size(shadowWidth, iconHeight);
		if(iconID == "GVPS") {
			iconList[iconID].transparent = "../marketplace/images/Map Icons/gvps_t.png";
		}else if(iconID == "TCA") {
			iconList[iconID].transparent = "../marketplace/images/Map Icons/gvps_t.png";
		}else{
			iconList[iconID].transparent = "../marketplace/images/Map Icons/transparent_32.png";
		}
		if(iconID == "Default") {
			iconList[iconID].iconAnchor = new google.maps.Point(Math.floor(10), Math.floor(iconHeight-2));
		}else{
			if(iconID == "GVPS") {
				iconList[iconID].iconAnchor = new google.maps.Point(Math.floor(iconWidth/2), Math.floor(iconHeight/2));
			}else if(iconID == "TCA") {
				iconList[iconID].iconAnchor = new google.maps.Point(Math.floor(iconWidth/2), Math.floor(iconHeight/2));
			}else{
				iconList[iconID].iconAnchor = new google.maps.Point(Math.floor(9), Math.floor(iconHeight-4));
			}
		}
		iconList[iconID].infoWindowAnchor = new google.maps.Point((iconWidth/2), 0);
		iconList[iconID].imageMap = [0,0, Math.floor(iconWidth),0, Math.floor(iconWidth),Math.floor(iconHeight), 0,Math.floor(iconHeight)];
	}
	
	function addDisplayMarker(displayID){
		switch(displayID){
			
			//
			//6-27-2010 Edition Ads
			//
			case "F25919":
				alert("Visit any of our offices to get your Garage Sale Kit today!");
				break;
			case "Regular Ad":
				addMarkerToMap(42.820521, -77.667483, "Default", "6 Spring St", "Livonia", "NY", "14487", null, displayID);
				break;
				
			case "F60741":
				addMarkerToMap(42.979265, -78.406681, "Default", "8966 Alleghany Rd", "Corfu", "NY", "14036", null, displayID);
				break;
			case "E95271":
				addMarkerToMap(42.820521, -77.667483, "Default", "6 Spring St", "Livonia", "NY", "14487", null, displayID);
				break;
				
			default:
				alert("There was an error adding this marker to the map.");
				break;
		}
	}
	
	function addMarkerToMap(ptLat, ptLng, iconID, markerStreet, markerCity, markerState, markerZip, description, adImage) {
		map.closeInfoWindow();
		windowOpen = 0;
      if (google.maps.BrowserIsCompatible()) {
		locationName = markerStreet + ", " + markerCity + ", " + markerState + " " + markerZip;
		if(streetArray[locationName] == null){
			streetArray[locationName] = markerStreet;
			cityArray[locationName] = markerCity;
			stateArray[locationName] = markerState;
			zipArray[locationName] = markerZip;
		}
		if(pointArray[locationName] == null){
			if((ptLat == null) || (ptLng == null) || (ptLat == 0) || (ptLng == 0)){
				geocoder.getLocations(locationName, function geocodeResponse(response) {
					if (!response || (response.Status.code != 200)) {
						alert("The address: " + locationName + " could not be found.");
					}else{
						place = response.Placemark[0];
						ptAcc = place.AddressDetails.Accuracy;
						switch(ptAcc){
							case 0:
								alert("This address (" + locationName + ") is unknown.");
								break;
							case 1:
								alert("This address (" + locationName + ") could only be found at the country level.  It was found as: "+place.address);
								break;
							case 2:
								alert("This address (" + locationName + ") could only be found at the region (state, province, prefecture, etc.) level.  It was found as: "+place.address);
								break;
							case 3:
								alert("This address (" + locationName + ") could only be found at the sub-region (county, municipality, etc.) level.  It was found as: "+place.address);
								break;
							case 4:
								alert("This address (" + locationName + ") could only be found at the town (city, village) level.  It was found as: "+place.address);
								break;
							case 5:
								alert("This address (" + locationName + ") could only be found at the post code (zip code) level.  It was found as: "+place.address);
								break;
							case 6:
								alert("This address (" + locationName + ") could only be found at the street level.  It was found as: "+place.address);
								break;
							default:
								break;
						}
						pointArray[locationName] = new google.maps.LatLng(place.Point.coordinates[1], place.Point.coordinates[0]);
						addNewMarker(pointArray[locationName], iconID, locationName, description, adImage);
					}
				});
			}else{
				pointArray[locationName] = new google.maps.LatLng(ptLat, ptLng);
			}
		}
		if(marker[locationName] != null) {
			if(marker[locationName].getIcon() == iconList["GVPS"]){
				map.removeOverlay(marker[locationName]);
				addNewMarker(pointArray[locationName], "GVPS", locationName, description, adImage);
			}else{
				map.removeOverlay(marker[locationName]);
				addNewMarker(pointArray[locationName], iconID, locationName, description, adImage);
			}
		}else{
			addNewMarker(pointArray[locationName], iconID, locationName, description, adImage);
		}
	  }
	}
	
	function addNewMarker(point, iconID, locationName, description, adImage) {
		marker[locationName] = new google.maps.Marker(pointArray[locationName], {title: locationName, icon: iconList[iconID], zIndexProcess: calcMarkerIndex});
		markerList.addMarker(marker[locationName], 8);
		if(adImage != null){
			imageLink1 = "../adspdf/garagesales/"+adImage+".pdf";
			imageLink2 = "../adspdf/garagesales/"+adImage+".jpg";
			infoTab = new google.maps.InfoWindowTab("Ad Info", '<div id="infoTab" style="max-height:131px; max-width:280px;" align="center" width="280px"><td><a href='+imageLink1+' target="_blank"><img src='+imageLink2.toLowerCase()+' alt="Ad Image" title="Click to open this ad in a new window." border="0" style="max-height:131; max-width:280"></a></td></div>');
		}else{
			if(description != (null || "")){
				if(iconID == "GVPS"){
					infoTab = new google.maps.InfoWindowTab("GVPS Info", '<div id="infoTab" style="max-height:131px; max-width:280px;" width="280px"><table border="0" cellpadding="0" cellspacing="0"><tr><td valign="top" align="center" width="100%"><a href="http://www.gvpennysaver.com/hometown/index.aspx" target="_blank"><img src="http://www.gvpennysaver.com/images/gvps_logo.gif" title="Click to open the GVPS homepage in a new window." alt="GVPS Logo" name="GVPS Logo" width="125" border="0"></a><br><br>'+description+'</td></tr></table></div>');
				}else if(iconID == "TCA"){
					infoTab = new google.maps.InfoWindowTab("TCA Info", '<div id="infoTab" style="max-height:131px; max-width:280px;" width="280px"><table border="0" cellpadding="0" cellspacing="0"><tr><td valign="top" align="center" width="100%"><a href="http://www.gvpennysaver.com/hometown/index.aspx" target="_blank"><img src="http://www.gvpennysaver.com/images/TCA.gif" title="Click to open the GVPS homepage in a new window." alt="TCA Logo" name="TCA Logo" width="125" border="0"></a><br><br>'+description+'</td></tr></table></div>');
				}else{
					infoTab = new google.maps.InfoWindowTab("Ad Info", '<div id="infoTab" style="max-width:280px;" width="280"><table border="0" cellpadding="0" cellspacing="0"><tr><td valign="top" align="left" width="100%">'+description+'</td></tr></table></div>');
				}
			}else{
				infoTab = null;
			}
		}
		if((cityArray[locationName] != null) && (stateArray[locationName] != null) && (zipArray[locationName] != null)){
			if(streetArray[locationName] != null){
				addressTab = new google.maps.InfoWindowTab("Address", '<div id="addressTab" style="max-height:131px; max-width:280px;" width="280px"><table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%"><tr><td align="center">'+streetArray[locationName]+'<br>'+cityArray[locationName]+', '+stateArray[locationName]+' '+zipArray[locationName]+'<br><br><a href="javascript:;" onClick="marker[locationClicked].showMapBlowup()">Show Detailed Map</a></td></tr></table></div>');
			}else{
				addressTab = new google.maps.InfoWindowTab("Address", '<div id="addressTab" style="max-height:131px; max-width:280px;" width="280px"><table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%"><tr><td align="center">'+cityArray[locationName]+', '+stateArray[locationName]+' '+zipArray[locationName]+'<br><br><a href="javascript:;" onClick="marker[locationClicked].showMapBlowup()">Show Detailed Map</a></td></tr></table></div>');
			}
		}else{
			addressTab = null;
		}
		if((iconID == "GVPS") || (iconID == "TCA")){
			hoursTab = new google.maps.InfoWindowTab("Our Hours", '<div id="hoursTab" style="max-height:131px; max-width:280px;" width="280px"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"><tr><td align="center" style="border-bottom:1px;"><u><strong>Our Office Hours</strong></u><br><table border="0" cellpadding="0" cellspacing="0"><tr><td>Mondays - Wednesdays</td><td style="padding-left:10px">8:30 - 5:00</td></tr><tr><td>Thursdays</td><td style="padding-left:10px">8:00 - 5:00</td></tr><tr><td>Fridays</td><td style="padding-left:10px">8:30 - 3:00</td></tr></table></td></tr></table></div>');
		}else{
			hoursTab = null;
		}
		if(hoursTab != null){
			if(infoTab == null){
				if(addressTab != null){
					markerTabs[point] = [addressTab, hoursTab];
				}
			}else{
				if(addressTab == null){
					markerTabs[point] = [infoTab, hoursTab];
				}else{
					markerTabs[point] = [infoTab, addressTab, hoursTab];
				}
			}
		}else{
			if(infoTab == null){
				if(addressTab != null){
					markerTabs[point] = [addressTab];
				}
			}else{
				if(addressTab == null){
					markerTabs[point] = [infoTab];
				}else{
					markerTabs[point] = [infoTab, addressTab];
				}
			}
		}
		google.maps.Event.addListener(marker[locationName], "click", function() {
			locationClicked = this.getTitle();
			daddress.innerHTML = locationClicked;
			document.googledirform.daddr.value = locationClicked;
			if(windowOpen == 0){
				map.openInfoWindowTabsHtml(point, markerTabs[point], {maxWidth: 300, onCloseFn: function(){windowOpen = 0;}});
				windowOpen = 1;
			}else{
				map.closeInfoWindow();
				windowOpen = 0;
			}
        });
		map.addOverlay(marker[locationName]);
		map.panTo(pointArray[locationName]);
	}
	
	function calcMarkerIndex(marker, x){
		if(marker.icon == iconList["GVPS"]){
			return 1;
		}else{
			return 100;
		}
	}
	
	google.setOnLoadCallback(load);

    //
