for (var i = 0; i < quotes.length; i++) {
    var preload = new Image();
    preload.src = "fileadmin/img/fotos/"+quotes[i].image+".jpg";
}
var next_q;
var quote_div = document.getElementById("quote_div");
var author_img = document.getElementById("author_img");
var quote = document.getElementById("quote");
var quote_sig = document.getElementById("quote_sig");
var fadetime_quotes = 60;
function change_quote() {
    next_q = fadetime_quotes - 1;
    window.setTimeout("fadeout_q();", 33);
}
function fadeout_q() {
    quote_div.style.opacity = next_q / fadetime_quotes;
    quote_div.style.filter = "alpha(opacity="+Math.round(next_q/0.3)+")";
    if (--next_q > 0) {window.setTimeout("fadeout_q();", 33);}
    else {
        if (++current_quote >= quotes.length) {current_quote = 0;}
	author_img.src = "fileadmin/img/fotos/"+quotes[current_quote].image+".jpg";
	author_img.alt = quotes[current_quote].name;
	quote.innerHTML = quotes[current_quote].quote;
	quote_sig.innerHTML = quotes[current_quote].name+"<br/>"+quotes[current_quote].position;
        next_q = 1;
        window.setTimeout("fadein_q();", 33);
    }
}
function fadein_q() {
    quote_div.style.opacity = next_q / fadetime_quotes;
    quote_div.style.filter = "alpha(opacity="+Math.round(next_q/0.3)+")";
    if (++next_q <= fadetime_quotes) {
	window.setTimeout("fadein_q();", 33);
    } else {
        window.setTimeout("change_quote();", 5000);
    }
}
window.setTimeout("change_quote();", 5000);
