
// new Array("Location Name", "Prefix ", "Street Address", "City, Prov, Postal Code", "Phone", "Fax", "Email", "Schedule Key")
var dcLocations = new Array(
	new Array("Calgary South", "#6, ", "711 48 Avenue SE", "Calgary, AB T2G 4X2", "(403) 255-3111", "(403) 258-3555", "calgaryse@dentclinic.com", 0),
	new Array("Calgary North", "Bay #118, ", "1725 32 Ave NE", "Calgary, AB T2E 7C8", "(403) 250-2435", "(403) 219-3154", "calgary.ne@dentclinic.com", 1),
	new Array("Red Deer", "#2, ", "5551 45th Street", "Red Deer, AB T4N 1L2", "(403) 340-3177", "(403) 340-3191", "reddeer@dentclinic.com", 2),
	new Array("Edmonton", "#130, ", "3903 99 Street", "Edmonton, AB T6E 6M2", "(780) 466-4468", "(780) 485-0781", "edmonton@dentclinic.com", 0),
	new Array("Saskatoon", "", "702 First Avenue N", "Saskatoon, SK  S7K 1Y1", "(306) 956-DENT (3368)", "(306) 956-3367", "saskatoon@dentclinic.com", 1),
	new Array("Regina", "", "437 Broad Street", "Regina, SK S4R 1X4", "(306) 721-DENT (3368) ", "(306) 721-3379", "regina@dentclinic.com", 1)
	//new Array("Prince Albert", "Bay #1, ", "406 South Industrial Drive", "Prince Albert, SK S6V 7L8", "(306) 764-DENT (3368)", "(306) 763-4844", "princealbert@dentclinic.com", 3)
);

// new Array("Mon - Fri", "Saturday", "Sunday")
var dcSchedules = new Array(
	new Array("8:00am - 5:00pm", "10:00am - 2:00pm", "Closed"),
	new Array("8:00am - 5:00pm", "By Appointment Only", "Closed"),
	new Array("8:30am - 5:00pm", "By Appointment Only", "Closed"),
	new Array("8:30am - 5:00pm", "Closed", "Closed")
);

var map = null;
var geocoder = null;

function initialize() {
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map"),
			{ size: new GSize(579,395) } );
			
		// ====== Restricting the range of Zoom Levels =====
		// Get the list of map types      
		var mt = map.getMapTypes();
		// Overwrite the getMinimumResolution() and getMaximumResolution() methods
		for (var i=0; i<mt.length; i++) {
			mt[i].getMinimumResolution = function() {return 4;}
			mt[i].getMaximumResolution = function() {return 15;}
		}
	
		map.setCenter(new GLatLng(55, -115), 4);
		
		var uiOptions = map.getDefaultUI();
		uiOptions.zoom.scrollwheel = false;
		map.setUI(uiOptions);
		
		geocoder = new GClientGeocoder();
	}
}

function createMarker(id) {

	map.clearOverlays();

	var address = dcLocations[id][2] + dcLocations[id][3];
	
	// Override for Calgary North location (Marker is more accurate Geocacheing by Postal Code for some reason)
	if (dcLocations[id][0] == "Calgary North") {
		address = dcLocations[id][3];
	}
	
	geocoder.getLatLng(address, function(point) {
			var marker = new GMarker(point);
			map.addOverlay(marker);
			var info = '<div class="marker-content"><div id="marker-name">Dent Clinic ' + dcLocations[id][0] + '</div><div id="marker-address">' + dcLocations[id][1] + dcLocations[id][2] + '<br />' + dcLocations[id][3] + '</div><div id="marker-phone">Phone: ' + dcLocations[id][4] + '<br />Fax: ' + dcLocations[id][5] + '</div><div id="marker-mail"><a href="mailto:' + dcLocations[id][6] + '">' + dcLocations[id][6] + '</a></div></div>';
			var hours = '<div class="marker-content"><div id="marker-name">Dent Clinic ' + dcLocations[id][0] + '</div><table id="marker-hours" cellspacing="0"><tr><td class="first">Mon - Fri</td><td>' + dcSchedules[dcLocations[id][7]][0] + '</td></tr><tr><td class="first">Saturday</td><td>' + dcSchedules[dcLocations[id][7]][1] +'</td></tr><tr><td class="first">Sunday</td><td>' + dcSchedules[dcLocations[id][7]][2] + '</td></tr></table></div>';
			var tabs = new Array(new GInfoWindowTab("Address", info), new GInfoWindowTab("Hours", hours));
			map.setCenter(point, 13);
			marker.openInfoWindowTabsHtml(tabs);
		}
	);
	
	setClass(id);
}

function setClass(id) {

	var i = 0;

	do {
		e = document.getElementById('location' + i);
		if (e) {
			e.className = '';
		}
		i++;
	} while (e);

	document.getElementById('location' + id).className = 'active';
	
}