// set the starting image.
var i = 0;
var cur_image = 0;

// The array of div names which will hold the images.
var div_slide = new Array('slideshow_1', 'slideshow_2');

// The number of images in the array.
var NumOfDivs = div_slide.length;
var NumOfImages = image_slide.length;

// The Fade Function
function SwapDiv(x,y) {
	$(div_slide[x]).appear({duration: 3.0 });
	$(div_slide[y]).fade({duration: 3.0 });
}

// the onload event handler that starts the fading.
function StartSlideShow() {
	var onLoadVal = $$('body')[0].readAttribute('onload'); 
        
	if(startImageFlow === true || onLoadVal == 'StartSlideShow();') {
		new Effect.Appear(div_slide[0], { duration:0.3, afterFinish: function() { play = setInterval('Play()',wait); } });
	} else {
		setTimeout('StartSlideShow()',500);
	}
}

function Play() {

        var divShow, divHide;
	var imageShow, imageHide;

	divShow = i+1;
	divHide = i;

        i++;
	if (divShow == NumOfDivs) {
		divShow = 0;
		i = 0;
	}

        LoadNextImage( divShow );

	SwapDiv(divShow,divHide);
}

function LoadNextImage(div) {

        if(cur_image+1 == NumOfImages)
          cur_image = -1;

        $(div_slide[div]).style.backgroundImage = 'url(\'new/images/banner/' + image_slide[cur_image+1] + '.png\')';
        
        cur_image++;
}



