$(function () {
  var ni = null;
  $('#ss_thumbnails:not([class~=animating]) .ss_thumbnail').live('slideshow', function () {
    var ts = $('#ss_thumbnails');
    ts.addClass('animating');
    var bf = $('#ss_buffer_front');
    $('.ss_thumbnail').removeClass('active');
    $(this).addClass('active');
    bf.css({ 'background-image': $(this).css('background-image').replace(/thumbs/, 'slides') }).fadeIn('slow', function () {
      $('#ss_buffer_back').css({ 'background-image': $(this).css('background-image').replace(/thumbs/, 'slides') });
      bf.fadeOut(0);
      setTimeout(function () {
        var ta = $('.ss_thumbnail.active')
            tn = null;
	if (ni == null) {
          tn = ta.next();
          if (!tn.size()) tn = ta.siblings().first();
        } else {
          tn = ni.removeClass('selected');
          ni = null;
        }
	if (tn != null) tn.trigger('slideshow');
      }, 2500);
      ts.removeClass('animating');
    });
    return false;
  }).first().trigger('slideshow');
  $('.ss_thumbnail').bind('click', function () {
    ni = $(this).addClass('selected').siblings().removeClass('selected').end();
  });
});
$(function () {
  var map = $('#map');
  if (!map) return;
  loc = new google.maps.LatLng(loc[0], loc[1]);
  map = new google.maps.Map(map.get(0), {
    center: loc,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    zoomControlOptions: {
      style: google.maps.ZoomControlStyle.LARGE
    },
    zoom: 10
  });
  var pin = new google.maps.Marker({
    map: map,
    position: loc,
    title: 'The Old House Hotel, The Square, Wickham, Hampshire, PO17 5JG'
  });
  $('#directions').attr({ target: '_blank' });
});

