var ie5=(document.getElementById && document.all);
var ns6=(document.getElementById && !document.all);
var timeDelay = 6; // change delay time in seconds


var howMany = Pix.length;

timeDelay *= 1000; // Timedelay to change images in seconds

var PicCurrent = new Image();

PicCurrent.src = Pix[PicCurrentNum];

var nPlus = 5   //the % of fading for each step
var speed = 55  //the speed

// You don't have to edit below this line
var nOpac = 100

var i = "ChangingPixTwo";

// Preload images
for (count=0; count < howMany; count++) {
    var preload = new Image();
    preload.src = Pix[count];
}

function FadeIn() {
	var imgs = document[i];
    var opacity = nOpac+nPlus;
    
    nOpac = opacity;
    
    if (opacity < 100) {
		setTimeout('FadeIn()',speed);
	}
    
    if (opacity < 100) {
		nPlus=+nPlus;
	}
	
	if(ie5){
        imgs.style.filter="alpha(opacity=0)";
		imgs.filters.alpha.opacity = opacity;
    }
    if(ns6){
		imgs.style.MozOpacity = opacity / 100;
    }

}

function FadeOut() {
	var imgs = document[i];
    var opacity = nOpac+nPlus;
    
    nOpac = opacity;
     
	if (opacity >= 0) {
		setTimeout('FadeOut()',speed);
	}
    
    if (opacity>100 || opacity<0) {
		nPlus=-nPlus;
	}
	
	if(ie5){
        imgs.style.filter="alpha(opacity=0)";
		imgs.filters.alpha.opacity = opacity;
    }
    if(ns6){
		imgs.style.MozOpacity = opacity / 100;
    }

}

function startPix() {
	slideshow();
	setInterval("doTransition()", timeDelay);
}

function doTransition() {
	// Determining which image to transition
	switch (i) {
		case "ChangingPixOne" :
			i = "ChangingPixThree";
			break;
		case "ChangingPixThree" :
			i = "ChangingPixTwo";
			break;
		case "ChangingPixTwo" :
			i = "ChangingPixOne";
			break;
		default:
			i = "ChangingPixOne";
	}
	
	if (document[i] == undefined) i = "ChangingPixTwo";
	
	// Doing Fadeout and then change image
	nOpac=100;
	FadeOut();
	setTimeout("slideshow()",2000);
}
function slideshow() {
	PicCurrentNum++;

	if (PicCurrentNum == howMany) {
		PicCurrentNum = 0;
	}

	PicCurrent.src = Pix[PicCurrentNum];
	
	document[i].src = PicCurrent.src;
	
	nOpac = 0;
	FadeIn();
}

