var aktiv_top_filme;
var lastId 		= 1;
var speed_steps = 10;
var opacity 	= 0;

var aktiv_showing_movie;
var showing_movie = 0;
var running_automatically_cnt = 1;

var plaetze = new Array();
plaetze[0] = "";

for(var zaehler=1; zaehler<5; zaehler++)
{
	plaetze[zaehler] = new Image();
	plaetze[zaehler].src = "/images/top_filme_top_"+zaehler+".gif";
}

function slide_in(place)
{
	if(aktiv_showing_movie==null) document.body.style.cursor='pointer'; 
	if(place != lastId)
	{
		makeTransparentStop();
		document.images["top_filme"].src = plaetze[place].src;
		document.getElementById("top_filme_place_"+lastId).style.display 	= "none";
		document.getElementById("top_filme_place_"+place).style.display 	= "block";
		lastId = place;
		makeTransparent();
		showing_movie = place;
	}
}

function slide_out()
{
	document.body.style.cursor='default'; 
}

function makeTransparent()
{
	opacity += speed_steps;
	var opacity_moz = opacity*0.01;
	document.getElementById("top_filme_bild_"+lastId).style.filter 		= "Alpha(opacity="+opacity+")";
	document.getElementById("top_filme_bild_"+lastId).style.MozOpacity 	= opacity_moz;
	if(opacity==100)
	{
		makeTransparentStop();
	} else
	{
		aktiv_top_filme = window.setTimeout("makeTransparent()", 100);
	}
}

function makeTransparentStop()
{
	window.clearTimeout(aktiv_top_filme);
	opacity = 0;
}

function zeigeFilm(id)
{
	var url = document.getElementById("link_film_"+id).href;
	if(url) {
		neuesFenster = window.open(url);
		neuesFenster.focus();
	}
}

function startAutomatically() {
	if(running_automatically_cnt == 1 && aktiv_showing_movie == null) {
		running_automatically_cnt++;
		showAutomatically();
	}
}

function showAutomatically() {
	if(showing_movie==4) {
		showing_movie = 1;
	} else {
		showing_movie++;
	}
	aktiv_showing_movie = window.setTimeout("showAutomatically()", 3000);
	slide_in(showing_movie);
}

function stopAutomatically() {
	window.clearTimeout(aktiv_showing_movie);
	aktiv_showing_movie = null;
	running_automatically_cnt--;
}