(function($) {
  $.fn.fullBg = function(){
    var bgImg = $(this);
    
    bgImg.addClass('fullBg');
    
    function resizeImg() {
      var imgwidth = bgImg.width();
      var imgheight = bgImg.height();
      
      var winwidth = $(window).width();
      var winheight = $(window).height();
      
      var widthratio = winwidth / imgwidth;
      var heightratio = winheight / imgheight;
      
      var widthdiff = heightratio * imgwidth;
      var heightdiff = widthratio * imgheight;
    
      if(heightdiff>winheight) {
        bgImg.css({
          width: winwidth+'px',
          height: heightdiff+'px'
        });
      } else {
        bgImg.css({
          width: widthdiff+'px',
          height: winheight+'px'
        });    
      }
    }
    resizeImg();
    $(window).resize(function() {
      resizeImg();
    });
  };
})(jQuery);

/**
* Fullscreenr - lightweight full screen background jquery plugin
* By Jan Schneiders
* Version 1.0
* www.nanotux.com
**/
(function($){	
	$.fn.fullscreenr = function(options) {
		if(options.height === undefined) alert('Please supply the background image height, default values will now be used. These may be very inaccurate.');
		if(options.width === undefined) alert('Please supply the background image width, default values will now be used. These may be very inaccurate.');
		if(options.bgID === undefined) alert('Please supply the background image ID, default #bgimg will now be used.');
		var defaults = { width: 1280,  height: 1024, bgID: 'bgimg' };
		var options = $.extend({}, defaults, options); 
		$(document).ready(function() { $(options.bgID).fullscreenrResizer(options);	});
		$(window).bind("resize", function() { $(options.bgID).fullscreenrResizer(options); });		
		return this; 		
	};	
	$.fn.fullscreenrResizer = function(options) {
		// Set bg size
		var ratio = options.height / options.width;	
		// Get browser window size
		var browserwidth = $(window).width();
		var browserheight = $(window).height();
		// Scale the image
		if ((browserheight/browserwidth) > ratio){
		    $(this).height(browserheight);
		    $(this).width(browserheight / ratio);
		} else {
		    $(this).width(browserwidth);
		    $(this).height(browserwidth * ratio);
		}
		// Center the image
		$(this).css('left', (browserwidth - $(this).width())/2);
		$(this).css('top', (browserheight - $(this).height())/2);
		return this; 		
	};
})(jQuery);

jQuery.noConflict();
jQuery(document).ready(function()
{
  //jQuery("#background").fullBg();
  
  var FullscreenrOptions = {  width: 963, height: 624, bgID: '#background' };
  jQuery.fn.fullscreenr(FullscreenrOptions);
  
        /*
	 * SEO Text unten
	 */
	jQuery('.seo_text h1').click(function() {
        jQuery('.seo_text .text').slideToggle('slow', function() {
        	if ( jQuery('.seo_text .text').is(':visible')){
                var pos=jQuery("body").height();
                jQuery('html,body').animate({scrollTop: pos}, 500);
            }
        });
         });
});
