// Initialise
var arrPOI = new Array();

arrPOI.push(new POI(52.758482, -4.780070, 'Bardsey Island, Gwynedd'));
arrPOI.push(new POI(52.794744, -4.767549, 'Braich y Pwll, Gwynedd'));
arrPOI.push(new POI(52.881615, -4.412931, 'Pwllheli, Gwynedd'));
arrPOI.push(new POI(52.901214, -4.170901, 'Tremadog, Gwynedd'));
arrPOI.push(new POI(52.515598, -4.056448, 'Ynyslas, Ceredigion'));
arrPOI.push(new POI(52.215529, -4.361879, 'New Quay, Ceredigion - Birds Rock and New Quay Harbour'));
arrPOI.push(new POI(52.137536, -4.639205, 'Mwnt, Ceredigion'));
arrPOI.push(new POI(52.131255, -4.682379, 'Cardigan Island, Ceredigion'));
arrPOI.push(new POI(52.117290, -4.732449, 'Cemaes Head, Pembrokeshire'));
arrPOI.push(new POI(52.022918, -4.857014, 'Newport, Pembrokeshire'));
arrPOI.push(new POI(52.030185, -5.068530, 'Strumble Head, Pembrokeshire'));
arrPOI.push(new POI(51.902448, -5.313019, 'St. David\'s Head, Pembrokeshire'));
arrPOI.push(new POI(51.862345, -5.349075, 'Ramsey Island, Pembrokeshire'));

// ==================================================================================================

function POI(vdblLat, vdblLong, vsDescription)
{
	// Creates a new sighting
	this.YGeoPoint = new YGeoPoint(vdblLat, vdblLong);
	this.Description = vsDescription;
}

// ==================================================================================================

function createYahooMarker(vobjPOI)
{
  // Create a new image
  var myImage = new YImage();
  myImage.src = '/Images/Icon_Dolphin.jpg';
  myImage.size = new YSize(20,20);

  // Create a marker
  myImage.offsetSmartWindow = new YCoordPoint(10,10);
  var marker = new YMarker(vobjPOI.YGeoPoint,myImage);
  var label= '<img src="/Images/Icon_Dolphin.jpg">';
  marker.addLabel(label);

  // The text that is going to appear in the window
  var swtext = '<span style="font-family:Arial; font-size:12px;">' + vobjPOI.Description + '</span>';

  // Create an event handler
  YEvent.Capture(marker,EventsList.MouseClick,function() { marker.openSmartWindow(swtext) });

  // Return it
  return marker;
}

// ==================================================================================================

// Create a lat/lon object - this is the last sighting and we are going to center the map in it
var myPoint = new YGeoPoint(52.515598, -4.056448);

// Create a map object
var map = new YMap(document.getElementById('mapContainerVisit'));

// Display the map centered on a latitude and longitude
map.drawZoomAndCenter(myPoint, 11);

// Add a pan control
map.addPanControl();
// Add a slider zoom control
map.addZoomLong();

// For each sighting
for (var i = 0; i < arrPOI.length ; i++) {
  // Create a marker
  var marker = createYahooMarker(arrPOI[i]);

  // Add it to the map
  map.addOverlay(marker);
}

// Add map type control
map.addTypeControl();

// Set map type to either of: YAHOO_MAP_SAT YAHOO_MAP_HYB YAHOO_MAP_REG
map.setMapType(YAHOO_MAP_REG);

//Get valid map types, returns array [YAHOO_MAP_REG, YAHOO_MAP_SAT, YAHOO_MAP_HYB]
var myMapTypes = map.getMapTypes();
