window.onload = function(){
  $('#gallContent,#mainMedContent,#mainBigContent').jScrollPane({showArrows:true,scrollbarWidth:15,arrowSize:18});
  //#mainContent,#newsContent,#newsListContent,
}
$(document).ready(function(){
  $('.galpic').live('click', function(){
    if($('.galcontent', $(this).parent()).html() == '') {
      $('#phoverlay #img').attr('src', $(this).attr('href'));
      $('#galinfo').html($('.picinfo', $(this).parent()).html());
      $('#vioverlay').hide();
      $('#phoverlay').show();
      $('.albumitem').removeClass('active');
      $(this).parent().addClass('active');
      $('#navigationSubMenu').animate({top: '-418px'}, 50);
    } else {
      $('#vioverlay #vid').html($('.galcontent', $(this).parent()).html());
      $('#vinfo').html($('.picinfo', $(this).parent()).html());
      $('#phoverlay').hide();
      $('#vioverlay').show();
      $('.albumitem').removeClass('active');
      $(this).parent().addClass('active');
    }
  });
  $('.gallink').live('click', function(){
    $('.picinfo').hide();
    $(this).next().show();
  });
  $('.miniclose').live('click', function(){
    $(this).parent().hide();
  });
  $('#galclose').live('click', function(){ $('#phoverlay').hide(); $('#navigationSubMenu').animate({top: '0px'}, 50); });
  $('#vidclose').live('click', function(){ $('#vioverlay').hide(); });
  $('#galnext').live('click', function(){
    var urm = $('.albumitem.active').nextAll('.albumitem.imag').slice(0,1);
    if( $(urm).length == 0 ) urm = $('.albumitem.imag:first');
    $('#phoverlay #img').attr('src', $('.galpic', urm).attr('href'));
    $('#galinfo').html($('.picinfo', urm).html());
    $('.albumitem').removeClass('active');
    urm.addClass('active');
  });
  $('#galprev').live('click', function(){
    var ant = $('.albumitem.active').prevAll('.albumitem.imag').slice(0,1);
    if( $(ant).length == 0 ) ant = $('.albumitem.imag:last');
    $('#phoverlay #img').attr('src', $('.galpic', ant).attr('href'));
    $('#galinfo').html($('.picinfo', ant).html());
    $('.albumitem').removeClass('active');
    ant.addClass('active');
  });
  $('.picinfo a').attr('onclick', "self.location.href = '/download.php?file='+$(this).attr('href'); return false;");
});