var lang = 'ru';
var ll = {
  'en' : {
    'close' : 'close',
    'next' : 'next',
    'previous' : 'previous',
    'current' : '{current} of {total}',
    'quick-search' : 'Quick Search',
    'full' : 'Open full-size image'
  },
  'ru' : {
    'close' : 'закрыть',
    'next' : 'следующая',
    'previous' : 'предыдущая',
    'current' : '{current} из {total}',
    'quick-search' : 'Быстрый поиск',
    'full' : 'Открыть полноразмерное изображение'
  }
};

$(document).ready(function(){
  initializeColorbox();
  
  $('a[rel^="photoline"]').colorbox({'rel':'photoline','close':ll[lang]['close'],'next':ll[lang]['next'],'previous':ll[lang]['previous'],'current':ll[lang]['current'],title: function(){
    var title = $(this).attr('title');
    var url = $(this).attr('rev');
    
    var section = $(this).attr('abstract');
    var pagetitle = $(this).attr('pagetitle');
    var pageurl = $(this).attr('pageurl');
    
    return '<a href="'+url+'" target="_blank" class="download-photo">'+section+ ' ' +title+'</a><a href="'+pageurl+'" class="gallery-pid">'+pagetitle+'</a>';
  }});
  /*
  $("body").flexiPagination({
        url: "?type=500",
    currentPage: 0,
    totalResults: 99999,
    perPage: 50,
    container: "#photo-line-container",
    pagerVar : "page",
    loaderImgPath: "fileadmin/templates/js/libs/jqpageflow/images/loader.gif",
    debug : 1
      });
      */
      $('.timeLine').append('<div class="loading">Loading ...</div>');
      $('.timeLine a').click(function(e){
        var el = $(this);
        var loading = el.parent().find('.loading');
        var page = $(this).attr('rel');
        
        e.preventDefault();

        loading.fadeIn(150);
        
        $('.dayEvents.ajax-content').fadeTo("slow", 0.38).load('?type=510&no_cache=1&page=' + page, function() {
      loading.fadeOut(250);
          el.parents('.timeLine').find('a').removeClass('active');
          el.addClass('active');
          $(this).fadeTo("fast", 1);
          initializeColorbox();
    });
      });
});

function initializeColorbox() {
  $('a[rel^="lightbox"]').colorbox({'rel':'lightbox','close':ll[lang]['close'],'next':ll[lang]['next'],'previous':ll[lang]['previous'],'current':ll[lang]['current'],title: function(){
    var url = $(this).attr('rev');
    return '<a href="'+url+'" target="_blank">'+ll[lang]['full']+'</a>';
  }});
}

