var pic_myOpacity;
var pic_interval;
var pic_opacityChange;
var pic_displayChange;
var pic_opacityGoal;
var pictureDelay = 4*1000;
var pic_picNumber = 2;
var pic_shouldPreload = 1;

function startUpSwapFade()
{
window.setTimeout("pic_fadeIt(1)", pictureDelay); 
main2 = new Image(); main2.src = my_directory + myPictureArray[2];
}

function pic_fadeFunction()
{
if (pic_myOpacity != pic_opacityGoal)
    {
    pic_myOpacity = pic_myOpacity + pic_opacityChange;
    if (navigator.userAgent.indexOf('MSIE') > 0)
        document.getElementById("main_picture").style.filter = "alpha(opacity:" + (pic_myOpacity * 100) + ")";
    else
        document.getElementById("main_picture").style.opacity = pic_myOpacity;
    }
else
    {
    clearInterval(pic_interval);
    if (pic_opacityGoal == 0)
        {
        document.getElementById('main_picture').src = my_directory+myPictureArray[pic_picNumber];
        pic_fadeIt(0);
        pic_picNumber++;
        if (pic_picNumber > tot_num_pics)
            {
            if (pic_shouldPreload) // load first picture first time through loop
                    eval('main1 = new Image(); main1.src = "'+my_directory+myPictureArray[1]+'"');

            pic_shouldPreload = 0;
            pic_picNumber = 1;
            }
        else if (pic_shouldPreload)
            {
            eval('main' + pic_picNumber + ' = new Image(); main' + pic_picNumber + '.src = "'+my_directory+myPictureArray[pic_picNumber]+'"');
            }
        }
    else
        {
        window.setTimeout("pic_fadeIt(1)", pictureDelay);
        }
    }
}

function pic_fadeIt(shouldFade)
{
if (shouldFade)
    {
    pic_myOpacity = 1.0;
    pic_opacityChange = -0.25;
    pic_opacityGoal = 0.0;
    }
else
    {
    pic_myOpacity = 0.0;
    pic_opacityChange = 0.25;
    pic_displayChange = "inline";
    pic_opacityGoal = 1.0;
    }
pic_interval = setInterval("pic_fadeFunction()", 200);
}
                                                                          
startUpSwapFade();
