// Javascript used bu artists-insideout site.

// ---------------------------------------------------------
// Functions for google map displayed on location.html page.
// ----------------------------------------------------------

// These functions were taken from the Google example page and
// adapted to display a single location.
// http://code.google.com/support/bin/answer.py?answer=65622&topic=11364
// Latitude and longitude of the House gallery were obtained from 
// python module geopy.
// http://exogen.case.edu/projects/geopy/
// Email me if you want a copy of the python code to call geopy
// stuart@squeakymouse.com.

function load() {
  
  // Load Google map.
  
  if (GBrowserIsCompatible()) {
    
    // Map goes in "map" div on current page.
    var map = new GMap2(document.getElementById("map"));
    map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());
    
    // Latitude and longitude of the House Gallery in Camberwell.
    var lat = 51.473486999999999;
    var lng = -0.088743000000000002;

    // Center the map on the House gallery.
    map.setCenter(new GLatLng(lat, lng), 16);
    var point = new GLatLng(lat, lng)
    
    // Add a pin to show where the House gallery is.
    var marker = createMarker(point);
    map.addOverlay(marker);
  }
}

function createMarker(point) {
  
  // Place marker point and info window when point
  // clicked on map.
  
  // Icons from google web site stored locally.
  // http://labs.google.com/ridefinder/images/mm_20_red.png
  // http://labs.google.com/ridefinder/images/mm_20_shadow.png
  var iconRed = new GIcon(); 
  iconRed.image = 'images/chrome/mm_20_red.png';
  iconRed.shadow = 'images/chrome/mm_20_shadow.png';
  iconRed.iconSize = new GSize(12, 20);
  iconRed.shadowSize = new GSize(22, 20);
  iconRed.iconAnchor = new GPoint(6, 20);
  iconRed.infoWindowAnchor = new GPoint(5, 1);
  var marker = new GMarker(point, iconRed);
  
  // Add info panel with picture of house gallery and address details.
  // Hyperlink picture to take people to the House gallery website.
  var html = '<div id="locationinfo">'
            + '<a href="http://www.house-gallery.co.uk">'
            + '<img src="images/chrome/house.jpg" alt="Picture of House Gallery." />'
            + '<\/a>'
            + '<p>House Gallery<\/p>'
            + '<p>70 Camberwell Church Street<\/p>'
            + '<p>Camberwell<\/p>'
            + '<p>London<\/p>'
            + '<p>SE5 8QZ<\/p><\/div>'
    
  GEvent.addListener(marker, 'click', function() {
    marker.openInfoWindowHtml(html);
  });
  return marker;
}

// ---------------------------------------------------------
// Function to change picture description.
// ----------------------------------------------------------

function changePicture(desc) {

  var d2 = document.getElementById('picturedesc');
  d2.innerHTML = desc;
    
  return true;
}
