(function( $ ){
  $.fn.gallery_nav = function( settings ) {
    var options = {
      'images'         : [],
      'text_to_append' : ''
    };
    return $(this).each(function() {
      if ( settings ) { $.extend( options, settings ); }
      var nav = $('<nav>').fadeTo(1, 0.5).html(
        $('<div>').addClass('content')
        .append(options['text_to_append'])
      ).delay(1750).fadeOut('fast');
      // empty the container
      $(this).empty();
      var image_container = $('<div>').attr('id', 'overlay-content');
      // append the images into the container
      $.each(images, function(i, img) {
        if (img) { image_container.append( $('<img>').attr({ src: img, alt:'' }) ); }
      });
      
      $(this).append(image_container)
      .append(nav)
      .hover(function() {
        $('nav', $(this)).fadeIn('fast');
      }, function() {
        $('nav', $(this)).fadeOut('fast');
      });
      if ($('img', image_container).length > 1) {
        image_container.cycle({
          fx: 'scrollHorz',
          pager: $('.content', $(this)),
          timeout: 0
        });
      }
      return this;
    });
  };
})( jQuery );

