//image shuffler
gblPhotoShufflerDivId = "photodiv";
gblPhotoShufflerImgId = "photoimg"; 
gblImg = new Array("./user_files/images/mainimgs/img1.jpg","./user_files/images/mainimgs/img2.jpg","./user_files/images/mainimgs/img3.jpg","./user_files/images/mainimgs/img4.jpg","./user_files/images/mainimgs/img5.jpg","./user_files/images/mainimgs/img6.jpg");
gblPauseSeconds = 7.25;
gblFadeSeconds = .85;
gblRotations = 100;
gblDeckSize = gblImg.length;
gblOpacity = 100;
gblOnDeck = 0;
gblStartImg=null;
gblImageRotations = gblDeckSize * (gblRotations+1);

window.onload=photoShufflerLaunch;

function photoShufflerLaunch()
{
    
	theimg = document.getElementById(gblPhotoShufflerImgId);
	gblStartImg = theimg.src; // save away to show as final image
	document.getElementById(gblPhotoShufflerDivId).style.backgroundImage='url(' + gblImg[gblOnDeck] + ')';
	setTimeout("photoShufflerFade()",gblPauseSeconds*1000);
}
 
function photoShufflerFade()
{
	theimg = document.getElementById(gblPhotoShufflerImgId);
	fadeDelta = 100 / (30 * gblFadeSeconds);
	
	if (gblOpacity < 2*fadeDelta ) 
	{
		gblOpacity = 100;
		if (gblImageRotations < 1) return;
	 
		photoShufflerShuffle();
		setTimeout("photoShufflerFade()",gblPauseSeconds*1000);
	}
	else
	{
	 	gblOpacity -= fadeDelta;
		setOpacity(theimg,gblOpacity);
	 	setTimeout("photoShufflerFade()",30);  // 1/30th of a second
	}
}
function photoShufflerShuffle()
{
	thediv = document.getElementById(gblPhotoShufflerDivId);
	theimg = document.getElementById(gblPhotoShufflerImgId);
	theimg.src = gblImg[gblOnDeck];
	setOpacity(theimg,100);
	gblOnDeck = ++gblOnDeck % gblDeckSize;
	if (--gblImageRotations < 1)
	{
	gblImg[gblOnDeck] = gblStartImg;
	}
	thediv.style.backgroundImage='url(' + gblImg[gblOnDeck] + ')';
}
function setOpacity(obj, opacity) {
	opacity = (opacity == 100)?99.999:opacity;
	obj.style.filter = "alpha(opacity:"+opacity+")";
	obj.style.KHTMLOpacity = opacity/100;
	obj.style.MozOpacity = opacity/100;
	obj.style.opacity = opacity/100;
}



