// JavaScript Document

// slideshow
var images = new Array;
var imageIndex = 0;
var layerSwitcher = 1;
var imageCount;

function initSlideShow() {
	var showcase = $('div#home_slideshow');
	imageCount = $('div#home_slideshow img').length;
	$('div#home_slideshow').children('.slide').each(function(i){
  	images.push(this.src);
		$(this).remove();
	}); 
	$('div#home_slideshow_layer').append('<img id="home_slideshow_layer_image" src="'+images[0]+'"/>');
	slideShow();
}

function slideShow() {
	setTimeout('slideShow()' , 4000);
	if(imageIndex>(images.length-1)) {
		imageIndex = 0;
	}
	var background = 'url(\''+images[imageIndex]+'\')';
	if(layerSwitcher==1) {
		$('div#home_slideshow').css("background",background);
		$('div#home_slideshow_layer').fadeOut(1000);
	} else {
		$('img#home_slideshow_layer_image').get(0).src = images[imageIndex];
		$('div#home_slideshow_layer').fadeIn(1000);
	}
	layerSwitcher *= -1;
	imageIndex++;
}
