/* List of files found in images/rotater directory */
var ads = ['rotater_1.jpg', 'rotater_2.jpg', 'rotater_3.jpg',
           'rotater_4.jpg', 'rotater_5.jpg', 'rotater_6.jpg',
           'rotater_7.jpg', 'rotater_8.jpg', 'rotater_9.jpg',
           'rotater_10.jpg', 'rotater_11.jpg'];
           



  
$('document').ready(function(){
  /* Function: Preloader */
  function preload(arrayOfImages) {
    $(arrayOfImages).each(function(){
      $('<img/>')[0].src = "images/rotater/" + this;
    });
  }
  
  /* Preload Images to Rotate */
    preload(ads);
    
  /* Fancybox */
    jQuery( "a.fancybox" ).fancybox({
      'autoScale'     : true,
      'transitionIn'  : 'fade',
      'transitionOut' : 'fade',
      'titlePosition' : 'inside',
      'overlayColor'  : '#666',
      'overlayOpacity': '0.65',
      'titleFormat'   : function(title, currentArray, currentIndex, currentOpts) {
        //return '<span id="fancybox-title-inside"><span>' + (title.length ? ' &#160; ' + title : '') + '</span><span>Image ' + (currentIndex + 1) + ' / ' + currentArray.length + '</span></span>';
        return '<div id="fancybox-title-inside">' + (title && title.length ? '<b>' + title + '</b>' : '' ) + 'Image ' + (currentIndex + 1) + ' of ' + currentArray.length + '</div>';
      }
    });
});
