/* Controls the speed of fading in and out */
var speed = '.75';

function rotateImage(imgDiv, caption, hires) {
    
    div = $('gallery-banner-' + imgDiv);
    
    /* Ensure we're not working on the current image so it doesn't break when trying to swap with itself */
    if (!div.hasClassName('current')) {

        /* Fade out the current image */
        $$('.current').each(function(elem) {
            elem.removeClassName('current');
            Effect.Fade(elem, {duration:speed});
        });
        
        /* Fade in the new image */
        Effect.Appear(div, {duration:speed});
        
        /* Give the new image the 'current' class */
        div.addClassName('current'); 
        
        /* Update caption */
        $('gallery-title').innerHTML = caption;

        /* Check if hi-res image is set */
         if  (hires != '') {
             /* Update hi-res link */
             $('gallery-hires-link').href = hires;
         }
    

    }
    
}