var map = null;
var geoXml = null;

function initialize() {
  var latlng = new google.maps.LatLng(60.00000,-95.00000);
  var myOptions = {
    zoom: 3,
    center: latlng,
    disableDefaultUI: true,
    zoomControl: true,
    zoomControlOptions: {style: google.maps.ZoomControlStyle.SMALL},
    mapTypeControl: true,
    mapTypeId: google.maps.MapTypeId.HYBRID
  };
  map = new google.maps.Map(document.getElementById("photoMap"), myOptions);
  geoXml = new google.maps.KmlLayer('http://betterleftunsaid.ca/service/betterleftunsaid-photographs.kml', {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);
	}
}

function zoomToCity(city) {
	if (city == "hfx") {
		map.setCenter(new google.maps.LatLng(44.640672,-63.575542));
		map.setZoom(13);
	}
	else if (city == "nyc") {
		map.setCenter(new google.maps.LatLng(40.736344,-73.988396));
		map.setZoom(13);
	}
}

$(document).ready(function(){
	$("#flickrPhotos").load('../inc/flickrphotos.php?w='+$(document).width(), function() {
    $(".fp").fancybox({
      'transitionIn'	:	'fade',
      'transitionOut'	:	'fade',
      'speedIn'		    :	600, 
      'speedOut'	    :	200,
      'titleShow'     : true,
      'titlePosition' : 'outside',
      'overlayShow'	  :	true
    });
  });
});

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

$(document).ready(function(){
	if (document.referrer != '') {
		var ref = document.referrer;
		$.post('../inc/notify.php', {rf: ref});
	}
	else {
		$.post('../inc/notify.php');
	}
});
