var imgA=document.createElement('img');
var imgB=document.createElement('img');
imgA.id='firstImg';
imgB.id='secondImg';
imgA.src=ImgArray[0]['Src'];
imgA.title=ImgArray[0]['titleAlt'];
imgA.alt=ImgArray[0]['titleAlt'];
imgA.style.opacity=1;
imgB.src=ImgArray[1]['Src'];
imgB.title=ImgArray[1]['titleAlt'];
imgB.alt=ImgArray[1]['titleAlt'];
imgB.style.opacity=0;
imgA.style.position="absolute";
imgB.style.position="absolute";
var ImgId,ImgId2;
var fOut=1;
var fIn=0;
var Imgfade;
var counter=2;
var arCount=1;
//funktion startet nur wenn sich auf der seite ein IMG tag mit id-Bild1 befindet
//6000 steht für 6 sekunden: nach einem fade vergehen 6 sekunden
if(document.getElementById("Bild1")){
var Contain=document.getElementById('BilderBox');
Contain.removeChild(document.getElementById("Bild1"));
Contain.appendChild(imgB);
Contain.appendChild(imgA);
setTimeout('selectImg()', 6000);
}
//Bild-wahl durch ein counter werden die DIV invertiert
function selectImg(){
if(counter%2==0){
ImgId='secondImg';ImgId2='firstImg';
document.getElementById(ImgId2).alt=ImgArray[arCount]['titleAlt'];
document.getElementById(ImgId2).title=ImgArray[arCount]['titleAlt'];

}else{
ImgId='firstImg';ImgId2='secondImg';
document.getElementById(ImgId).alt=ImgArray[arCount]['titleAlt'];
document.getElementById(ImgId).title=ImgArray[arCount]['titleAlt'];

}

fOut=1;fIn=0;
Imgfade=setInterval('fadeInOut()',10);
}
//interval funktion für's faden
//0.005 ist ersetzbar: desto größer der wert, desto schneller werden die bilder gefadet

function fadeInOut(){
fOut=fOut-0.005;
fIn=fIn+0.005;
if(navigator.appName.indexOf("Microsoft")!= -1){
var Fin=fIn*100;
var Fout=fOut*100;
document.getElementById(ImgId).style.filter = 'alpha(opacity=' + Fin + ')';
document.getElementById(ImgId2).style.filter = 'alpha(opacity=' + Fout + ')';
}
else{
document.getElementById(ImgId).style.opacity=fIn;
document.getElementById(ImgId2).style.opacity=fOut;
}
if(fOut<0 || fIn>1){
clearInterval(Imgfade);
arCount++;
if(arCount>ImgArray.length-1){arCount=0;}
document.getElementById(ImgId2).src=ImgArray[arCount]['Src'];
counter++;setTimeout('selectImg()', 6000);
return;}
}

