	(function($) {
	  var cache = [];
	  // Arguments are image paths relative to the current page.
	  $.preLoadImages = function() {
	    var args_len = arguments.length;
	    for (var i = args_len; i--;) {
	      var cacheImage = document.createElement('img');
	      cacheImage.src = arguments[i];
	      cache.push(cacheImage);
	    }
	  }
	})(jQuery)


var thumbsize = function () {

	$(".galerie_content li img").each( function(i) {

		if($(this).height()/$(this).width() < $(this).parent().height()/$(this).parent().width())
			$(this).height($(this).parent().height());
		else
			$(this).width($(this).parent().width());
  	 });
    }


    
    var thumbHover = function () {
        $(".galerie_content li img").hover(
            function () { $(this).animate({"opacity":1}, 700); },
            
            function () {
                
                if($(this).parent().is(':not(.active)'))
                    $(this).animate({"opacity":0.3}, 700); }
        );
    }
    
    var thumbClick = function () {
        $(".galerie_content li a").click(function() {

            if(!$(this).parent().hasClass('active')) {
            
                $(".galerie_content li.active img").animate({"opacity":0.3}, 700).dequeue().parents('li').removeClass('active');
                $(this).parent().addClass('active');
                $('.image img').css({'opacity':0}).attr('src',$(this).attr('href')).animate({'opacity':1},1000).dequeue();

            }
            return false;
       
        });

    }
    
    var imageClick = function () {
        
        $(".image img").click(function() {
            
            if($("li.active").is(':last-child'))
                $("li.active:last-child img").animate({"opacity":0.3}, 700).parents('li').removeClass('active').siblings(':first-child').children().animate({"opacity":1}, 700).parents('li').addClass('active');
            else
                $("li.active:not(:last-child) img").animate({"opacity":0.3}, 700).parents('li').removeClass('active').next().children().animate({"opacity":1}, 700).parents('li').addClass('active');
            
            $(".image img").css({'opacity':0}).attr('src',$('li.active a').attr('href')).animate({'opacity':1},1000).dequeue();
                              
        });
        
        
    }
    


