var map = null;
var pinid = 0;
<!-- Hard-coded list of stores and their coordinates -->
var stores = new Array();
<!-- List of results sorted by nearest to person to furthest. --> 
var results = new Array();
<!-- Set default coords to Richmond office -->
var coords = new Array(49.187398, -123.106656);


<!-- Setup the Database As Soon As Page Loads -->
SetupDB();

<!-- Import An External XML Document -->
function SetupDB()
{
	<!-- Array of possible store locations -->
	
		<!-- Format is as follows: -->
			<!-- [String]	Store Name					-->
			<!-- [String]	Store Address				-->
			<!-- [String]	Store Postal Code			-->
			<!-- [String]	Province ("AB", "BC", etc)	-->
			<!-- [String]	Phone Number				-->
			<!-- [Float]	Lattitude					-->
			<!-- [Float]	Longitude					-->
			<!-- [Integer]	Storetype					-->
			<!--			->[0] Must Preorder			-->
			<!--			->[1] Carries on shelf		-->
			<!-- [String]	Comments					-->
			<!-- [Float]	Geocode distance of store	Special Note: This number is pushed on to the array by the script during runtime, so there cannot be any values here, or after this index) -->
			
	
	<!-- British Columbia -->
		<!-- 100 Mile House -->
		stores.push(new Array("Higher Ground Natural Foods","104 South Birch Ave","V0K 2E0","100 Mile House","BC","(250) 395-2261",51.640861,-121.297728,1,""));
		<!-- Abbotsford -->
		stores.push(new Array("Herbs & Health Food","Unit 32 32700 S Fraserway","V2T 4M5","Abbotsford","BC","(604) 852-4425",49.050201,-122.317293,0,"Located in West Oak mall"));
		<!-- Ashcroft -->
		stores.push(new Array("Chandras Health Food Store", "413 Railway Ave", "V0K 1A0", "Ashcroft", "BC", "(250) 453-9309", 50.722814, -121.279916, 1, ""));
		<!-- Chetwynd -->
		stores.push(new Array("Chetwynd Health & Book Nook","4721 51st St","V0C 1J0","Chetwynd","BC","(250) 788-2068",55.699566,-121.632814,1,""));
		<!-- Cranbrook -->
		stores.push(new Array("Herbs &amp; Health Food", "1009 Baker St.", "V1C 1A6", "Cranbrook", "BC", "(250) 489-4464", 49.512051, -115.767266, 1, ""));
		<!-- Fort St. John -->
		stores.push(new Array("Homesteader Health","#20-9831 98a Ave","V1J 1S3","Fort St. John","BC","(250) 785-1455",56.244664,-120.844163,0,"Located in Fort St. John Mall."));
		<!-- Kelowna -->
		stores.push(new Array("Kelowna Natural Health Centre", "#50-301 Hwy 33 West Plaza", "V1X 1X8", "Kelowna", "BC", "(250) 765-8085", 49.888845, -119.391324, 1, ""));
		<!-- Keremeos -->
		stores.push(new Array("Pharmasave #250", "526 7th Ave", "V0X 1N0", "Keremeos", "BC", "(250) 499-5543", 49.205011, -119.826677, 1, ""));
		<!-- Parksville -->
		stores.push(new Array("Pharmasave #024","P.O. Box 10 1-281 E. Island Hwy","V9P 2G3","Parksville","BC","(250) 951-0227",49.317954,-124.303293,0,""));
		<!-- Penticton -->
		stores.push(new Array("Whole Foods Market","1770 Main Street #103","V2A 5G8","Penticton","BC","(250) 493-2855",49.479048,-119.584150,1,""));
		<!-- Prince George -->
		stores.push(new Array("Susan Cameron","11575 Sylvia Road West Beaverly","V2N 5B7","Prince George","BC","(250) 964-0840",53.826124,-122.942193,1,"Specializes in pet and horse applications."));
		stores.push(new Array("Ave Maria Specialties Ltd", "1638 20th Avenue", "V2L 4B6", "Prince George", "BC", "(250) 563-6388", 53.905562, -122.758500, 1, ""));
		<!-- Richmond -->
		stores.push(new Array("Consumers Nutrition Ltd.", "#1112-6551 No. 3 Road", "", "Richmond", "BC", "(604) 270-0007", 49.166462, -123.136643, 1, "Richmond Center Mall"));
		<!-- Salmon Arm -->
		stores.push(new Array("Shuswap Health Foods","120 8 AVE SW","V1E 1A1","Salmon Arm","BC","(250) 832-9998",50.693745,-119.286816,1,""));
		<!-- Sardis -->
		stores.push(new Array("Sardis Health Food","134-45610 Lukakuck Way", "V2R 1A2", "Sardis", "BC", "(604) 858-9111",49.140797,-121.961400,0,""));
		<!-- Twsawassen -->
		stores.push(new Array("Wellspring Health", "1248 56th Street Tsawassen", "V4L 2A4", "Twsawassen", "BC", "(604) 943-1499", 49.022722, -123.068367, 1, "Danny/Dolly Sheremeta"));
		<!--Vancouver-->
		stores.push(new Array("Marks Plaza Pharmacy","5760 Cambie Street","V5Z 3A6","Vancouver","BC","(604) 324-3848",49.232967,-123.115899,1,""));
		stores.push(new Array("Alive", "#271-650 W. 41st Avenue","V5Z 2M9","Vancouver","BC","(604) 263-3235",49.233503,-123.117726,1,"Oakridge Shopping Center"));
		<!-- Vernon -->
		stores.push(new Array("Nurse Gwen","5598 Pearson Road","V1B 3L1","Vernon","BC","(250) 545-7063",50.287839,-119.251328,1,""));
		
	<!-- Alberta -->
		<!-- Calgary -->
		stores.push(new Array("Bowness Health Foods","6435 Bowness Rd. N.W.","T3B 0E6","Calgary","AB","(403) 286-2224",51.085835,-114.180184,1,""));
		stores.push(new Array("Community Natural Health Foods","1304 10th Ave. S.W.","T3C 0J2","Calgary","AB","(403) 229-2383",51.044251,-114.091439,1,""));
		stores.push(new Array("Community Natural Health Foods - Chinook","202 - 61st Ave. S.W.","T2H 0B4","Calgary","AB","(403) 541-0606",50.997877,-114.067303,1,""));
		stores.push(new Array("Morning Sun Health Foods","#24 1200 - 37th street SW","T3C 1S2","Calgary","AB","(403) 246-8133",51.041392,-114.140980,0,"Located in Westbrook Mall"));
		stores.push(new Array("Morning Sun Health Foods","3625 Shaganappi Trail NW","T3A 0E2","Calgary","AB","(403) 288-5466",51.085171,-114.152716,0,"Located in the Market Mall"));
		stores.push(new Array("Morning Sun Health Foods","2350-2525 36 St NE","T1Y 5T4","Calgary","AB","(403) 293-9445",51.074017,-113.981507,0,"Located in the Market Mall"));
		stores.push(new Array("Morning Sun Health Foods","901 64 Avenue NE","T2E 7P4","Calgary","AB","(403) 730-8562",51.110615,-114.042434,0,"Located in the Deerfoot Mall"));
		stores.push(new Array("Morning Sun Health Foods","5747 Signal Hill Ctre. S.W","T3H 3P8","Calgary","AB","403-217-3304",51.018061,-114.172330,0,"Located in the Signal Hill Centre"));
		stores.push(new Array("Nutrition House","#162-100 Anderson Rd SE","T2J 3V1","Calgary","AB","(403) 278-7315",50.950640,-114.066991,1,""));
		stores.push(new Array("Sincere Health Food","107-8120 Bedington Blvd. NW","T3K 2A8","Calgary","AB","(403) 295-1375",51.125871,-114.074469,1,""));
		stores.push(new Array("Vitamin Farm","363-317 7th Ave SW","T2P 2Y9","Calgary","AB","(403) 237-5630",51.046468,-114.068346,1,""));
		<!-- Claresholm -->
		stores.push(new Array("Larabies Fountain of Youth","122 49 Avenue","T0L 0T0","Claresholm","AB","(403) 625-4549",50.025118,-113.579468,1,""));
		<!-- Cochrane -->
		stores.push(new Array("Main Street Pharmacy","Suite 207 105 1st Street","T4C 1A7","Cochrane","AB","(403) 932-6246",51.195576,-114.481655,1,"Unverified Location - May not be located in this exact area."));
		<!-- Drayton Valley -->
		stores.push(new Array("Drayton Valley Value Drug Mart","5203 - 50 Street, Box 7230","T7A 1S5","Drayton Valley","AB","(780) 542-5366",53.224978,-114.974050,1,""));
		<!-- Edmonton -->
		stores.push(new Array("Vitality Health Foods","82ave - 83st","T6C 3B8","Edmonton","AB","(780) 469-3411",53.518657,-113.457688,0,"Located in the Bonnie Doon Centre."));
		stores.push(new Array("Vitality Health Foods","5004 98 Ave","T6A 0A2","Edmonton","AB","(780)413-4817",53.538067,-113.420123,0,"Located in the Capilano Mall"));
		stores.push(new Array("Vitality Health Foods","14963 Stony Plain Road","T5P 3Y1","Edmonton","AB","(780) 484-2380",53.541192,-113.580276,0,"Jasper Gates"));
		stores.push(new Array("Vitality Health Foods","Londonderry Mall 137 Ave & 66 St","T5J 0E7","Edmonton","AB","(780) 473-4268",53.532790,-113.503383,0,"Londonderry Mall"));
		stores.push(new Array("Vitality Health Foods","9499 137 Ave","T5E 6K9","Edmonton","AB","(780) 476-6062",53.599265,-113.487967,0,"Northgate Centre"));
		stores.push(new Array("Vitality Health Foods","2020 Sherwood Drive","T8A 4W2","Edmonton","AB","(780) 467-0389",53.528962,-113.295536,0,""));
		stores.push(new Array("Vitality Health Foods","South Common 1925 98 St","T6N 1L5","Edmonton","AB","(780) 461-0889",53.448110,-113.484154,0,""));
		stores.push(new Array("Vitality Health Foods","St. Albert, Gateway Village 228, 2 Hebert Road","T8N 5T8","Edmonton","AB","(780) 460-4583",53.623320,-113.607141,0,""));
		stores.push(new Array("Vitality Health Foods","1057 West Edmonton Mall, Phase 1.  8882-170 street","T5T 4T1","Edmonton","AB","(780) 448-9530",53.522980,-113.615588,0,"Next to Zellers"));
		stores.push(new Array("Vitality Health Foods","Westmount Centre 111 Ave & Groat Road","T5M 3K1","Edmonton","AB","(780) 453-1313",53.558996,-113.551235,0,""));
		stores.push(new Array("Boost Your Health Ltd.", "6719 - 177th Street NW", "T5T 4K3", "Edmonton", "AB", "(780) 487-1240", 53.502096, -113.627142, 1, ""));
		stores.push(new Array("Optimum Health", "#2  7115 109th St.", "T6G 1B9", "Edmonton", "AB", "(780) 432-5464", 53.507344, -113.512023, 1, "The Centre"));
		stores.push(new Array("Sangster's", "#3 11100 51st Ave", "T6H 4M6", "Edmonton", "AB", "(780) 437-7997", 53.488418, -113.517969, 1, "Southgate Centre"));
		<!-- Fort Saskatchewan -->
		stores.push(new Array("Get Real Natural","104 8701 94 St","T8L 4P7","Fort Saskatchewan","AB","(780) 997-6443",53.699074,-113.192816,0,""));
		<!-- Hanna -->
		stores.push(new Array("Pharmasave #354","610 Second Avenue","T0J 1P0","Hanna","AB","(403) 854-3711",51.640655,-111.939155,1,""));
		stores.push(new Array("Hanna Value Drug Mart","231 - 2 Avenue West","T0J 1P0","Hanna","AB","(403) 854-4081",51.642705,-111.929258,1,""));
		<!-- High River -->
		stores.push(new Array("The Health Hut","109 - 4th Ave W","T1V 1M6","High River","AB","(403) 652-2420",50.579385,-113.867212,1,""));
		<!-- Innisfail -->
		stores.push(new Array("Innisfail Shoppers Drug Mart #2362","#12, 4303-50 Street","T4G 1B6","Innisfail","AB","(403) 227-1111",52.027522,-113.937584,1,"Located at the Co-op mall"));
		<!-- Lethbridge -->
		stores.push(new Array("Harvest Havan Market Farm","RR8 Site 22 Compound 1 Station Main","T1J 4P4","Lethbridge","AB","(403) 329-9157",49.698355,-112.775603,1,"Farmers Market"));
		stores.push(new Array("Old Fashioned Foods", "1240 - 2a Ave N.", "T1H 0E4", "Lethbridge", "AB", "(403) 380-2120", 49.701530, -112.827681, 1, ""));
		stores.push(new Array("Oliver Health Foods","#107  College Centre","T1K 2S2","Lethbridge","AB","(403) 327-4994",49.672245,-112.799640,1,""));
		stores.push(new Array("Norbridge Pharmacy","722 23 St N.","T1H 3S7","Lethbridge","AB","(403) 329-1211",49.709431,-112.808363,1,""));
		<!-- Lloydminster -->
		stores.push(new Array("Co-Op Marketplace Pharmacy","3606 - 50th Avenue","T9V 0V7","Lloydminster","AB","(780) 808-2180",53.270278,-110.005556,1,""));
		stores.push(new Array("Sangster's", "158 - 5211 44th Street", "T9V 0A7", "Lloydminster", "AB", "(780) 875-1651", 53.278083, -110.013070, 1, "Lloyd Mall"));
		<!-- Medicine Hat -->
		stores.push(new Array("Sangster's","134-3292 Dunmore Rd. SE","T1B 2R4","Medicine Hat","AB","(403) 526-2333",50.006759,-110.646785,1,"Located in Medicine Hat Mall"));
		<!-- Olds -->
		stores.push(new Array("Stang's Health Center","5013 50th St., Box 3761","T4H 1P5","Olds","AB","(403) 556-6090",51.792529,-114.107280,1,""));
		<!-- Oyen -->
		stores.push(new Array("Oyen Value Drug Mart","101 1st Avenue E, Box 659","T0J 2J0","Oyen","AB","(403) 664-3732",51.354464,-110.482039,1,""));
		<!-- Red Deer -->
		stores.push(new Array("Highland Green Value Drug Mart","#7, 88 Howarth Street","T4N 6V9","Red Deer","AB","(403) 341-3166",52.281905,-113.837274,1,""));
		<!-- Rocky Mountain House -->
		stores.push(new Array("Alpine Value Drug Mart","5107 - 50 Street, Box 39","T4T 1A1","Rocky Mountain House","AB","(403) 845-3727",52.376260,-114.919480,1,""));
		<!-- Strathmore -->
		stores.push(new Array("Strathmore Value Drug Mart","132 - 2 Avenue, Box 2310","T1P 1K3","Strathmore","AB","(403) 934-3122",51.043201,-113.395506,1,""));
		<!-- Sundre -->
		stores.push(new Array("Sundre Value Drug Mart","403 - Main Avenue West, Box 1560","T0M 1X0","Sundre","AB","(403) 638-3922",51.796439,-114.643892,1,""));
		<!-- Sylvan Lake -->
		stores.push(new Array("Sylvan Lake Value Drug Mart","5043 - 50 A Street, Bay 8-10","T4S 1R1","Slyvan Lake","AB","(403) 887-4200",52.309103,-114.098430,1,""));
		<!-- Vegreville -->
		stores.push(new Array("Vegreville Value Drug Mart","134, 4925 - 50 Avenue, Box 837","T9C 1R9","Vegreville","AB","(780) 632-7660",53.493905,-112.050256,1,""));

	<!-- Saskachewan -->
		<!-- Assiniboia -->
		stores.push(new Array("The Nature Shop","520 Centre Street","S0H 0B0","Assiniboia","SK","(306) 642-5301",49.630236,-105.993197,1,""));
		<!-- Canora -->
		stores.push(new Array("Health Bar & Hobbies","B & N Carlson Farms LTD. 108 Main St, Box 2159","S0A 0L0","Canora","SK","(306) 563-4111",51.636330,-102.436127,1,""));
		<!-- Estevan -->
		stores.push(new Array("Henders Drugs","1220 - 4th Street","S4A 0W9","Estevan","SK","(306) 634-3666",49.141294,-102.996799,1,""));
		<!-- Melfort -->
		stores.push(new Array("Nutters #25","102 McKendry Ave W.","S0E 1A0","Melfort","SK","(306) 752-1900",52.867959,-104.608526,1,""));
		<!-- Moostj Jaw -->
		stores.push(new Array("Alternate Root Organics", "16 Athabasca St. West", "S6H 2B5", "Moost Jaw", "SK", "(306) 693-4372", 50.395332, -105.534870, 1, ""));
		<!-- North Battleford -->
		stores.push(new Array("Nutter's #31 North Battleford","11204 Railway Ave E.","S9A 2R7","North Battleford","SK","(306) 446-3666",52.761072,-108.277008,1,""));
		<!-- Prince Albert -->
		stores.push(new Array("Sangster's","33 2995 2nd Ave West","S6V 5V5","Prince Albert","SK","(306) 764-6577",53.185806,-105.755697,0,""));
		stores.push(new Array("Nutter's #15", "365 - 36th St. W.", "S6V 7L4", "Prince Albert", "SK", "(306) 922-3835", 53.180470, -105.767505, 1, ""));
		<!-- Saskatoon -->
		stores.push(new Array("Sangster's", "11-2325 Preston Ave.", "S7J 2G2", "Saskatoon", "SK", "(306) 374-2788", 52.102630, -106.622508, 1, "Market Mall"));
		<!-- Swift Current -->
		stores.push(new Array("Pioneer Co-Op Pharmacy #4","1150 Central Ave North","S9H 0G1","Swift Current","SK","(306) 778-8821",50.301744,-107.795690,1,""));
		<!-- Yorkton -->
		stores.push(new Array("Good Earths Shop","385 Broadway East","S3N 3Z3","Yorkton","SK","(306) 782-5300",51.210258,-102.438473,1,""));
		stores.push(new Array("Yorkton Vitamin Centre", "112 Fenson Crescent", "S3N 3S5", "Yorkton", "SK", "(306) 782-8529", 51.215867, -102.442056, 1, ""));
		
	<!-- Manitoba -->
		<!-- Brandon -->
		stores.push(new Array("Hedley Enterprises Ltd","62-1570 - 18th Street","R7A 5C5","Brandon","MB","(204) 725-3131",49.827435,-99.961671,1,""));
		<!-- Morbin -->
		stores.push(new Array("Feelin' Good Health Products", "372  Stephen St.", "R6M 1T5", "Morden", "MB", "(204) 822-6707", 49.190183, -98.097553, 1, ""));
		<!--Roblin-->
		stores.push(new Array("Mitchells Drug Store","125 Main Street","R0L 1P0","Roblin","MB","(204) 937-4424",51.229353,-101.355150,1,""));
	
	<!-- Ontario -->
		<!-- Oshawa -->
		stores.push(new Array("Feel Good Natural Health", "129 King Street E", "L1H 1C2", "Oshawa", "ON", "(905) 571-1100", 43.898552, -78.858761, 1, ""));
		<!-- Ottawa -->
		stores.push(new Array("Rainbow Natural Foods", "1487 Richmond Rd.", "V0X 1N0", "Ottawa", "ON", "(613) 726-9200", 45.362267, -75.790908, 1, ""));
		<!-- Port Perry -->
		stores.push(new Array("Herbally Yours","180 Mary Street 1a","L9L 1C4","Port Perry","ON","(905) 985-0861",44.103522,-78.941043,1,""));
	
	
}
<!-- Load Map -->
function LoadMap()
{
	var latitude = 0.0;
	var longitude = 0.0;
	var postalcode = "";
	
	<!-- Read the URL and see if we have form submitted data -->
	var url = document.URL.indexOf('?');
	if (url != -1)
	{
		addr = document.URL.substring(url+1, document.URL.length);
		
		<!-- Cycle through all characters in the URL and determine what the parameters are -->
		var params = new Array();
		var paramCount = 0;
		var paramString = "";
		
		for (count = 0; count < addr.length; count++) 
		{
			needleChar = addr.charAt(count);
			if(needleChar!="&")
			{
				paramString = paramString + needleChar;
			}
			else
			{
				params[paramCount] = paramString;
				paramCount ++;
				paramString = "";
			}
			params[paramCount] = paramString;
		}
		
		<!-- Cycle through returned parameters and see if they match what we are looking for -->
		for(i=0; i<params.length;i++)
		{
		
			if(params[i].indexOf('Lat')!=-1)
			{
				<!-- Found Latitude -->
				latitude = params[i].substring( params[i].indexOf('Lat')+4, params[i].length );
			}
			
			if(params[i].indexOf('Lon')!=-1)
			{
				<!-- Found Longitude -->
				longitude = params[i].substring(params[i].indexOf('Lon')+4,params[i].length);
			}
			
			if(params[i].indexOf('ID')!=-1)
			{
				<!-- Found a postal code -->
				tempcode = params[i].substring(params[i].indexOf('ID')+3,params[i].length);
				<!-- Convert spaced formatting -->
				for (i=0;i<tempcode.length;i++)
				{
					if(tempcode.charAt(i)!="+")
					{
						postalcode = postalcode + tempcode.charAt(i);
					}
					else
					{
						postalcode = postalcode + " ";
					}
				}
			}
			
		}
	}
	
	<!-- Setup the map -->
	map = new VEMap('myMap');

	map.LoadMap(new VELatLong(55.62799595426722, -110.478515625), 5, VEMapStyle.Road, false);
	map.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers);
	
	<!-- Add some pushpins -->
	for(i=0;i<stores.length;i++){
		AddPushpin(stores[i][0],stores[i][1] + "\n<br>" + stores[i][3] + ", " + stores[i][4] + ".  " + stores[i][2] + "<br>\nPh: " + stores[i][5] + "\n<br><br>" + stores[i][9] ,stores[i][6],stores[i][7],stores[i][8]);
	}
	
	<!-- If the location is not null, center the map on it -->
	if(postalcode!="")
	{
		map.Find(null,postalcode, null, null, null, 1, true, true, null, true, GetCoordinates);   
	}
}

