function image_slider_onload(){
    if($(".image_slider").length > 0){
        // Init
        var innerWidth = document.body.clientWidth;
        var innerHeight = document.body.clientHeight;
        
        // Do resize
        if( $(".pagewrapper_two-col_large").length > 0 ){
          updateImageSize(innerWidth-520, innerHeight);
          if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
            var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
            if (ieversion>=6){
              $(".right_content_container").width(innerWidth-523);
              $(".right_content_container").height(innerHeight);
            }
            if (ieversion==9){
              $(".right_content_container").width(innerWidth-543);
              $(".right_content_container").height(innerHeight);
            }
          }
        }
        if( $(".pagewrapper_two-col_small").length > 0 ){
          updateImageSize(innerWidth-460, innerHeight);
          if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
            var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
            if (ieversion>=6){
              $(".right_content_container").width(innerWidth-463);
              $(".right_content_container").height(innerHeight); 
              $(".google_maps").width(innerWidth-463);
              $(".google_maps").height(innerHeight); 
            }
            if (ieversion==9){
              $(".right_content_container").width(innerWidth-583);
              $(".right_content_container").height(innerHeight);
            }
          }
        }
        if( $(".pagewrapper_three-col").length > 0 ){
          updateImageSize(innerWidth-760, innerHeight);
          if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
            var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
            if (ieversion>=6){
              $(".right_content_container").width(innerWidth-763);
              $(".right_content_container").height(innerHeight);
            }
            if (ieversion==9){
              $(".right_content_container").width(innerWidth-783);
              $(".right_content_container").height(innerHeight);
            }
          }
        }
        // destroy current cycle(s) & init new one
        $('.image_slider .images').cycle('destroy');
        $('.image_slider .images').cycle({
            fx:     'fade',
            speed:  '1200',
            timeout: 5000,
            next:   '#slider_next',
            prev:   '#slider_prev'
        });

				var imagesClone = $('.image_slider .images').clone().removeAttr('style').removeAttr('id').hide();
				imagesClone.find('img').each(function() {
					var newImg = $(this).clone().removeAttr('style').removeAttr('height').removeAttr('width');
					$(this).replaceWith($('<a href="'+newImg.attr('src')+'" class="gallery" rel="randomrel"></a>').html(newImg));
				});
				imagesClone.appendTo('body');
				imagesClone.find('a').fancybox({ overlayOpacity: 0.75, overlayColor: '#000' });
				$('#slide_show').click(function(e) {
					imagesClone.find('a:first').trigger('click');
					e.preventDefault();
				});
    }
}

function updateImageSize(currentWindowWidth,currentWindowHeight){
    // Overwrite length & height of the slider-images
    $(".image_slider .images img").each(function(){
            // Current ratio
            ratio = $(this).width()/$(this).height();
            // Min-height
            if(currentWindowHeight<650){ currentWindowHeight = 650; }
            new_image_height = currentWindowHeight;
            new_image_width = ratio*new_image_height;
            // No empty areas?
            if( new_image_width < currentWindowWidth ){
                new_image_width = currentWindowWidth;
                new_image_height = currentWindowWidth/ratio;
            }
            // Overwrite image properties
            $(this).width(new_image_width);
            $(this).height(new_image_height);
    });
}

