var activelayer=0;
var fade=100;
var cfade=100;
var timer=null;
var v=0;
var start=0;
var url="http://"+location.host+"/scripts/frontend/index.php3?ACTION=imageShow&ID=index.php3?ACTION=imageShow&textid=123267&width="+parseInt(444)+"&height="+parseInt(290)+"&method=cut&ID=";
var url_thumb="http://"+location.host+"/scripts/frontend/index.php3?ACTION=imageShow&ID=index.php3?ACTION=imageShow&textid=123267&width="+parseInt(444)+"&height="+parseInt(290)+"&method=cut&ID=";

onload = function() {
    var bild = new Image;
    bild.src = url + inhalt[0];
    bild.onload = function() {
        makeInhalt();
    }
}
function createPic(i) {
    var newbild = document.createElement("IMG");
    newbild.src = "/domains/" + location.host + "/images/corporate/rahmen.png";
    newbild.style.background = "url('" + url + inhalt[i] + "') 33px 33px no-repeat";
    newbild.id = "mod_ajaxgalery_img" + i;
    newbild.alt = kommentare[i];
    newbild.title = kommentare[i];

    var newbildlink = document.createElement("A");
    newbildlink.title = "mod_ajaxgalery_imglink" + i;
    if (bildlinks[i] != "") {
        newbildlink.href = "javascript:var v = parseInt(this.id.replace('mod_ajaxgalery_imglink', '')); location.href = bildlinks[v];";
    }
    else {
        newbildlink.href = "javascript:openCentered('index.php3?ACTION=imageShowFrame&textid=123267&ID=" + inhalt[i]+"' , 480, 480);";
    }
    newbildlink.appendChild(newbild);
    return newbildlink;
}
function makeInhalt() {
	/**
	*	Inhaltsverzeichnis bauen
	*/
	newbild = createPic(0);
	document.getElementById("mod_ajaxgalery_bild2").appendChild(newbild);
	document.getElementById("mod_ajaxgalery_bild").appendChild(newbild);
	timer=setTimeout("fadepicture();", 1000);
}
function swap() {
    start = start + 1;
    if (start >= inhalt.length) {
        start = 0;
    }
    var newbild = document.createElement("IMG");
    newbild.src = url + inhalt[start];
    newbild.onload = function() { swap2(); }
}
function swap2() {
    document.getElementById("mod_ajaxgalery_bild").innerHTML = "";
    document.getElementById("mod_ajaxgalery_bild").appendChild(createPic(start));
	timer=setTimeout("fadepicture();", 5000);
	}
function fadepicture() {
	e=document.getElementById("mod_ajaxgalery_bild2");
	if (fade==100) {
		var mozo=1;
		}
	else {
		var mozo="0."+fade;
		}
	if (fade<10) {
		mozo="0.0"+fade;
		}
	e.style.filter="Alpha(opacity="+fade+");";
	e.style.opacity=mozo;
	if (fade>0) {
		fade-=10;
		timer=setTimeout("fadepicture();", 10);
		}
	else {
	    fade = 100;
	    document.getElementById("mod_ajaxgalery_bild2").innerHTML = document.getElementById("mod_ajaxgalery_bild").innerHTML;
		document.getElementById("mod_ajaxgalery_bild2").style.filter="Alpha(opacity=100);";
		document.getElementById("mod_ajaxgalery_bild").style.filter="Alpha(opacity=100);";
		document.getElementById("mod_ajaxgalery_bild2").style.opacity=1;
		document.getElementById("mod_ajaxgalery_bild").style.opacity=1;
		swap();
		}
	}