<!--Find the a location based on coordinates -->
function FindCoordinates(inLat,inLong)
{
	map.LoadMap(new VELatLong(inLat, inLong), 15, VEMapStyle.Road, false);
	map.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers);
	
	<!-- Add some pushpins -->
	for(i=0;i<stores.length;i++){
		AddPushpin(stores[i][0],stores[i][1] + stores[i][1] + "\n<br>" + stores[i][2] + ".  Ph: " + stores[i][5] + "\n<br>" + stores[i][9] ,stores[i][6],stores[i][7],stores[i][8]);
	}
}

<!-- Get the coordinates of a location -->
function GetCoordinates(layer, resultsArray, places, hasMore, veErrorMessage)
{
   FindClosest(places[0].LatLong.Longitude,places[0].LatLong.Latitude);
}

<!-- Get Lat Long -->
function GetLatLong()
{
	return map.GetCenter();
}

<!-- Convert Degrees into Radians -->
function degToRad(inDeg)
{
	var rads = (inDeg*(Math.PI/180));
	return rads;
}

<!-- Find closest store location -->
function FindClosest(inLong,inLat,inmaxR,inKMs)
{
	if ( inmaxR === undefined ) {
      inmaxR = 20;
	}
	
	if ( inKMs === undefined ) {
      inKMs = 1;
	}

	var R;
	if(inKMs==1)
	{
		<!--KMs-->
		R = 6371;
	}
	else
	{
		<!--Miles-->
		R = 3959;
	}
	
	<!-- Determine Distance from various stores -->
	for(i=0;i<stores.length;i++)
	{
		<!-- Convert the difference of latitude and longitude to radians -->
		var dLat = degToRad(inLat-(stores[i][6]));
		var dLon = degToRad(inLong-(stores[i][7])); 
		<!-- Use the Haversine formula to determine the distance between two polar coordinates -->
		var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
		        Math.cos(degToRad(inLat)) * Math.cos(degToRad(stores[i][6])) * 
		        Math.sin(dLon/2) * Math.sin(dLon/2); 
		var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 
		var d = R * c;
		<!-- Add the distance to the array for later use -->
		stores[i].push(d);
	}
	<!-- Now sort according to the closest from the person to the furthest and return the results-->
	stores.sort(sortStores);
	
	var outString = "<b>Results:</b><br><table border=\"0\" cellpadding=\"3\" width=\"100%\" cellspacing=\"0\">";
	outString = outString + "<tr><td>" + "<b>Distance<br>(KM)</b>" + "</td><td>" + "<b>Store Name</b>" + "</td><td>" + "<b>Mailing Address</b>" + "</td><td>" + "<b>City Location</b>" + "</td><td>" + "<b>Phone Number</b>" + "</td><td>" + "<b>Carries Stock</b>" + "</td><td>" + "<b>Comments</b>" + "</td></tr>";
	
	
	<!-- And finally print them all out to the results div -->
	for(i=0;i<stores.length;i++)
	{
		<!-- Check if store sells Triticum on its shelves -->
		var Sells = "";
		if (stores[i][8]==1){
			Sells = "Yes";
		}
		<!-- Output the string in the form of a row to the table -->
		outString = outString + "<tr><td><a href=\"#\" onClick=\"FindCoordinates(" +stores[i][6]+","+stores[i][7]+");\">" +roundNumber(stores[i][10],2)+ "</a></td><td>" + stores[i][0] + "</td><td>" + stores[i][1] +", "+ stores[i][2] + "</td><td>" + stores[i][3] + ", " + stores[i][4] + "</td><td>" + stores[i][5] + "</td><td>" + Sells + "</td><td>" + stores[i][9] + "</td>" + "</tr>";
	}
	outString = outString + "</table>";
	document.getElementById("divResults").innerHTML = outString; 
}

<!--Rounding function.  dec == decimal place -->
function roundNumber(num, dec) {
	var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
	return result;
}

<!-- Sort stores according to their distance from the person-->
function sortStores(a, b) {
    var x = a[10];
    var y = b[10];
    return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}

<!-- Add Push Pins-->
function AddPushpin(inName,inDesc,xCord,yCord,isOnShelf)
{
	var coords = new VELatLong(xCord,yCord);
	var shape = new VEShape(VEShapeType.Pushpin, coords);
	
	<!-- Determine if the store carries the product on the shelf -->
	if(isOnShelf==1){
		shape.SetCustomIcon("<div class='map_pin2'></div>"); 
	}
	else
	{
		shape.SetCustomIcon("<div class='map_pin1'></div>"); 
	}
	
	shape.SetTitle(inName);
	shape.SetDescription(inDesc);
	pinid++;
	
	<!-- Maybe change this function later so that the stores which carry the product on shelves are drawn after the stores that don't, that way, they will take priority on the map -->
	
	map.AddShape(shape);
}


<!-- Get the number of stores which carry the product -->
function StoreCount()
{
	return stores.length;
}