$(document).ready(function(){
	
  // fixed navigation
  $(".navigation").css({
	  'position':'fixed',
	  'margin-left':'240px',
	  'z-index':'10'
  });
	
  // image 
  var imagewidth = $(".hintergrund .hintergrundbild img").width();
  var imageheight = $(".hintergrund .hintergrundbild img").height();
  var ratio = imageheight / imagewidth;	

  // browser
  var browserwidth = $(window).width()+18;
  var browserheight = $(window).height()+18;

  // scale the image
  if ((browserheight/browserwidth) > ratio){
    $(".hintergrund .hintergrundbild img").height(browserheight);
    $(".hintergrund .hintergrundbild img").width(browserheight / ratio);
  } else {
    $(".hintergrund .hintergrundbild img").width(browserwidth);
    $(".hintergrund .hintergrundbild img").height(browserwidth * ratio);
  }
  
  // center the image
  $(".hintergrund .hintergrundbild img").css('left', (browserwidth - $(this).width())/2);
  $(".hintergrund .hintergrundbild img").css('top', (browserheight - $(this).height())/2);

  // resize  
  $(window).resize(function(){
    // image 
    var imagewidth = $(".hintergrund .hintergrundbild img").width();
    var imageheight = $(".hintergrund .hintergrundbild img").height();
    var ratio = imageheight / imagewidth;	

    // browser
    var browserwidth = $(window).width()+18;
    var browserheight = $(window).height()+18;

    if ((browserheight/browserwidth) > ratio){
      $(".hintergrund .hintergrundbild img").height(browserheight);
      $(".hintergrund .hintergrundbild img").width(browserheight / ratio);
    } else {
      $(".hintergrund .hintergrundbild img").width(browserwidth);
      $(".hintergrund .hintergrundbild img").height(browserwidth * ratio);
    }
    // center the image
    $(".hintergrund .hintergrundbild img").css('left', (browserwidth - $(this).width())/2);
    $(".hintergrund .hintergrundbild img").css('top', (browserheight - $(this).height())/2);
  });	
});
