$(function(){ $(window).bind('load', function() {
    lightbox();
    gallery.init();
}); });

var gallery = {
    elem: null,
    thumbSrc: null,
    bigSrc: null,
    
    init: function()
    {
        var cache = [];
        var args_len = $('#Picture a img').length;
        for (var i = args_len; i--;) {
         thumbSrc =  $('#Picture a img:eq('+i+')').attr('src');
         bigSrc = thumbSrc.replace(/thumbnail/, "normal").replace(/_klein./, ".");
         //alert(bigSrc);
         
          var cacheImage = document.createElement('img');
          cacheImage.src = bigSrc;
          cache.push(cacheImage);
        }
        $('#Pic0Caption').show();
        gallery.animImg($('#Picture a img'));
    },
    
    animImg: function(elem)
    {
        elem.click(function(){
           thumbSrc = $(this).attr('src');
           thumbNr = $(this).attr('id').substring(3);
           bigSrc = thumbSrc.replace(/thumbnail/, "normal").replace(/_klein./, ".");
           $('#PicFull').height($('#PicFull').height());
           $('#Caption p').fadeOut();
           $('#FullPic').fadeOut(function(){
                $('#Pic'+thumbNr+'Caption').fadeIn();
                $('#FullPic').attr('src',bigSrc).fadeIn();
                $('#PicFull').height('auto');
            });
           return false;
        });
    }
}

function lightbox()
{
    	$('a[rel=lightbox]').lightBox({
        imageLoading: 'http://' + location.hostname + '/js/lightbox/images/loading.gif',
        imageBtnClose: 'http://' + location.hostname + '/js/lightbox/images/close.gif',
        imageBtnPrev: 'http://' + location.hostname + '/js/lightbox/images/prev.png',
        imageBtnNext: 'http://' + location.hostname + '/js/lightbox/images/next.png',
        imageBlank: 'http://' + location.hostname + '/js/lightbox/images/blank.gif',
        txtImage: 'Bild',
        txtOf: 'von' });
}
