﻿/* thumbnailNavFunctions.js - (c) Ty Norton 2009
 * Do not redistribute without express written consent from Ty Norton (tynorton AT gmail.com)
 * You must also include JSQuery to make this work: http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js
 */

var fadeSpeed = 300;
var selectedSlideIndex = 0;

function changeImage(imgElementId, newSrcUrl) {
    var imgTag = $("#" + imgElementId);
    
    imgTag.fadeTo(fadeSpeed, 0, function() {
        imgTag.changeSrc(newSrcUrl);
    });
    
    // Wait for img to load before fading it back in.
    imgTag.load(function(evt) {
        $(evt.target).clearStyles();
        $(evt.target).fadeTo(fadeSpeed, 1);
    });
}

function changeSlide() {
    selectedSlideIndex++;
    if (selectedSlideIndex >= slideShowPicturesArray.length) {
        selectedSlideIndex = 0;
    }
    changeImage(mainImgTagId,slideShowPicturesArray[selectedSlideIndex]);
}