jQuery(function()
{
    jQuery(".bildreihe a[rel^='prettyPhoto']").prettyPhoto({theme:'light_square'});
});
function nextFade()
{
    window.clearTimeout(showNext);
    showNext = window.setTimeout("fadeContent("+aktDiv+","+nextDiv+",1)", 0);
    document.getElementById('play_btn').style.display='block';
    document.getElementById('stop_btn').style.display='none';    
}
function prevFade()
{
    if(aktDiv == 1) nextDiv = maxDiv;
    else nextDiv = aktDiv-1;

    window.clearTimeout(showNext);
    showNext = window.setTimeout("fadeContent("+aktDiv+","+nextDiv+",1)", 0);
    document.getElementById('play_btn').style.display='block';
    document.getElementById('stop_btn').style.display='none';    
}
function playFade()
{
    showNext = window.setTimeout("fadeContent("+aktDiv+","+nextDiv+",0)", 0);
    document.getElementById('play_btn').style.display='none';
    document.getElementById('stop_btn').style.display='block';
}
function stopFade()
{
    window.clearTimeout(showNext);
    document.getElementById('play_btn').style.display='block';
    document.getElementById('stop_btn').style.display='none';
}

function fadeContent(iFadeOut, iFadeIn, clear)
{
    jQuery(document).ready(function()
    {
        jQuery("#content_div_"+iFadeOut).fadeOut(1500,'linear');
        jQuery('#content_div_'+iFadeIn).fadeIn(1500,'linear');

        if(iFadeOut!=iFadeIn && iFadeOut!=0)
        {
            document.getElementById('content_img_'+iFadeOut).src='img/content_off.jpg';
            document.getElementById('content_img_'+iFadeIn).src='img/content_act.jpg';
        }
        
            aktDiv = nextDiv;
            nextDiv = aktDiv+1;
            if(nextDiv > maxDiv)
            {
                nextDiv = 1;
            }            
            if(clear == 1)
            {
                window.clearTimeout(showNext);
                return;
            }
            else
            {
                showNext = window.setTimeout("fadeContent("+aktDiv+","+nextDiv+")", 15000);
            }        

    });
}


var scrollSpeed = 100; 		// Speed in milliseconds
var step = 1; 				// How many pixels to move per step
var current = 0;			// The current pixel row
var imageWidth = 100;		// Background image width
var headerWidth = 1280;		// How wide the header is.

//The pixel row where to start a new loop
var restartPosition = -(imageWidth - headerWidth);

function scrollBg(){
	//Go to next pixel row.
	current -= step;
	
	//If at the end of the image, then go to the top.
	if (current == restartPosition){
		current = 0;
	}
	
	//Set the CSS of the header.
	jQuery('#header').css("background-position",current+"px 126px");
}

//Calls the scrolling function repeatedly
var init = setInterval("scrollBg()", scrollSpeed);



