function x_accordion(text, nav)
{	
        if(!text.length && !nav.length) return;
        text.hide();
        nav.click(function()
        {
                nav.removeClass("accordion_current");
                text.not(':hidden').slideUp('slow', function()
                        {
			    // on background -----------------------------------
			    $(this).prev().removeClass('navon');
			    $(this).prev().addClass('nav');     
                        });
                var accordion_current = $(this);
                $(this).next()
                        .not(":visible")
                        .slideDown('slow', function()
                        {
			    // on active ---------------------------------------
                            accordion_current.addClass('accordion_current');

			    $(this).prev().removeClass('nav');
			    $(this).prev().addClass('navon');
			    var id = $(this).prev().attr('id');
			    window.setTimeout(function () { load_img(id, "/bg.jpg"); }, 500);                            
                        });
            
        });
}

function nav_mouse_out(obj)
{
	if($(obj).next().css('height') == 'auto')
	{
		$(obj).removeClass('navon');
		$(obj).addClass('nav');
	}
}

function nav_start(index)
{
	nav = $('.nav')[index];
	$('#img2').hide();
	$(nav).next().not(":visible").slideDown('fast');
	$(nav).addClass('accordion_current');
	$(nav).removeClass('nav');
	$(nav).addClass('navon');
	var id = $(nav).attr('id');
	window.setTimeout(function () { load_img(id, "/bg.jpg"); }, 500);                            	
}

function load_img(id, img)
{
	var img2 = $('#img2');
	if(img2.attr('src') != id + img)
	{
		img2.fadeOut('slow', function()
                {
			wait_img();
			img2.attr('src', id + img);
		});
	}
}

function wait_img()
{
	var color = $('#load').css('color');
	if($('#img2').css('opacity') == 0)
	{
	   if(color == 'black')
	   {
		$('#load').css('color', 'white');
	   }
	   else
	   {
		$('#load').css('color', 'white');
	   }
	   window.setTimeout(function () { wait_img(); }, 500);	
	}	
	else{$('#load').css('color', 'white');}
	}
	
/* Funktionen für das Hintergrundbild ----------------------------------------------------------------------------------------------*/
function Fensterweite() //Ermittelt die aktuelle Fensterbreite
{
  	if (window.innerWidth) 
	{
		return window.innerWidth;
  	} 
  	else if (document.body && document.body.offsetWidth) 
	{
		return document.body.offsetWidth;
  	} 
	else 
	{
		return 0;
  	}
}

function Fensterhoehe() //Ermittelt die aktuelle Fensterhˆhe
{
	if (window.innerHeight) 
	{
	    return window.innerHeight;
	} 
	else if (document.body && document.body.offsetHeight) 
	{
	    return document.body.offsetHeight;
	} 
	else 
	{
	    return 0;
	}
}

function neuAufbau() //Passt das Hintergrundbild der neuen Fenstergrˆﬂe an
	{
	var nav_height = parseInt($("$#navigation").css('height'));
	var nav_top = parseInt($("$#navigation").css('top'));
	var nav = nav_top + nav_height;
	
	window_width = Fensterweite();
	window_height = Fensterhoehe();
	
	if(window_height < nav){window_height = nav;}
		
	image_height = 1416;
	image_width = 2128;
	new_image_height = image_height * window_width / image_width;
	new_image_width = window_width;
	
	if(new_image_height < window_height)
		{
		new_image_height = window_height;
		new_image_width = image_width * window_height / image_height;
		}

	new_image_width = parseInt(new_image_width);
	new_image_height = parseInt(new_image_height);
	
	$('#img1').css('height', new_image_height + 'px');
	$('#img1').css('width', new_image_width + 'px');
	$('#img2').css('height', new_image_height + 'px');
	$('#img2').css('width', new_image_width + 'px');
	}
	
/* ‹berwachung von Netscape initialisieren */
if (!window.Weite && window.innerWidth) //Reagiert auf ƒnderungen der Fenstergrˆﬂe
	{
	window.onresize = neuAufbau;
	}
	
