function rand (min, max) {
	return Math.floor(Math.random() * (max - min + 1)) + min;
}


var i = rand(0, 9);
var z = 0;
var x = 100;

var FotoUrl = new Array();
FotoUrl[0] = "http://www.schoenstatt-mannesjugend.de/wjt/wp-content/themes/jmj2011/img/wjtthumb1.jpg";
FotoUrl[1] = "http://www.schoenstatt-mannesjugend.de/wjt/wp-content/themes/jmj2011/img/wjtthumb2.jpg";
FotoUrl[2] = "http://www.schoenstatt-mannesjugend.de/wjt/wp-content/themes/jmj2011/img/wjtthumb3.jpg";
FotoUrl[3] = "http://www.schoenstatt-mannesjugend.de/wjt/wp-content/themes/jmj2011/img/wjtthumb4.jpg";
FotoUrl[4] = "http://www.schoenstatt-mannesjugend.de/wjt/wp-content/themes/jmj2011/img/wjtthumb5.jpg";
FotoUrl[5] = "http://www.schoenstatt-mannesjugend.de/wjt/wp-content/themes/jmj2011/img/wjtthumb6.jpg";
FotoUrl[6] = "http://www.schoenstatt-mannesjugend.de/wjt/wp-content/themes/jmj2011/img/wjtthumb7.jpg";
FotoUrl[7] = "http://www.schoenstatt-mannesjugend.de/wjt/wp-content/themes/jmj2011/img/wjtthumb8.jpg";
FotoUrl[8] = "http://www.schoenstatt-mannesjugend.de/wjt/wp-content/themes/jmj2011/img/wjtthumb9.jpg";
FotoUrl[9] = "http://www.schoenstatt-mannesjugend.de/wjt/wp-content/themes/jmj2011/img/wjtthumb10.jpg";

var thumbs = new Array();

function init_change()
{
  for (z = 0; z < FotoUrl.length; z++)
  {
    thumbs[z] = new Image();
    thumbs[z].src = FotoUrl[z];
  }

document.getElementById("inner_thumb").src = thumbs[i].src;
i++;
window.setTimeout("change()", 20000);
}

function change()
{
if ( i <= 9)
{
fade_out();
}
else
{
i = 0;
window.setTimeout("change()", 0);
}
}

function fade_out()
{
if ( x > 0 )
{
document.getElementById("inner_thumb").style.opacity = x/100;
document.getElementById("inner_thumb").style.zIndex = 1;
x = x - 2;
window.setTimeout("fade_out()", 0);
}
else
{
document.getElementById("inner_thumb").src = thumbs[i].src;
document.getElementById("inner_thumb").style.zIndex = 1;
document.getElementById("inner_thumb").style.opacity = x/100;
i++;
x = 0;
fade_in();
}
}


function fade_in(i)
{
if ( x < 100 )
{
document.getElementById("inner_thumb").style.opacity = x/100;
document.getElementById("inner_thumb").style.zIndex = 1;
x = x+2;
window.setTimeout("fade_in()", 0);
}
else
{
document.getElementById("inner_thumb").style.opacity = x/100;
document.getElementById("inner_thumb").style.zIndex = 1;
x = 100;
i++;
window.setTimeout("change()", 20000);
}
}





var abstand = 0;
zaehler = 0;

function pull_buehne()
{
if ( abstand <= 96 )
{
setTimeout("exact_pull()",10000);
}
else
{
setTimeout("exact_push()",10000);
}
}

function exact_pull()
{
if ( zaehler <= 32 )
{
document.getElementById("ticker_buehne").style.marginTop = "-" + abstand + "px";
abstand++;
zaehler++;
setTimeout("exact_pull()",50);
}
else
{
zaehler = 0;
setTimeout("pull_buehne()",1000);
}
}


function exact_push()
{
if ( abstand >= 0 )
{
document.getElementById("ticker_buehne").style.marginTop = "-" + abstand + "px";
abstand = abstand-1;
setTimeout("exact_push()",3);
}
else
{
zaehler = 0;
setTimeout("pull_buehne()",10000);
}
}






var oldWindowOnload = window.onload;

window.onload = function () {
    if (typeof(oldWindowOnload) == "function") {
        oldWindowOnload();
    }

    init_change();
    pull_buehne();

};
