// javascript for visit gros morne


// initialize jquery functions.
jQuery(document).ready(function($){



 // initialize variables
 $pagefade = $('div#pagefade');
 $page = $('div#page');
 $loading = $('div#loading');



 // slide fader
 // see: http://jonraasch.com/blog/a-simple-jquery-slideshow
 function slideSwitch() {
  var $active = $('#slideshow div.active');

  if ( $active.length == 0 ) $active = $('#slideshow div:last');

  // use this to pull the divs in the order they appear in the markup
  var $next = $active.next().length ? $active.next() : $('#slideshow div:first');

  // uncomment below to pull the divs randomly
  // var $sibs  = $active.siblings();
  // var rndNum = Math.floor(Math.random() * $sibs.length );
  // var $next  = $( $sibs[ rndNum ] );

  $active.addClass('last-active');

  $next.css({opacity: 0.0})
   .addClass('active')
   .animate({opacity: 1.0}, 1500, function() {
    $active.removeClass('active last-active');
   });
 }
 setInterval( slideSwitch, 5000 );



 // hide loading animation when calendar loads
 $('div#calendar iframe').load(function() {
  $loading.hide();
 });
 
 
 // links with 'fancybox' class open using jquery fancybox plugin.
 // Documentation: http://fancybox.net/
 $('a.fancybox').fancybox();



});



// generates e-mail link, hides address from spammers; linktext is optional
// <script type="text/javascript">mailto('user','domain.com');</script>
function mailto(user,domain,linktext){
 address = user + '@' + domain;
 if (linktext == undefined) linktext = address;
 document.write('<a href="mailto:' + address + '">' + linktext + '</a>');
}

