
	  
(function () {
    $.fn.infiniteCarousel = function () {
        function repeat(str, n) {
            return new Array( n + 1 ).join(str);
        }
        
        return this.each(function () {
            // magic!
            var $wrapper = $('> div', this).css('overflow', 'hidden'),
                $slider = $wrapper.find('> ul').width(99999999),
                $items = $slider.find('> li'),
                $single = $items.filter(':first')
                
                singleWidth = $single.outerWidth(),
                visible = Math.ceil($wrapper.innerWidth() / singleWidth),
                currentPage = 1,
                pages = Math.ceil($items.length / visible);
                
            /* TASKS */
            
            // 1. pad the pages with empty element if required
            if ($items.length % visible != 0) {
                // pad
                $slider.append(repeat('<li class="empty" />', visible - ($items.length % visible)));
                $items = $slider.find('> li');
            }
            
            // 2. create the carousel padding on left and right (cloned)
            $items.filter(':first').before($items.slice(-visible).clone().addClass('cloned'));
            $items.filter(':last').after($items.slice(0, visible).clone().addClass('cloned'));
            $items = $slider.find('> li');
            
            // 3. reset scroll
            $wrapper.scrollLeft(singleWidth * visible);
            
            
            // 4. paging function
            function gotoPage(page) {
            	
            
                var dir = page < currentPage ? -1 : 1,
                    n = Math.abs(currentPage - page),
                    left = singleWidth * dir * visible * n;
                
                $wrapper.filter(':not(:animated)').animate({
                    scrollLeft : '+=' + left
                }, 500, function () {
                    // if page == last page - then reset position
                    if (page > pages) {
                        $wrapper.scrollLeft(singleWidth * visible);
                        page = 1;
                        
                    } else if (page == 0) {
                        page = pages;
                        $wrapper.scrollLeft(singleWidth * visible * pages);
                    }
                    
                    currentPage = page;
                   
                    var color = $("#hidden" + page).css("background-color");
      				
                   
                    //$("div").css("paddingRight", "1");
                     $("#startCounter div").css("background", "#464b4f");
                     
                     
      				
   					 $("#" + page).css("background", color);


                     
     				// $("#" + page).css("paddingRight", "1");
     				 
      				 
                });
            }
            
            // 5. insert the back and forward link
            $wrapper.after('<a href="#" class="arrow back">&lt;</a><a href="#" class="arrow forward">&gt;</a>');
            
            // 6. bind the back and forward links
            $('a.back', this).click(function () {
                gotoPage(currentPage - 1);
                return false;
            });
       
            
            $('a.forward', this).click(function () {
                gotoPage(currentPage + 1);
                return false;
            });
            
              
            $('.bildchange').click(function () {
              	var page = parseInt(this.id);
                gotoPage(page);
                return false;
            });
            
            
            $(this).bind('goto', function (event, page) {
                gotoPage(page);
            });
            
            
            // THIS IS NEW CODE FOR THE AUTOMATIC INFINITE CAROUSEL
            $(this).bind('next', function () {
                gotoPage(currentPage + 1);
            });
        });
    };
})(jQuery);

$(document).ready(function () {



    // THIS IS NEW CODE FOR THE AUTOMATIC INFINITE CAROUSEL
    var autoscrolling = true;
    
    $('.infiniteCarousel').infiniteCarousel().mouseover(function () {
   
        autoscrolling = true;
    }).mouseout(function () {
        autoscrolling = true;
    });
    
    setInterval(function () {
        if (autoscrolling) {
            $('.infiniteCarousel').trigger('next');
        }
    }, 80000);
});


$(document).ready(function() {
	$('.events').hover(function(){
		$(this).css("background", "#f4f4f4");
		

	}, function(){
		$(this).css("background", "#ffffff");

	});
});



			
$(function() {

	$('#naviYear > ul').tabs({ fx: { height: 'toggle', opacity: 'toggle' } });		
	
	$('#container-presse > ul').tabs({ fx: { height: 'toggle', opacity: 'toggle' } });		
	
 });
		
	

				$(document).ready(function(){ // This sets the opacity of the thumbs to fade down to 60% when the page loads
					$("#sponsors .sponsor img").fadeTo("slow", 1.0);

					$("#sponsors").hover(function(){
					$("#sponsors .sponsor img").fadeTo("slow", 1.0); // This sets the opacity to 100% on hover
					},function(){
					$("#sponsors .sponsor img").fadeTo("slow", 1.0); // This sets the opacity back to 60% on mouseout
					});
				});
					
					
					$(function () {
        if ($.browser.msie && $.browser.version < 7) return;
        
        $('#navigationbodyinnerSub li ')
            .removeClass('highlight')
            .find('a')
            .append('<span class="hover" />').each(function () {
                    var $span = $('> span.hover', this).css('opacity', 0);
                    $(this).hover(function () {
                        // on hover
                        $span.stop().fadeTo(500, 1);
                    }, function () {
                        // off hover
                        $span.stop().fadeTo(500, 0);
                    });
                });
                
    });
	
	
	
			$(document).ready(function() {
						$("a.zoom").fancybox();

						$("a.zoom1").fancybox({
							'overlayOpacity'	:	0.7,
							'overlayColor'		:	'#FFF'
						});

						$("a.zoom2").fancybox({
							'zoomSpeedIn'		:	500,
							'zoomSpeedOut'		:	500
						});
					});

