var mapStores = null;
	var numberOfStores = 32;
	var storeMarker = new Array();
	var storeHtml = new Array;
	var gdir;
	var storeHours = "Open Daily - 10:00 AM to 9:00 PM<br />Open Sunday - 11:00 AM to 6:00 PM<br /><br />";
	var storeKC = new Array("0","0","0","0","0","0","1","0","1","0","0","1","0","0","0","0","0","1","0","0","1","1","0","0","1","1","1","1","1","0","0","1","0");
	var storeCC = new Array("0","1","1","1","1","1","1","1","1","1","1","1","0","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","0");
	var cpuHeader = "<strong>Customer Pickup Hours</strong><br>";
	var storeCpu = new Array("-1","Daily 1:30 P.M.-7:30 P.M.<br>Saturday 12:00 P.M.-7:30 P.M.","Daily 11:00 A.M.-8:30 P.M.<BR>Saturday 11:00 A.M.-8:30 P.M.<BR>Sunday 12:00 P.M.-5:00 P.M.","Daily 12:00 P.M.-8:00 P.M.<BR>Saturday 12:00 P.M.-8:00 P.M.<BR>Sunday 12:00 P.M.-5:00 P.M.","Not available","Daily 12:00 P.M.-8:00 P.M.<BR>Saturday 12:00 P.M.-8:00 P.M.<BR>Sunday None","Daily 12:00 P.M.-8:00 P.M.<BR>Saturday 12:00 P.M.-8:00 P.M.<BR>Sunday 12:00 P.M.-5:00 P.M.","Daily 3:00 P.M.-8:00 P.M.<BR>Saturday 12:00 P.M.-8:00 P.M.<BR>Sunday 12:00 P.M.-5:00 P.M.","Daily 11:00 A.M.-8:00 P.M.<BR>Saturday 11:00 A.M.-8:00 P.M.<BR>Sunday 12:00 P.M.-5:00 P.M.","Daily 1:00 P.M.-8:00 P.M.<BR>Saturday 1:00 P.M.-8:00 P.M.<BR>Sunday 12:00 P.M-5:00 P.M.","Daily 2:00 P.M.-8:00 P.M.<BR>Saturday 10:00 A.M.-9:00 P.M.<BR>Sunday None.","Daily 2:00 P.M.-8:00 P.M.<BR>Saturday 2:00 P.M- 8:00 P.M.<BR>Sunday 12:00 P.M.-5:00 P.M.","Daily 12:00 A.M.-8:00 P.M.<BR>Saturday 12:00 P.M.-8:00 P.M.<BR>Sunday 12:00 P.M.-5:00 P.M.","Daily 10:30 A.M.-8:30 P.M.<BR>Saturday 10:30 A.M.-8:30 P.M<BR>Sunday 12:00 P.M.-5:00 P.M.","Daily 3:00 P.M.-8:00 P.M.<BR>Saturday 12:00 P.M.-8:00 P.M.<BR>Sunday 12:00 P.M.-5:00 P.M.","Daily 3:00 P.M.-8:00 P.M.<BR>Saturday 3:00 P.M.-8:00 P.M.<BR>Sunday 12:00 P.M.-5:00 P.M.","Daily 12:00 P.M.-8:00 P.M.<BR>Saturday 12:00 P.M.-8:00 P.M.<BR>Sunday 12:00 P.M.-5:00 P.M.","Daily 12:00 P.M.-8:00 P.M.<BR>Saturday 12:00 P.M.-8:00 P.M<BR>Sunday 12:00 P.M.-5:00 P.M.","Daily 12:00 P.M.-8:00 P.M.<BR>Saturday 12:00 P.M.-8:00 P.M.<BR>Sunday 12:00 P.M.-5:00 P.M.","Daily 12:00 P.M.-8:00 P.M.<BR>Saturday 12:00 P.M.-8:00 P.M.<BR>Sunday 12:00 P.M.-5:00 P.M.","Daily 3:00 P.M.-8:00 P.M.<BR>Saturday 1:00 P.M.-8:00 P.M.<BR>Sunday 1:00 P.M.-5:00 P.M.","Daily 12:00 P.M.-8:00 P.M.<BR>Saturday 12:00 P.M.-8:00 P.M.<BR>Sunday 12:00 P.M.-5:00 P.M.","Not available","Daily 3:00 P.M-8:00 P.M.<BR>Saturday 10:00 A.M.-9:00 P.M.<BR>Sunday 12:00P.M.-5:00 P.M.","Daily 10:00 A.M.-8:30 P.M.<BR>Saturday 10:00 A.M.-9:00 P.M.<BR>Sunday 12:00 P.M.-5:00 P.M.","Daily 2:00 P.M.-8:00 P.M.<BR>Saturday 2:00 P.M.-8:00 P.M.<BR>Sunday None","Daily 12:00 P.M.-8:00 P.M.<BR>Saturday 12:00 P.M.-8:00 P.M.<BR>Sunday 12:00 P.M.-5:00 P.M.","Daily 2:00 P.M.-8:00 P.M.<BR>Saturday 2:00 P.M.-8:00 P.M.<BR>Sunday 12:00 P.M.-5:00 P.M.","Daily 10:00 A.M.-8:45 P.M.<BR>Saturday 10:00 A.M.- 8:45 P.M.<BR>Sunday 11:00 A.M.-5:45 P.M.","Daily 12:00 P.M.-8:00 P.M.<BR>Saturday 12:00 P.M.-8:00 P.M.<BR>Sunday 12:00 P.M.-5:00 P.M.","Daily 3:00 P.M.-8:00 P.M.<BR>Saturday 12:00 P.M.-8:00 P.M.<BR>Sunday 12:00 A.M.-5:00 P.M.","Daily 1:00 P.M.-8:00 P.M<BR>Saturday 1:00 P.M.-8:00 P.M.<BR>Sunday 1:00 P.M.-5:00 P.M.","Daily 12:00 P.M.-8:00 P.M.<BR>Saturday 12:00 P.M.-8:00 P.M.<BR>Sunday 12:00 P.M.-5:00 P.M.");
	var storeId = new Array("-1","053","067","036","017","034","075","029","083","065","031","025","041","055","080","051","040","071","020","059","019","073","014","033","044","024","012","057","011","015","030","023","027");
	var storeName = new Array("center","Ann Arbor","Battle Creek","Bay City","Bloomfield","Burton","Chesterfield","Clinton Township","Comstock Park","Dearborn","Flint","Grand Rapids","Grandville","Holland","Howell","Jackson","Kalamazoo","Lansing","Livonia","Muskegon","Novi","Port Huron","Royal Oak","Saginaw","Shelby Township","Southfield","Taylor","Traverse City","Warren - 14 Mile","Warren - 8 Mile","Waterford","Westland","Canton - Pure Sleep");
	var storeAddress = new Array("center","425 E. Eisenhower Pky.","6100 B Dr. North","4150 E. Wilder Rd","2125 N Telegraph Rd","4095 E. Court St","50400 Gratiot","33801 Gratiot Ave","4273 Alpine Ave N.W.","15701 Market Dr","G-4577 Miller Rd","4375 28th St. S.E.","4625 Wilson Avenue SW","12610 Felch St.","4101 E. Grand River Ave","950 N. West Ave","550 Ring Rd","8748 W. Saginaw Hwy","29905 W. 7 Mile Rd","630 Seminole Rd","27775 Novi Rd","1234 32nd St","32301 N. Woodward","2660 Tittabawassee Rd","14055 Hall Rd","22555 Greenfield Rd","22035 Eureka Rd","1775 Oak Hollow Dr.","6500 E. 14 Mile Rd","13855 E 8 Mile Rd","5053 Dixie Hwy","8300 N Wayne Rd","41913 Ford Rd");
	var storeCitySt = new Array("center","Ann Arbor, MI","Battle Creek, MI","Bay City, MI","Bloomfield Hills, MI","Burton, MI","Chesterfield, MI","Clinton Twp, MI","Comstock Park, MI","Dearborn, MI","Flint, MI","Grand Rapids, MI","Grandville, MI","Holland, MI","Howell, MI","Jackson, MI","Portage, MI","Lansing, MI","Livonia, MI","Muskegon, MI","Novi, MI","Port Huron, MI","Royal Oak, MI","Saginaw, MI","Shelby Township, MI","Southfield, MI","Taylor, MI","Traverse City, MI","Warren, MI","Warren, MI","Waterford, MI","Westland, MI","Canton, MI");
	var storeZip = new Array("center","48108","49014","48706","48302","48509","48051","48035","49321","48126","48507","49512","49418","49424","48843","49202","49024","48917","48152","49441","48377","48060","48073","48604","48315-6104","48075","48180","49686","48092","48089","48329","48185","48187");
	var storePhone = new Array("center","(734) 747-7170","(269) 979-1091","(989) 667-4700","(248) 454-0900","(810) 742-9120","(586) 840-1995","(586) 792-2810","(616) 784-1041","(313) 982-9999","(810) 733-3110","(616) 940-2070","(616) 531-3961","(616) 786-3400","(517) 552-0720","(517) 784-6700","(269) 323-3222","(517) 622-5959","(248) 478-8870","(231) 733-2141","(248) 348-8922","(810) 989-2049","(248) 549-2900","(989) 790-2221","(586) 566-1490","(248) 569-3770","(734) 287-4000","(231) 932-1050","(586) 939-2100","(586)779-9530","(248) 674-4731","(734) 425-9600","(734) 983-9100");
	var storeGeo = new Array();
	storeGeo[0] = new GLatLng(43.8264350, -84.4683480);
	storeGeo[1] = new GLatLng(42.2449780, -83.7430330);	
	storeGeo[2] = new GLatLng(42.2610395, -85.1770287);
	storeGeo[3] = new GLatLng(43.6237210, -83.8893195);
	storeGeo[4] = new GLatLng(42.6077170, -83.2973030);
	storeGeo[5] = new GLatLng(43.0198600, -83.6313560);
	storeGeo[6] = new GLatLng(42.6705338, -82.8365120);
	storeGeo[7] = new GLatLng(42.5448823, -82.9058233);
	storeGeo[8] = new GLatLng(43.0415063, -85.6896395);
	storeGeo[9] = new GLatLng(42.3275540, -83.1972120);
	storeGeo[10] = new GLatLng(42.9756450, -83.7707000);
	storeGeo[11] = new GLatLng(42.9125329, -85.5594245);
	storeGeo[12] = new GLatLng(42.881691, -85.762617);
	storeGeo[13] = new GLatLng(42.8192771, -86.0924427);
	storeGeo[14] = new GLatLng(42.5860634, -83.8720765);
	storeGeo[15] = new GLatLng(42.2597416, -84.4234007);
	storeGeo[16] = new GLatLng(42.2228254, -85.5954049);
	storeGeo[17] = new GLatLng(42.7420350, -84.6805930);
	storeGeo[18] = new GLatLng(42.4261440, -83.3410140);
	storeGeo[19] = new GLatLng(43.1870751, -86.2608041);
	storeGeo[20] = new GLatLng(42.4952169, -83.4761905);
	storeGeo[21] = new GLatLng(42.9694480, -82.4624356);
	storeGeo[22] = new GLatLng(42.5272770, -83.1959680);
	storeGeo[23] = new GLatLng(43.4799871, -83.9688286);
	storeGeo[24] = new GLatLng(42.62803, -82.98729);
	storeGeo[25] = new GLatLng(42.4588853, -83.2012355);
	storeGeo[26] = new GLatLng(42.1980354, -83.2484489);
	storeGeo[27] = new GLatLng(44.7343060, -85.6114141);
	storeGeo[28] = new GLatLng(42.5363852, -83.0384538);
	storeGeo[29] = new GLatLng(42.4502610, -82.9833530);
	storeGeo[30] = new GLatLng(42.6917860, -83.3897810); 
	storeGeo[31] = new GLatLng(42.3471899, -83.3854796); 
	storeGeo[32] = new GLatLng(42.322484, -83.453761);
	

	var i=1;
	for (i=1;i<=numberOfStores;i++) {
		storeMarker[i] = new GMarker(storeGeo[i]);
		//storeMarker[i].value = i;
		storeHtml[i] = "<span class='mapInfoHdr'>" + storeName[i] + "</span><br /><span class='mapAddress'>" + storeAddress[i] + "<br />" + storeCitySt[i] + " " + storeZip[i] + "<br />" + storePhone[i] + "</span>";
	} 
	
	function setDirections(fromAddress, toAddress) {
		mapStores.clearOverlays();
		gdir.load("from: " + fromAddress + " to: " + toAddress, "en_US");
	}
			
	function onGDirectionsLoad(){ 
		document.getElementById('store_Directions').style.display = 'block';
		// Use this function to access information about the latest load()
		// results.
		// e.g.
		// document.getElementById("getStatus").innerHTML = gdir.getStatus().code;
		// and yada yada yada...
	}
			
	function handleErrors(){
	    if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
	    alert("We could not find the address that you entered.  Please check the address and try again.");
	    // alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
	    else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
	    alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
	    else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
			alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);
		//   else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS)  <--- Doc bug... this is either not defined, or Doc is wrong
		//     alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code);
	    else if (gdir.getStatus().code == G_GEO_BAD_KEY)
			alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);
        else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
			alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
	    else alert("An unknown error occurred.");
	}
	
	function infoDisplay(dispNum) {
		var storeInfoDisp = storeHtml[dispNum] + "<br /><br /><span class='mapAddress'>" + storeHours + cpuHeader + storeCpu[dispNum];
		if (storeCC[dispNum]==1 || storeKC[dispNum]==1) {
			storeInfoDisp = storeInfoDisp + "<br /><br /><strong>Store Features</strong>";
		}
		if (storeCC[dispNum]==1) {
			storeInfoDisp = storeInfoDisp + "<br />Clearance Center";
		}
		if (storeKC[dispNum]==1) {
			storeInfoDisp = storeInfoDisp + "<br />Kid's Castle";
		}
		storeInfoDisp = storeInfoDisp + "<br /><br />";
		storeInfoDisp = storeInfoDisp + "<strong>Get Directions</strong><br />";
		storeInfoDisp = storeInfoDisp + "Enter the address you are starting from to get directions to this location.<br />";
		storeInfoDisp = storeInfoDisp + "<form action='#' onsubmit='setDirections(this.from.value,this.to.value); return false'>";
		storeInfoDisp = storeInfoDisp + "<input type='text' size='40' id='fromAddress' name='from'/>&nbsp;";
		storeInfoDisp = storeInfoDisp + "<input name='submit' type='submit' value='Get Directions' />";
		storeInfoDisp = storeInfoDisp + "<input name='to' type='hidden' id='toAddress' value='" + storeAddress[dispNum] + " " + storeCitySt[dispNum] + " " + storeZip[dispNum] + "'/>";
		storeInfoDisp = storeInfoDisp + "</form></span>";
		document.getElementById("store_Info").innerHTML = storeInfoDisp;	
		document.getElementById('store_Info').style.display = 'block';
	}
	
	function locationDisplay(thisNum) {
	//alert(thisNum);
		var k=0;
		for (k=0;k<storeId.length;k++) {
			if (storeId[k] == thisNum) {
				var thisStore = k;
			}
		}
		document.getElementById('map_Stores').style.height = "320px";
		mapStores.checkResize();
		mapStores.setZoom(13);
		mapStores.disableScrollWheelZoom();
		mapStores.panTo(storeGeo[thisStore]);
		mapStores.addOverlay(storeMarker[thisStore]);
		//mapStores.openInfoWindowHtml(storeGeo[thisStore],storeHtml[thisStore]);
		GEvent.addListener(storeMarker[thisStore],"click", function() {
		mapStores.openInfoWindowHtml(storeGeo[thisStore],storeHtml[thisStore]);
		});
		document.getElementById('store_Directions').innerHTML = '';
		document.getElementById('store_Directions').style.display = 'none';
		infoDisplay(thisStore);
	}

	
	
    function initialize(location) {
		var storeText = "";
		if (GBrowserIsCompatible()) {
			mapStores = new GMap2(document.getElementById("map_Stores"));
			document.getElementById('map_Stores').style.height = "640px";
			mapStores.checkResize();
			gdir = new GDirections(mapStores, document.getElementById("store_Directions"));
			GEvent.addListener(gdir, "load", onGDirectionsLoad);
			GEvent.addListener(gdir, "error", handleErrors);
			mapStores.setCenter(storeGeo[0], 7);
			mapStores.setUIToDefault();
			mapStores.disableScrollWheelZoom();
			
			function createMarker(latlng, number) {
				var marker = new GMarker(latlng);
				var myHtml = storeHtml[number];
				GEvent.addListener(marker,"click", function() {
					mapStores.openInfoWindowHtml(latlng, myHtml);
					infoDisplay(number);
				});
				return marker;
			}
			if (location == 'null' || !location) {
				var j=1;
				for (j=1;j<=numberOfStores;j++) {
					mapStores.addOverlay(createMarker(storeGeo[j],j));
					document.getElementById('store_Info').style.display = 'none';
				}
				document.getElementById('store_Directions').innerHTML = '';
				document.getElementById('store_Directions').style.display = 'none';
			} else {
				var k=0;
				for (k=0;k<storeId.length;k++) {
					if (storeId[k] == location) {
						var thisStore = k;
					}
				}
				document.getElementById('map_Stores').style.height = "320px";
				mapStores.checkResize();
				mapStores.setZoom(13);
				mapStores.panTo(storeGeo[thisStore]);
				mapStores.addOverlay(storeMarker[thisStore]);
				mapStores.openInfoWindowHtml(storeGeo[thisStore],storeHtml[thisStore]);
				infoDisplay(thisStore);
			}
		}
	}
