$(document).ready(function(){
    // prevent email address crawling
    $("span[class*=email]").each(function(){
        $(this).html($(this).html() + '@' + 'zt-zirngast.at');
        $(this).click(function(){
            window.location.href = 'mailto:' + $(this).html();
        });
    });

    // navigation link area extension
    $("ul[class=nav] li").each(function(){
        $(this).click(function(){
            // @TODO: what about -> $(this).children('a').trigger('click');
            window.location.href = $(this).children('a').attr('href');
        });
    });

    // course info toggle
    $("a[class*=info]").each(function(){
        $('#' + this.id + '_infobox').hide();
        
        $(this).click(function(){
            var height = $('#' + this.id + '_infobox').height();
            var id     = this.id;
            
            $("div[id$='_infobox']").each(function(){

               if(this.id != id + '_infobox'){
                  $('#' + this.id).hide();
               }
            });

            if(height < $(this).height()){
               $(this).toggleClass('open_info');
            }else{
               $(this).toggleClass('closed_info');
            }

            $('#' + this.id + '_infobox').slideToggle('500');

            return false;
        });
    });

   $('#gallery a[rel*=lightbox]').lightBox({
    overlayBgColor: '#FFF',
    overlayOpacity: 0.6,
    imageLoading: '/static/images/jquery-lightbox/loading.gif',
    imageBtnClose: '/static/images/jquery-lightbox/close.gif',
    imageBtnPrev: '/static/images/jquery-lightbox/prev.gif',
    imageBtnNext: '/static/images/jquery-lightbox/next.gif',
    containerResizeSpeed: 350,
    txtImage: 'Bild',
    txtOf: 'von'
   });
});

