﻿// Configurable Variables
var sImagePath2  = "Resource/gfx/Phototator2/"; // Relative path to the home of the images.
var aImages2     = Array ("I1.jpg","I2.jpg","I3.jpg","I4.jpg","I5.jpg","I6.jpg","I7.jpg");

var iImgWid2     = 370;      // Width of images in pixels.
var iImgHei2     = 90;      // Height of images in pixels.

var iItvl2       = 5000;     // Pause between transitions in miliseconds.
var iFade2       = 800;      // Time it takes to fade an image in or out in miliseconds.
var iPrLd2       = 5;        // Number of images to preload in the first instance.

var aLoaded2     = Array();  // Array to store the loaded images.
var bLoaded2     = false;    // Indicates if all the images have been loaded.
var iNxtLd2      = 0;        // Indicates the next element in the array to be loaded.

var ord2=0;                  // Starting point in the array of images
var odd2			= false;	// Tracks the faders

function preload2() {
    var i=0;
    for(i;i<iPrLd2;i++) {
        aLoaded2[ord2+i]      = new Image(iImgWid2,iImgHei2);
	    aLoaded2[ord2+i].src  = sImagePath2+aImages2[ord2+i];
	    iNxtLd2++;
    }
}

function rotate2() {
    var nxt=-1;
    
	if((ord2+1)>=aImages2.length) {nxt=0;} else {nxt=ord2+1;}
	if(!odd2) {
		$("#jHdr2").attr("src",aLoaded2[nxt].src);
		$("#jHdrDiv2").fadeIn(iFade2);
		$("#jHdrDiv1").fadeOut(iFade2);
		odd2=true;
	} else {
		$("#jHdr1").attr("src",aLoaded2[nxt].src);
		$("#jHdrDiv2").fadeOut(iFade2);
		$("#jHdrDiv1").fadeIn(iFade2);
		odd2=false;
	}
	
	// Load the next image...
	if(!bLoaded2) {
	    aLoaded2[iNxtLd2]      = new Image(iImgWid2,iImgHei2);
	    aLoaded2[iNxtLd2].src  = sImagePath2+aImages2[iNxtLd2];
	    
	    iNxtLd2++;	    
	    if(iNxtLd2==aImages2.length){bLoaded2=true;} // Detect if loading is complete...
	}
	ord2=nxt;
	setTimeout("rotate2();",iItvl2);
}


$(document).ready(function(){
    preload2();
	$("#jHdrDiv1").fadeIn(1);
	$("#jHdrDiv2").fadeOut(1);
	setTimeout("rotate2();",iItvl2);
});
