var map = null;
var geoXml = null;

function initialize() {
  var latlng = new google.maps.LatLng(60.00000,-95.00000);
  var myOptions = {
    zoom: 3,
    center: latlng,
    mapTypeId: google.maps.MapTypeId.HYBRID
  };
  map = new google.maps.Map(document.getElementById("photoMap"), myOptions);
  geoXml = new google.maps.KmlLayer('http://betterleftunsaid.ca/service/geolocation.php', {suppressInfoWindows: false, map: map});
  geoXml.setMap(map);
  
  google.maps.event.addListener(geoXml, 'click', function(kmlEvent) {
  	var infowindow = new google.maps.InfoWindow({
    	content: kmlEvent.featureData.description
		});

  	infowindow.open(map,geoXml);
	});
}

function zoomToProvince(prov) {
	if (prov == "bc") {
		map.setCenter(new google.maps.LatLng(54.022442,-124.439751));
		map.setZoom(5);
	}
	else if (prov == "son") {
		map.setCenter(new google.maps.LatLng(44.420818,-79.362983));
		map.setZoom(7);
	}
	else if (prov == "ns") {
		map.setCenter(new google.maps.LatLng(45.190479,-63.220764));
		map.setZoom(6);
	}
	else if (prov == "nyc") {
		map.setCenter(new google.maps.LatLng(40.736344,-73.988396));
		map.setZoom(13);
	}
}

$(document).ready(function() {
	$("#mapPage").fancybox({
		'width': 590,
		'height': 450,
		'transitionIn': 'fade',
		'transitionOut': 'fade',
		'type': 'iframe'
	});
});