
// image CROSS-OVER fading slideshow written by paul@pioneerwebsites.com.au. contact the owner before using.

	// -------- full file names in each pages head script i=new Array(); i[0]=new Array('',''); randomise='yes' or 'no';

// -----------------------------------------------------------------------------
wait=300; // pause at full opacity in milliseconds
blendfactor=5; // 1 to (100/blendbase) try 70
blendrate=40; // 1 to 100 (milliseconds inbetween frames) try 80
// -----------------------------------------------------------------------------
randomise='no';
blendbase=1; // don't change this
s=0;
function startfaderF() { 
/* if (s==0) { // PUT BACKGROUND IMAGE ON SPOTS SO NOT BLANK ONLOADING?
	MCFbg=0; while (MCFbg<i.length) { 
		// MCFdump=i[MCFbg].length; // to use if the [0] below wants to be the last one like [MCFdump-1]
		if (MCFbg!=1) {document.getElementById('spot'+MCFbg).style.background='url("'+i[MCFbg][0]+'") center center no-repeat';}
		MCFbg++;
	}
} */
offset=(wait/MCFi.length*blendrate).toFixed(0);
	if (s<MCFi.length) {
		imagefaderF(s); 
		s++;
		setTimeout('startfaderF();',offset);
	}
}

aobr=new Array(); obr=new Array(); MCFz=new Array(); count=new Array(); ao=new Array(); MCFo=new Array(); aonxt=new Array(); onxt=new Array(); znxt=new Array();

function imagefaderF(MCFT) {
	spot=document.getElementById('slideD'+MCFT); // id of div
	function randOrd(){return (Math.round(Math.random())-0.5);}; if (randomise=='yes') {i[MCFT].sort(randOrd)};
	aobr[MCFT]=blendfactor.toFixed(0); obr[MCFT]=(aobr[MCFT]/100).toFixed(2); MCFz[MCFT]=0;
	for (y=0; y<MCFi[MCFT].length; y++) {
		extra=document.createElement('img'); 
		extra.setAttribute("src", MCFi[MCFT][y]); // alert(i[MCFT][y]);
		extra.setAttribute("id", "fader"+MCFT+y); // alert ("fader"+MCFT+y);
		if (y==0) {
			startO=1; // so the first one arrives turned on, the others arrive turned off (working?)
		} else {
			startO=0;
		}
		extra.style.cssText='opacity: '+startO+'; filter: alpha(opacity='+(startO*100)+'); position: absolute; top: 0px; left: 0px;'; 
		spot.appendChild(extra); // alert('appended');
	}
	// spot.style.cssText='position: relative;';
	count[MCFT]=0; ao[MCFT]=100; MCFo[MCFT]=1; aonxt[MCFT]=0; onxt[MCFT]=0; 
	setTimeout('trans('+MCFT+');',(wait*2))
}

function trans(MCFT) {
	ao[MCFT]-=aobr[MCFT]; MCFo[MCFT]-=obr[MCFT]; MCFo[MCFT]=parseFloat(MCFo[MCFT]).toFixed(2); aonxt[MCFT]=parseFloat(aonxt[MCFT])+parseFloat(aobr[MCFT]); onxt[MCFT]=parseFloat(onxt[MCFT])+parseFloat(obr[MCFT]); onxt[MCFT]=parseFloat(onxt[MCFT]).toFixed(2);
//	document.defaultView.getComputedStyle(document.getElementById('fader'+MCFT+MCFz[MCFT]), null).opacity=MCFo[MCFT]; document.defaultView.getComputedStyle(document.getElementById('fader'+MCFT+MCFz[MCFT]), null).filter='alpha(opacity='+ao[MCFT]+')';
	document.getElementById('fader'+MCFT+MCFz[MCFT]).style.opacity=MCFo[MCFT]; document.getElementById('fader'+MCFT+MCFz[MCFT]).style.filter='alpha(opacity='+ao[MCFT]+')';
	if (MCFz[MCFT]==(MCFi[MCFT].length-1)) {
		znxt[MCFT]=0; 
	} else {
		znxt[MCFT]=MCFz[MCFT]+1;
	}
	document.getElementById('fader'+MCFT+znxt[MCFT]).style.opacity=onxt[MCFT]; document.getElementById('fader'+MCFT+znxt[MCFT]).style.filter='alpha(opacity='+aonxt[MCFT]+')';
	count[MCFT]++;
	if (count[MCFT]<(((100/blendbase+1)-blendfactor)*blendbase)) { // alert(MCFz+'.  pic:'+znxt+'. ao, MCFo: '+ao+','+MCFo+'ao,onext: '+aonxt+','+onxt);
		setTimeout("trans("+MCFT+");",blendrate)
	} else { // alert(MCFz+'.  pic:'+znxt+'. ao, MCFo: '+ao+','+MCFo+'ao,onext: '+aonxt+','+onxt);
		setTimeout("count["+MCFT+"]=0; ao["+MCFT+"]=100; MCFo["+MCFT+"]=1; aonxt["+MCFT+"]=0; onxt["+MCFT+"]=0; MCFz["+MCFT+"]++; if (MCFz["+MCFT+"]==MCFi["+MCFT+"].length) {MCFz["+MCFT+"]=0;}; trans("+MCFT+");",wait);
	}
}
// end CROSS-OVER image fading slideshow
