var showBlog = true;
var baseTime = 0;
var closeCounter = 0;
var slogans = Array();
var restart;
var showCase = Math.floor((Math.random() * 3) + 1);
var showCounter = 0;
var start = 0;
var max_slogans = 0;
var num_slogans = 0;
var timer = function (theFunc) {
   	return setTimeout (theFunc, baseTime + (Math.random() * 2000));
}
var pickSlogan = function () {
	clearBoxes();
	if (showBlog) {
		if (showCounter >= num_slogans) {
			if (max_slogans > showCounter) {
				window.location.href="index.php?start=" + start;
 			} else {
				showCounter = 0;
			}
		}
		document.getElementById("content_box_slogan_" + showCase).innerHTML = formatText(slogans[showCounter]);
		document.getElementById("box_slogan_" + showCase).style.visibility = "visible";
		showCounter = showCounter +1;
		var rnd = Math.floor((Math.random() * 5) + 1);
		while (rnd == showCase) {
			rnd = Math.floor((Math.random() * 5) + 1);
		}
		showCase = rnd;
	} else {
		if (closeCounter > 0) {
			closeCounter = closeCounter - 1;
		} else {
			close_text();
		}
	}
	restart();
}
function clearBoxes() {
	for (i = 1; i < 6; ++i) {
		document.getElementById("box_slogan_" + i).style.visibility = "hidden";
		document.getElementById("content_box_slogan_" + i).innerHTML = "";
	}
}
function hideBlog(x) {
	showBlog = false;
	clearBoxes();
	closeCounter = x;
}
function unhideBlog() {
	showBlog = true;
}
function formatText(text) {
	var size = 14;
	var length = text.length;
	if (length < 20) {
		size = 30;
	} else if (length < 40) {
		size = 24;
	} else if (length < 80) {
		size = 20;
	} else if (length < 120) {
		size = 16;
	} else if (length > 240) {
		size = 12;
	} else if (length > 200) {
		size = 13;
	}
	return 	"<span style=\"font-size:" + size + "px; \">" + text + "</span>";
}
function open_text() {
	hideBlog(12);
	document.getElementById("box_titel").style.visibility = "hidden";
	document.getElementById("box_titel_open").style.visibility = "visible";
}
function close_text() {
	document.getElementById("box_titel_open").style.visibility = "hidden";
	document.getElementById("box_titel").style.visibility = "visible";
	unhideBlog();
}
function hideEM(part1, part2) {
	var spamschutz = "mailto:" + part1 + "@" + part2;
	document.location.href = spamschutz;
}
