// JavaScript Document
$(document).ready(function() {
		$("a.proms_link").fancybox({
      'overlayOpacity': 0.3,
      'overlayShow': true,
      'zoomSpeedChange': 700
    });
});

/*this uses the DOM tranversal method, it filters out any elements with the class nav_link
that return false i.e. any nav links that do not match the current page, only the link for the
current page will return true thus getting the addClass applied to it and
highlighting to the user which page they are currently on*/
$(document).ready(function(){
  $('.nav_link').filter(function() { 
    return this.href == location.href;
  }).addClass('selected');  
});

//to hide price information for javascript users as it will be displayed in the jQuery fancybox 
//when small images are clicked
$(document).ready(function(){
  $('span.price').css('display', 'none');  
  slideShow(3000);
  
  //$('span#shortcuts').css({text-decoration: 'underline', cursor: 'pointer'});
  //$('span#keyboard_shortcuts').css('display', 'none');
  //$('span#shortcuts').click(function() {
      //$('span#keyboard_shortcuts').animate({opacity: 'toggle', height: 'toggle'}, 'slow');
  //});  
  
});

function slideShow(speed) {
  
  $('<div id="slideshow-caption"><p class="style"></p><p class="photographer"></p></div>').css({opacity:0.0}).prependTo('div.slideshow_container');
  
  //$('ul#slideshow').append('<li id="slideshow-caption" class="caption"><div class="slideshow-caption-container"><p></p></div></li>')
  
  $('ul#slideshow li').css({opacity: 0.0});
  
  $('ul#slideshow li.show').css({opacity: 1.0});
  
  $('#slideshow-caption p.style').html($('ul#slideshow li.show').find('img').attr('title'));
  $('#slideshow-caption p.photographer').html('Photography by<br /><a href="http://www.steveaddison.com/">Steve Addison</a>');
  
  $('#slideshow-caption').css({top:'319px', opacity:1.0}); 
  
  var timer = setInterval('gallery()', speed);
}

function gallery() {
  var current = $('ul#slideshow li.show');
  
  if (current.hasClass('last')) {//if last picture
    var next = $('ul#slideshow li:first');//go back to stat=rt
  }
  else {
    var next = current.next();//go to next one
  }
  
  var desc = next.find('img').attr('title');

  next.css({opacity:0.0}).addClass('show').animate({opacity:1.0}, 1500);
  
  $('#slideshow-caption').animate({bottom:-50}, 300, function() {
    $('#slideshow-caption p.style').html(desc);
    $('#slideshow-caption').animate({bottom:0}, 500);
  });
  
  current.animate({opacity:0.0}, 1500).removeClass('show');

}