function home_do_fade(l, t, g, n, c) {
	if (g > n) {
		n++;
	} else {
		n--;
	}
	l.opacity = 1 - n / t;
	l.filter = "alpha(opacity="+Math.round(100 * (1 - n / t))+")";
	if (n === g) {
		c();
	} else {
		setTimeout(function () {home_do_fade(l, t, g, n, c);}, 33);
	}
}

function home_show(e, p, l, text_array, i) {
	e.innerHTML = text_array[i][0];
	p.style.background = 'url(/fileadmin/img/content/'+text_array[i][1]+') no-repeat';
	
	setTimeout(function () {
		home_do_fade(l, 30, 0, 30, function () {
			home_show(e, p, l, text_array, ++i % text_array.length);
			home_do_fade(l, 30, 30, 0, function() {});
		});
	}, 7000);
}

function home_init(text_array) {
	var e = document.getElementById('home-content');
	var p = document.getElementById('pageContainer');
	var l = document.createElement('div');
	p.appendChild(l);
	l = l.style;
	l.height = '100%';
	l.width = '100%';
	l.position = 'absolute';
	l.background = '#f8f8f8';
	l.opacity = 0;
	l.filter = "alpha(opacity=0)";
	l.zIndex = 1;
	home_show(e, p, l, text_array, 0);
}

