var pix = new Array();
var nPix=16;
var nSets = 4;
var timePreFirstFade=2;
var intSecsBwFades=2;
var intSecsBwCycles = 5;

pix[0]=new Image();
pix[0].src="../graphics/sp6090A0.gif"; // 69889A = grey blank ... B3B37F = gold blank
pix[1]=new Image();
pix[2]=new Image();
pix[3]=new Image();
pix[4]=new Image();
pix[5]=new Image();
pix[6]=new Image();
pix[7]=new Image();
pix[8]=new Image();
pix[9]=new Image();
pix[10]=new Image();
pix[11]=new Image();
pix[12]=new Image();
pix[13]=new Image();
pix[14]=new Image();
pix[15]=new Image();
pix[16]=new Image();

function loadPics() 
	{
	pix[1].src="../diaporama/lafayette_diapho_01_tl.jpg";
	pix[2].src="../diaporama/lafayette_diapho_01_tr.jpg";
	pix[3].src="../diaporama/lafayette_diapho_01_br.jpg";
	pix[4].src="../diaporama/lafayette_diapho_01_bl.jpg";

	pix[5].src="../diaporama/lafayette_diapho_02_tl.jpg";
	pix[6].src="../diaporama/lafayette_diapho_02_tr.jpg";
	pix[7].src="../diaporama/lafayette_diapho_02_br.jpg";
	pix[8].src="../diaporama/lafayette_diapho_02_bl.jpg";

	pix[9].src="../diaporama/lafayette_diapho_03_tl.jpg";
	pix[10].src="../diaporama/lafayette_diapho_03_tr.jpg";
	pix[11].src="../diaporama/lafayette_diapho_03_br.jpg";
	pix[12].src="../diaporama/lafayette_diapho_03_bl.jpg";

	pix[13].src="../diaporama/lafayette_diapho_04_tl.jpg";
	pix[14].src="../diaporama/lafayette_diapho_04_tr.jpg";
	pix[15].src="../diaporama/lafayette_diapho_04_br.jpg";
	pix[16].src="../diaporama/lafayette_diapho_04_bl.jpg";
	}

var thisSet = 2; // first set to change to is 2
var pass=0; // incremented in FadeQuarterPix, so for first set only, pass = 2 on first cycle (ie skips topleft)
var whichTopLeft=5;
var whichTopRight=6;
var whichBottomLeft=7;
var whichBottomRight=8;
var openingScreen=true;
var nLoaded;
var i;
var target;

function FadeQuarterPix() 
	{
         // no images, so quit
         if (!document.images)
            return

         // check if all loaded: if not, wait 1 sec & look again
         nLoaded = 0
         for (i=1;i<nPix+1;i++)
           if (pix[i].complete == true)
              nLoaded++
         if (nLoaded < nPix)
            { 
            setTimeout("FadeQuarterPix()", 1000);
            return;
            }
         // opening screen, so wait timePreFirstFade secs before starting
         if (openingScreen==true)
            {
            openingScreen=false;
            setTimeout("FadeQuarterPix()",timePreFirstFade*1000);
            return;
            }

         // increment pass
         if (pass < 4)
            pass++
         else
		   {
		    pass = 1
            if (thisSet < nSets) // new cycle so increment thisSet
              thisSet++
            else
              thisSet=1
		    }
			
	 	target = (pass + 4 - thisSet + 1) % 4 + 1;

         // NN only - apply fade
         if (document.all)
            {
            if (target == 1)
               slidetopleft.filters.blendTrans.apply()
            else if (target == 2)
                   slidetopright.filters.blendTrans.apply()
            else if (target == 3)
                   slidebottomright.filters.blendTrans.apply()
            else // (target == 4)
                    slidebottomleft.filters.blendTrans.apply()
            }

         // topleft's turn
         if (target == 1)
            {
			if (thisSet % 4 == 1)
			   whichTopLeft = 0
			else 
              whichTopLeft = (thisSet-1)*4 + 1; 
			  
            document.images.slidetopleft.src=pix[whichTopLeft].src
            }
         else if (target == 2) // topright's turn
                {
				if (thisSet % 4 == 0)
			   		whichTopRight = 0
				else 
              		whichTopRight = (thisSet-1)*4 + 2;
					
                document.images.slidetopright.src=pix[whichTopRight].src
                }
         else if (target == 3) // bottomright's turn
                {
           		if (thisSet % 4 == 3)
			   		whichBottomRight = 0
				else 
              		whichBottomRight = (thisSet-1)*4 + 3;
					
                 document.images.slidebottomright.src=pix[whichBottomRight].src
                }
         else // (target == 4) bottomleft's turn
				{
                if (thisSet % 4 == 2)
					whichBottomLeft = 0
				else 
					whichBottomLeft = (thisSet-1)*4 + 4;
				
				document.images.slidebottomleft.src=pix[whichBottomLeft].src
       			}


         // NN only - apply fade
         if (document.all)
            {
            if (target == 1)
				  slidetopleft.filters.blendTrans.play()
            else if (target == 2)
				slidetopright.filters.blendTrans.play()
            else if (target == 3)
              	slidebottomright.filters.blendTrans.play()
            else // (target == 4)
               	slidebottomleft.filters.blendTrans.play()
            }

         //  timeout
         if (pass == 4)
		   setTimeout("FadeQuarterPix()", intSecsBwCycles*1000)
		 else
		   setTimeout("FadeQuarterPix()", intSecsBwFades*1000)

	}
