window.onload=function(){
//	splashImagesToDOM();
}
//-----------------------------
var imgObj = new Array;
function splashImagesToDOM(){
	// first create the images in divs, appended to existing image
	var parentDiv = document.getElementById("splash");
	if(parentDiv){
		for(var i=0; i<imageArray.length; i++) { 
			if(imageArray[i].length){
				var newDiv = document.createElement("DIV");
				parentDiv.appendChild(newDiv);
				newDiv.setAttribute('id','splash' + i);
				newDiv.style.width = "100%";
				newDiv.style.height = "100%";
				newDiv.style.position = "absolute";
				newDiv.style.top = "0";
				newDiv.style.left = "0";
				newDiv.style.background = "url(" + imageArray[i] + ")";
				newDiv.style.backgroundRepeat = "no-repeat";
				newDiv.style.overflow = "hidden";
				newDiv.style.display = "none";
				newDiv.style.zIndex = "auto";
				imgObj.push(document.getElementById("splash" + i));
				imgObj[i].xOpacity = 0;
			}
		}
		// now begin crossfading the images:
		imgObj[0].xOpacity = .99;
		crossFadeSplashImages(0);
	}
}
//-----------------------------
var current=0;
function crossFadeSplashImages(){
	var currentOpacity = imgObj[current].xOpacity;
	var nextIndex = imgObj[current+1]?current+1:0;
	var nextOpacity = imgObj[nextIndex].xOpacity;
	currentOpacity-=.05; 
	nextOpacity+=.05;
	imgObj[nextIndex].style.display = "block";
	imgObj[current].xOpacity = currentOpacity;
	imgObj[nextIndex].xOpacity = nextOpacity;

	setOpacity(imgObj[current]); 
	setOpacity(imgObj[nextIndex]);

	if(currentOpacity<=0) {
		imgObj[current].style.display = "none";
		current = nextIndex;
		setTimeout(crossFadeSplashImages,8000);
	} else {
		setTimeout(crossFadeSplashImages,40);
	}
	function setOpacity(obj) {
		if(obj.xOpacity>.99) {
			obj.xOpacity = .99;
			return;
		}
		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")";
	}
}
//-----------------------------

