/************************************
* File: photo-changer.js            *
* Author: Mark Jones                *
* Email: markjones1987@hotmail.com  *
* Description: Used to animate a    *
*   div that changes between a      *
*   number of images and            *
*   accompanying text.              *
*                                   *
* Created on: 01/07/09              *
* Last modified: 01/07/09           *
* Version: 0.1                      *
************************************/

function startChanging(){
    $photoArray = $$('.photo-option');
    for($i = 1 ; $i < $photoArray.length ; $i++){
        $tempImage = $$('#photo-changer .photo-option')[$i];
        $tempImage.hide();
    }

    $currentImage = 1;
    setInterval("$currentImage = changeImage($currentImage, $photoArray.length)", 5000);
}

function changeImage($currentImage, $numImages){
    if($currentImage == $numImages){
        $nextImage = 1;
    }else{
        $nextImage = $currentImage+1;
    }
    $$('#photo-option-'+$currentImage)[0].fade();
    $$('#photo-option-'+$nextImage)[0].appear({ queue: 'end' });
    return $nextImage;
}

Event.observe(window, 'load', function() {
  startChanging();
});
