// these are all populated in the calling .asp file
var nPix = 24;
var pix = new Array();
for (i=1;i<25;i++) {
  pix[i]=new Image();
  pix[i].src="../graphics/homefaders/homefader" + i + ".jpg";
}

var timePreFirstFade=2
var intSecsBwFades = 4;

var pass=1;
var whichTopLeft=1;
var whichTopRight=2;
var whichBottomLeft=3;
var whichBottomRight=4;
var openingScreen=true;
var nLoaded;
var i;

function Fade4Pix()
         {
         // 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<13;i++)
           if (pix[i].complete == true)
              nLoaded++
         if (nLoaded < 12)
            {
            setTimeout("Fade4Pix()", 1000);
            return;
            }

         // opening screen, so wait timePreFirstFade secs before starting
         if (openingScreen==true)
            {
            openingScreen=false;
            setTimeout("Fade4Pix()",timePreFirstFade*1000);
            return;
            }

         // NN only - apply fade
         if (document.all)
            {
            if (pass % 4 == 3)
               slideTopLeft.filters.blendTrans.apply()
            else
                if (pass % 4 == 2)
                   slideTopRight.filters.blendTrans.apply()
            	else
                	if (pass % 4 == 1)
                   		slideBottomLeft.filters.blendTrans.apply()
                	else
                    	slideBottomRight.filters.blendTrans.apply()
            }
         // top left's turn
         if (pass % 4 == 3)
            {
            whichTopLeft = whichTopLeft + 4
			if (whichTopLeft > nPix) whichTopLeft = 1 // 1, 5, 9...
            document.images.slideTopLeft.src=pix[whichTopLeft].src
            }
		else
             // top right's turn
			if (pass % 4 == 2)
                {
                whichTopRight = whichTopRight + 4
			    if (whichTopRight > nPix) whichTopRight = 2 // 2, 6, 10...
                document.images.slideTopRight.src=pix[whichTopRight].src
                }
         	else
				// bottom left's turn
             	if (pass % 4 == 1)
                	{
                	whichBottomLeft = whichBottomLeft + 4
			        if (whichBottomLeft > nPix) whichBottomLeft = 3 // 3, 7, 11...
                	document.images.slideBottomLeft.src=pix[whichBottomLeft].src
                	}
             	else
					// bottom right's turn
                 	{
                 	whichBottomRight = whichBottomRight + 4
			        if (whichBottomRight > nPix) whichBottomRight = 4 // 4, 8, 12...
                 	document.images.slideBottomRight.src=pix[whichBottomRight].src
                 	}

         // NN only - apply fade
         if (document.all)
            {
            if (pass % 4 == 3)
               slideTopLeft.filters.blendTrans.play()
            else
                if (pass % 4 == 2)
                   slideTopRight.filters.blendTrans.play()
                else
                	if (pass % 4 == 1)
                   		slideBottomLeft.filters.blendTrans.play()
                	else
                    	slideBottomRight.filters.blendTrans.play()
            }

         // increment pass
         if (pass<nPix)
            pass++
         else
             pass=1

         //  timeout
         setTimeout("Fade4Pix()", intSecsBwFades*1000)
}
Fade4Pix();

