var button_path  = "images/stills/buttons/";
var button_type  = "jpg"

var slide_number = 0;
var back_button  = 0;
var forth_button = 1;

//-----Getting the slide Show into a flexible library-----

// Kyle's Slide Show Button rollover()

//*****************************************************************************************
//* rolloverSlide() Requirements:                                                         *
//* img_name MUST be 'back' or 'forth'                                                    *
//* img_name MUST be the same as the file_name.type                                       *
//* Add 'return true;'to the HTML (onMouseOver or onMouseOut) code                        *
//* The following files MUST exist in the img_path folder:                                *
//* 'back_0.img_type',  'back_1.img_type',  'back_dis.img_type'                           *
//* 'forth_0.img_type', 'forth_1.img_type', 'forth_dis.img_type'                          *
//*                                                                                       *
//* example: onMouseOver="rolloverSlide('images/print/','forth','1','gif'); return true;" *
//*****************************************************************************************

function rolloverSlide(img_path,img_name,flag,img_type)
{
    if (img_name == "forth")
    {
        if (forth_button == 0)
        {
            document.images[img_name].src = img_path + img_name + "_dis." + img_type;
        }
        else
        {
            document.images[img_name].src = img_path + img_name + "_" + flag + "." + img_type;
        }
    }
    else if (img_name == "back")
    {
        if (back_button == 0)
        {
            document.images[img_name].src = img_path + img_name + "_dis." + img_type;
        }
        else
        {
            document.images[img_name].src = img_path + img_name + "_" + flag + "." + img_type;
        }
    }

    // Store the button paramaters for later.
    button_path = img_path;
    button_type = img_type;
}


//*****************************************************************************************
//* nextSlide() Requirements:                                                             *
//* img_name MUST be the same as the file_name.type                                       *
//* Add 'return false;'to the HTML (onClick) code                                         *
//* Max nuumber of images in sequence MUST be less than 100                               *
//* Files MUST be zero based (start from 0)                                               *
//* The following files MUST exist in the button_path folder:                             *
//* 'back_0.img_type',  'back_1.img_type',  'back_dis.img_type'                           *
//* 'forth_0.img_type', 'forth_1.img_type', 'forth_dis.img_type'                          *
//*                                                                                       *
//* example: onClick="nextSlide('slides/print/','text','gif','17'); return false;"        *
//*****************************************************************************************

function nextSlide(img_path,img_name,img_type,last_in_sequence)
{
    // At any time if the user clicks this button enable the other button
    back_button = 1;
    document.back.src = button_path + "back_0." + button_type;

    if (slide_number < last_in_sequence)
    {
        slide_number++;
        if (slide_number == last_in_sequence)
        {
            forth_button = 0;    // Disable button
            document.forth.src = button_path + "forth_dis." + button_type;
        }
        else
        {
            forth_button = 1;    // Enable button
            document.forth.src = button_path + "forth_1." + button_type;
        }
        if (slide_number < 10)
        {
            dbg_str = img_path + img_name + "_0" + slide_number + "." + img_type;
            document.images[img_name].src = img_path + img_name + "_0" + slide_number + "." + img_type;
        }
        else if (slide_number < 100)
        {
            document.images[img_name].src = img_path + img_name + "_" + slide_number + "." + img_type;
        }
    }
}

//*****************************************************************************************
//* prevSlide() Requirements:                                                             *
//* img_name MUST be the same as the file_name.type                                       *
//* Add 'return false;'to the HTML (onClick) code                                         *
//* Max nuumber of images in sequence MUST be less than 100                               *
//* Files MUST be zero based (start from 0)                                               *
//* The following files MUST exist in the button_path folder:                             *
//* 'back_0.img_type',  'back_1.img_type',  'back_dis.img_type'                           *
//* 'forth_0.img_type', 'forth_1.img_type', 'forth_dis.img_type'                          *
//*                                                                                       *
//* example: onClick="prevSlide('slides/print/','text','gif','0'); return false;"         *
//*****************************************************************************************

function prevSlide(img_path,img_name,img_type,first_in_sequence)
{
    // At any time if the user clicks this button enable the other button
    forth_button = 1;
    document.forth.src = button_path + "forth_0." + button_type;

    if (slide_number > first_in_sequence)
    {
        slide_number--;
        if (slide_number == first_in_sequence)
        {
            back_button = 0;    // Disable button
            document.back.src = button_path + "back_dis." + button_type;
        }
        else
        {
            back_button = 1;    // Enable button
            document.back.src = button_path + "back_1." + button_type;
        }
        if (slide_number < 10)
        {
            document.images[img_name].src = img_path + img_name + "_0" + slide_number + "." + img_type;
        }
        else if (slide_number < 100)
        {
            document.images[img_name].src = img_path + img_name + "_" + slide_number + "." + img_type;
        }
    }
}