
    var map = null;
    var geocoder = null;
	var directions = null;
	var currentAddress = null;

    function mapInit() {
		//alert('hi');
		if (GBrowserIsCompatible()) {
			//directionsPanel = document.getElementById("yt_MapDirections");
			map = new GMap2(document.getElementById("MapArea"));
			//directions = new GDirections(map, directionsPanel);
			//map.setCenter(new GLatLng(49.2632,-122.954779), 13);
			geocoder = new GClientGeocoder();
			map.addControl(new GSmallMapControl());
			map.addControl(new GMapTypeControl ()); 
			map.setCenter(new GLatLng(62.460000,-114.385000), 12);       
			//GEvent.addListener(directions, "error", handleErrors);
		}
    }

    function showAllAddress() {
		showAddress('X1A 2E8','3507 Ingraham Drive','Yellowknife','NT','Canada','Polar Developments Property', true,62.466179,-114.348139);
		showAddress('X1A 2E8','3509 Ingraham Drive','Yellowknife','NT','Canada','Polar Developments Property', true,62.466358,-114.347956);
		showAddress('X1A 1V4','5002-53rd Street','Yellowknife','NT','Canada','Polar Developments Property', true,62.452051,-114.375229);
		showAddress('X1A 1V4','5004-53rd Street','Yellowknife','NT','Canada','Polar Developments Property', true,62.451957,-114.374982);
		showAddress('X1A 1V4','5006-53rd Street','Yellowknife','NT','Canada','Polar Developments Property', true,62.451852,-114.374746);
		showAddress('X1A 1V4','5010-53rd Street','Yellowknife','NT','Canada','Polar Developments Property', true,62.451684,-114.374317);
		showAddress('X1A 1V4','5012-53rd Street','Yellowknife','NT','Canada','Polar Developments Property', true,62.451585,-114.374059);
		showAddress('X1A 3Y4','4501-52nd Avenue','Yellowknife','NT','Canada','Polar Developments Property', true,62.454929,-114.360852);
		showAddress('X1A-3R9','480 Range Lake Road','Yellowknife','NT','Canada','Center Ice Plaza',false,62.446801,-114.409937);	
		showAddress('X1A-3Y4','4503-52nd Avenue','Yellowknife','NT','Canada','The Watermark Tower',false,62.454284,-114.361002);	
		showAddress('X1A-3G5','5300-49th Street','Yellowknife','NT','Canada','Anderson Thomson Tower',false,62.450696,-114.363534);	
	}
    


    function showAddress(pc, str, cty, st, ctr, BldName, custIcon, lat, lng) {
		var address = str + ' ' + cty + ' ' + st + ' ' + pc + ' ' +ctr;
		currentAddress = address;
		//alert(address);
//		var addressText = '			<div style="font-size:9px; margin:0px 0px 0; line-height:1em!important;"><h5>'+BldName+'</h5>' + 
		var addressText = '			<div style="font-size:10px; margin:0px 0px 0; "><h3>'+BldName+'</h3>' + 
				str + ',<br />' + 
				cty + ', ' + st + ',<br />' + 
				ctr +'<br /></div>';
		var yellowIcon = new GIcon();
		yellowIcon.iconSize = new GSize(20, 34);
		yellowIcon.iconAnchor = new GPoint(9, 34);
		yellowIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
		yellowIcon.shadowSize = new GSize(37, 34);
		yellowIcon.infoWindowAnchor = new GPoint(9, 2);
		yellowIcon.infoShadowAnchor = new GPoint(18, 25);
		if (custIcon) {
			var icon = new GIcon(yellowIcon);
			icon.image = "images/yellow_marker.png";
		} else {
			icon = G_DEFAULT_ICON;
		}
		if (lat && lng) {
			var llPoint = new GLatLng(lat,lng)
			var marker = new GMarker(llPoint, icon);
			map.addOverlay(marker);
			GEvent.addListener(marker, "click", function() {
			  marker.openInfoWindowHtml(addressText);
			});
		} else {
		if (geocoder) {
		geocoder.getLatLng(
						
			address,
			function(point) {
				if (!point) {
					geocoder.getLocations(address, function(result) { 
						if (result.Status.code == G_GEO_SUCCESS) {
							var p = result.Placemark[0].Point.coordinates;
							var marker = new GMarker(new GLatLng(p[1], p[0]), icon);
							map.addOverlay(marker);
							//marker.openInfoWindowHtml(addressText);
							GEvent.addListener(marker, "click", function() {
							  marker.openInfoWindowHtml(addressText);
							});

						} else { 
							/*var reason="Code "+result.Status.code;
							if (reasons[result.Status.code]) {
								reason = reasons[result.Status.code];
							}
							alert('Could not find "'+address+ '" ' + reason); 
							alert('Address not found');*/
						}
					//alert(address + " not found");
					} );
				} else {
					//map.setCenter(point, 13);
					var marker = new GMarker(point, icon);
					map.addOverlay(marker);
					GEvent.addListener(marker, "click", function() {
					  marker.openInfoWindowHtml(addressText);
					});
					//marker.openInfoWindowHtml(addressText);
				}

			});
		}}
    }
	
	
	
	
	
    function handleErrors(){
	   //alert("Please make sure you've entered a valid address.");
	   
	}
	
	
	
