var slideShowSpeed = 10000
var maximal = 2
var t
var step = 0
var step2 = 0
var step3 = 0
var step4 = 0
var j = 0
function pause(millis) {
	var date = new Date();
	var curDate = null;
	
	do { curDate = new Date(); } 
	while(curDate-date < millis);
}

function fade(step) {
	step = step || 0;

    document.getElementById("slideshow1").style.opacity = 1-step/100;
    document.getElementById("slideshow2").style.opacity = 1-step/100;
    document.getElementById("slideshow3").style.opacity = 1-step/100;
    document.getElementById("slideshow1").style.filter = "alpha(opacity=" + 1-step + ")"; // IE
    document.getElementById("slideshow2").style.filter = "alpha(opacity=" + 1-step + ")"; // IE
    document.getElementById("slideshow3").style.filter = "alpha(opacity=" + 1-step + ")"; // IE

    step = step + 1;

    if (step <= 100) {
    	window.setTimeout(function () { fade(step); }, 5);
    }
    else {
    	document.getElementById("slideshow4").style.display='block';
		document.getElementById("slideshow5").style.display='block';
		document.getElementById("slideshow6").style.display='block';
		document.getElementById("slideshow1").style.display='none';
		document.getElementById("slideshow2").style.display='none';
		document.getElementById("slideshow3").style.display='none';
		document.getElementById("slideshow4").style.opacity='0';
		document.getElementById("slideshow5").style.opacity='0';
		document.getElementById("slideshow6").style.opacity='0';
		step = step || 100;
		step2 = step-100;
    	document.getElementById("slideshow4").style.opacity = step2/100;
    	document.getElementById("slideshow5").style.opacity = step2/100;
    	document.getElementById("slideshow6").style.opacity = step2/100;
    	document.getElementById("slideshow4").style.filter = "alpha(opacity=" + step2 + ")"; // IE
    	document.getElementById("slideshow5").style.filter = "alpha(opacity=" + step2 + ")"; // IE
    	document.getElementById("slideshow6").style.filter = "alpha(opacity=" + step2 + ")"; // IE
	
	    step = step + 1;
	
	    if (step <= 200) {
	    	window.setTimeout(function () { fade(step); }, 5);
	    }
    }
}

function fade2(step3) {
	step3 = step3 || 0;
    document.getElementById("slideshow4").style.opacity = 1-step3/100;
    document.getElementById("slideshow5").style.opacity = 1-step3/100;
    document.getElementById("slideshow6").style.opacity = 1-step3/100;
    document.getElementById("slideshow4").style.filter = "alpha(opacity=" + 1-step3 + ")"; // IE
    document.getElementById("slideshow5").style.filter = "alpha(opacity=" + 1-step3 + ")"; // IE
    document.getElementById("slideshow6").style.filter = "alpha(opacity=" + 1-step3 + ")"; // IE

    step3 = step3 + 1;

    if (step3 <= 100) {
    	window.setTimeout(function () { fade2(step3); }, 5);
    }
    else {
    	document.getElementById("slideshow1").style.display='block';
		document.getElementById("slideshow2").style.display='block';
		document.getElementById("slideshow3").style.display='block';
		document.getElementById("slideshow4").style.display='none';
		document.getElementById("slideshow5").style.display='none';
		document.getElementById("slideshow6").style.display='none';
		document.getElementById("slideshow1").style.opacity='0';
		document.getElementById("slideshow2").style.opacity='0';
		document.getElementById("slideshow3").style.opacity='0';
		step3 = step3 || 100;
		step4 = step3-100;
    	document.getElementById("slideshow1").style.opacity = step4/100;
    	document.getElementById("slideshow2").style.opacity = step4/100;
    	document.getElementById("slideshow3").style.opacity = step4/100;
    	document.getElementById("slideshow1").style.filter = "alpha(opacity=" + step4 + ")"; // IE
    	document.getElementById("slideshow2").style.filter = "alpha(opacity=" + step4 + ")"; // IE
    	document.getElementById("slideshow3").style.filter = "alpha(opacity=" + step4 + ")"; // IE
	
	    step3 = step3 + 1;
	
	    if (step3 <= 200) {
	    	window.setTimeout(function () { fade2(step3); }, 5);
	    }
    }
}

function runSlideShow()
{
	j = j + 1
	if (j > maximal) j=1
	
	if (j == 1) {
		fade();
	}
	else if (j == 2) {
		fade2();
	}
	
	t = setTimeout('runSlideShow()', slideShowSpeed)
}