
// 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=100; // pause at full opacity in milliseconds
blendfactor=20; // 1 to (100/blendbase) try 70
blendrate=30; // 1 to 100 (milliseconds inbetween frames) try 80
// -----------------------------------------------------------------------------

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/i.length*blendrate).toFixed(0);
	if (s<i.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('spot'+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<i[MCFT].length; y++) {
		extra=document.createElement('img'); 
		extra.setAttribute("src", i[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;
		}
		if (MCFT==0 || MCFT==2) {MCFleft=0; MCFtop=0;} // hand tools
		else if (MCFT==1) {MCFleft=((1-extra.offsetWidth)/2).toFixed(0); MCFtop=0; MCFleft=50;} // entry handles
		// else if (MCFT==2) {MCFleft=0; MCFtop=-25;} // magnetic tools
		extra.style.cssText='opacity: '+startO+'; filter: alpha(opacity='+(startO*100)+'); position: absolute; top: '+MCFtop+'px; left: '+MCFleft+'px;'; 
		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]==(i[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+"]==i["+MCFT+"].length) {MCFz["+MCFT+"]=0;}; trans("+MCFT+");",wait);
	}
}
// end CROSS-OVER image fading slideshow
