$(document).ready(function() {
    //Get our elements for faster access and set overlay width
    var div = $('div.sc_menu'),
                 ul = $('ul.sc_menu'),
                 // unordered list's left margin
                 ulPadding = 10;

    //Get menu width
    var divWidth = div.width();

    //Remove scrollbars
    div.css({overflow: 'hidden'});

    //Find last image container
    var lastLi = ul.find('li:last-child');

    //When user move mouse over menu
    div.mousemove(function(e){

      //As images are loaded ul width increases,
      //so we recalculate it each time
      var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;

      var left = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
      div.scrollLeft(left);
    });
});


var Engine = {
 
    glossarToggle : function(){

        $('#glossar')
            .find('strong')
//          .find('p.col-4').removeAttr('style').hide().end()

            .toggle(


                function(){
        
                    $(this)
//                      .removeClass('expand')
                        .toggleClass('collapse')
        
                        .siblings('strong.collapse').removeClass().end()
    
                        .next('p.col-4').slideToggle(500)
                        .siblings('p.col-4:visible').slideToggle(250) 
                        ;
    
                },



                function(){
    
                    $(this)
//                      .removeClass('collapse')
                        .toggleClass('collapse')
    
                        .siblings('strong.collapse').removeClass().end()

    
                        .next('p.col-4').slideToggle(500)
                        .siblings('p.col-4:visible').slideToggle(250) 
                        ;
    
                });



    }
 
 }



 
$(document).ready(function(){
 
    Engine.glossarToggle();
    
    });




$(document).ready(function() {
    $('a.praep_button')
//        .css( {backgroundPosition: "0 0"} )
        .mouseover(function(){
            $(this).stop().animate({"opacity": "0.8"}, {duration:1000})
        })
        .mouseout(function(){
            $(this).stop().animate({"opacity": "1"}, {duration:500})
    });

});


$(document).ready(function() {
    $('a.klinik_button')
//        .css( {backgroundPosition: "0 0"} )
        .mouseover(function(){
            $(this).stop().animate({"opacity": "0.8"}, {duration:1000})
        })
        .mouseout(function(){
            $(this).stop().animate({"opacity": "1"}, {duration:500})
    });

});


$(document).ready(function() {
    $('a.kurs_button')
//        .css( {backgroundPosition: "0 0"} )
        .mouseover(function(){
            $(this).stop().animate({"opacity": "0.8"}, {duration:1000})
        })
        .mouseout(function(){
            $(this).stop().animate({"opacity": "1"}, {duration:500})
    });

});

$(document).ready(function() {

// adds a Class to the infoboxes – this works only when javascript is activated in Browsers to prevent from hiding content if not
    $('div.infoboxk>h5').addClass('shrinked').siblings().hide();

// toggles the classes, both of h5 and the content
    $('div.infoboxk>h5').click(function(){
        $(this).toggleClass('expanded').siblings().toggleClass('').slideToggle(500);
    });
 
});


$(document).ready(function() {

// adds a Class to the infoboxes – this works only when javascript is activated in Browsers to prevent from hiding content if not
    $('div.infoboxk_wide>h5').addClass('shrinked').siblings().hide();

// toggles the classes, both of h5 and the content
    $('div.infoboxk_wide>h5').click(function(){
        $(this).toggleClass('expanded').siblings().toggleClass('').slideToggle(500);
    });
 
});





$(document).ready(function () {
 
    $(document).keydown(function(e) {
        var url = false;
        if (e.which == 37) {  // Left arrow key code
            url = $('.prev').attr('href');
        }
        else if (e.which == 39) {  // Right arrow key code
            url = $('.next').attr('href');
        }
        if (url) {
            window.location = url;
        }
    });
 
});



$(document).ready(function() {
    $('a.topic')
//        .css( {backgroundPosition: "0 0"} )
        .mouseover(function(){
            $(this).stop().animate({"opacity": "1"}, {duration:1000})
        })
        .mouseout(function(){
            $(this).stop().animate({"opacity": "0.7"}, {duration:500})
    });

});


