/* Essential Arrays for pages with calendars -------------------------- */

var theDays = new Array();
theDays[0]="Sunday";
theDays[1]="Monday";
theDays[2]="Tuesday";
theDays[3]="Wednesday";
theDays[4]="Thursday";
theDays[5]="Friday";
theDays[6]="Saturday";

var theMonths = new Array();
theMonths[0]="January";
theMonths[1]="February";
theMonths[2]="March";
theMonths[3]="April";
theMonths[4]="May";
theMonths[5]="June";
theMonths[6]="July";
theMonths[7]="August";
theMonths[8]="September";
theMonths[9]="October";
theMonths[10]="November";
theMonths[11]="December";

/* Data and functions for a "generic" slide show ---------------------- */

var mySlides = new Array();

var slidenumber = 0;
var totalslides = 0;
var maxWidth = 0;
var maxHeight = 0;
var loadedCount = 0;        // How many are loaded so far?
var numPictures = "0 pictures loaded";

// This is an event handler to count the images that are actually loaded.
// When they are all loaded, the arrows to move between images will work
//
function countImages()
{
    ++loadedCount;
    // defaultStatus = "Loaded Picture Count: " + loadedCount;
    numPictures = new String( "" + loadedCount + ((loadedCount > 1)?" pictures loaded" : " picture loaded"));
    document.picturecounter.loadedSoFar.value = numPictures;
}

// Create a bunch of off-screen images and pre-fetch the images
// into the off-screen images so that they're cached when needed
//
function setupSlides( slideCount, slides, areaWidth, areaHeight )
{
    totalslides = slideCount;
    if( totalslides > 0 && slides.length == slideCount )
    {
        mySlides = new Array( totalslides );
        for( slidenumber = 0; slidenumber < totalslides; slidenumber++ )
        {
            mySlides[slidenumber] = new Image();            // create an off-screen image
            mySlides[slidenumber].onload = countImages;     // assign event handler
            mySlides[slidenumber].src = slides[slidenumber];    // the URL to load
        }
    }
    ( areaWidth > 0 ) ? maxWidth = areaWidth : maxWidth = 200;
    ( areaHeight > 0 ) ? maxHeight = areaHeight : maxHeight = 200;
    slidenumber = 0;
}

function showPictures( docImage, direction )
{
    var ratioW = 1.0;
    var ratioH = 1.0;
    var ratio = 1.0;
    
    if( direction == "next" )
    {
        ( slidenumber + 1 >= loadedCount ) ? slidenumber = 0 : slidenumber++;
    }
    else
    {
        ( slidenumber - 1 < 0 ) ? slidenumber = loadedCount - 1 : slidenumber--;
    }
    
    theImage = document.getElementById( docImage );
    if( theImage != null )
    {
        if( mySlides[slidenumber].width > maxWidth )
            ratioW = mySlides[slidenumber].width / maxWidth;
        if( mySlides[slidenumber].height > maxHeight )
            ratioH = mySlides[slidenumber].height / maxHeight;

        ratio = ( ratioW > ratioH ) ? ratioW : ratioH;

        theImage.src = mySlides[slidenumber].src;
        theImage.width = mySlides[slidenumber].width / ratio;
        theImage.height = mySlides[slidenumber].height / ratio;
    }
}

function openCalendar( URL ) 
{
    var aWindow = openPopup( URL, "aCalendar", 850, 640, "yes" );
    // return aWindow;
}

function openFruits( URL ) 
{
    var aWindow = openPopup( URL, "aCalendar", 650, 600, "yes" );
    // return aWindow;
}

function turnOn(theLink)
{
//  theLink.style.fontStyle = "italic";
    theLink.style.color = "purple"; 

//  theLink.style.fontWeight = "bold";
}

function turnOff(theLink)
{
/*  theLink.style.fontStyle = "normal";
*/  theLink.style.color = "blue";

//  theLink.style.fontWeight = "normal";
}

function showPushed(theLink)
{
/*  theLink.style.fontStyle = "normal";
*/  theLink.style.color = "red";

//  theLink.style.fontWeight = "normal";
}


