
function getNextImage(slot){
	
	var tempArray = new Array();
	var tempVar = false;
	var z = 0;

	for(x=1; x <= totalImages; x++){
		for(y=1; y <= displayImages; y++){
			tempVar = false;
			var myPic = eval("pic"+x);
			var myCur = eval("document.myForm.cur"+y);	
			if(myCur.value == myPic){
				tempVar = true;
				break;
			}
		}
		if(tempVar == false){
			tempArray[z] = myPic;
			z++;			
		}
	}

	var tempRnd = Math.round((tempArray.length-1) * Math.random());	
	var tempCur = eval("document.myForm.cur"+slot);
	var curImg = tempArray[tempRnd];
	tempCur.value = curImg;
	return curImg;
}

function changeImage1(){
   
   img1 = getNextImage(1);
   
   if (document.all){
      document.images.switchImage1.style.filter="blendTrans(duration=2)";
      document.images.switchImage1.style.filter="blendTrans(duration=crossFadeDuration)";
      document.images.switchImage1.filters.blendTrans.Apply();     
   }
   document.images.switchImage1.src = preLoad[img1].src;
   if (document.all){
      document.images.switchImage1.filters.blendTrans.Play();
   }

   var1 = setTimeout('changeImage1()', Math.round(maxSeconds*Math.random())+minSeconds );
}

function changeImage2(){

   img2 = getNextImage(2);
   
   if (document.all){
      document.images.switchImage2.style.filter="blendTrans(duration=2)";
      document.images.switchImage2.style.filter="blendTrans(duration=crossFadeDuration)";
      document.images.switchImage2.filters.blendTrans.Apply();     
   }
   document.images.switchImage2.src = preLoad[img2].src;
   if (document.all){
      document.images.switchImage2.filters.blendTrans.Play();
   }

   var2 = setTimeout('changeImage2()', Math.round(maxSeconds*Math.random())+minSeconds );
}

function changeImage3(){
 
   img3 = getNextImage(3);
   
   if (document.all){
      document.images.switchImage3.style.filter="blendTrans(duration=2)";
      document.images.switchImage3.style.filter="blendTrans(duration=crossFadeDuration)";
      document.images.switchImage3.filters.blendTrans.Apply();     
   }
   document.images.switchImage3.src = preLoad[img3].src;
   if (document.all){
      document.images.switchImage3.filters.blendTrans.Play();
   }

   var3 = setTimeout('changeImage3()', Math.round(maxSeconds*Math.random())+minSeconds );
}

function changeImage4(){
   
   img4 = getNextImage(4);

   if (document.all){
      document.images.switchImage4.style.filter="blendTrans(duration=2)";
      document.images.switchImage4.style.filter="blendTrans(duration=crossFadeDuration)";
      document.images.switchImage4.filters.blendTrans.Apply();     
   }
   document.images.switchImage4.src = preLoad[img4].src;
   if (document.all){
      document.images.switchImage4.filters.blendTrans.Play();
   }

   var4 = setTimeout('changeImage4()', Math.round(maxSeconds*Math.random())+minSeconds );
}

function changeImage5(){
   
	img5 = getNextImage(5);

   if (document.all){
      document.images.switchImage5.style.filter="blendTrans(duration=2)";
      document.images.switchImage5.style.filter="blendTrans(duration=crossFadeDuration)";
      document.images.switchImage5.filters.blendTrans.Apply();     
   }
   document.images.switchImage5.src = preLoad[img5].src;
   if (document.all){
      document.images.switchImage5.filters.blendTrans.Play();
   }

   var5 = setTimeout('changeImage5()', Math.round(maxSeconds*Math.random())+minSeconds );
}

document.write("<form name='myForm' method='post' action=''>");
for (i = 1; i <= displayImages; i++){
	document.write("<IMG SRC='"+ preLoad[i].src +"' NAME='switchImage"+(i)+"' ID='switchImage"+(i)+"'>");
	var tempObj = eval("img"+i);
	tempObj = i;
	document.write("<input name='cur"+i+"' type='hidden' id='cur"+i+"' value='"+i+"'>");	
}
document.write("</form>");
function getRndTime(){
	var time = Math.round(initDelayMax*Math.random())+initDelayMin;
	return time;
}
function startLoops(){
	self.setTimeout('changeImage2()', getRndTime());
	self.setTimeout('changeImage3()', getRndTime());
	self.setTimeout('changeImage4()', getRndTime());
	self.setTimeout('changeImage5()', getRndTime());
	self.setTimeout('changeImage1()', getRndTime());
}

window.onload = startLoops;
