/********************************
 * site-specific settings       *
 ********************************/

var showRolloverMenuEffect = Effect.BlindDown;
var showRolloverMenuEffectOptions = { duration: 0.2 };
var hideRolloverDelay = 150;
var hideRolloverMenuEffect = Effect.BlindUp;
var hideRolloverMenuEffectOptions = { duration: 0.2 };

/********************************
 * site-specific functions      *
 ********************************/
function changeGalleryImage(galleryName, index) {
    var target = galleryName + '_image_' + index;
    var caption = galleryName + '_caption_' + index;
    if (!$(target)) return false;

    var queue = Effect.Queues.get('global');
    queue.each(function(e) { e.cancel() });

    for (var i = 0; i < gallerySize[galleryName]; i++) {
        el = $(galleryName + '_image_' + i);
        if (el.id != target && el.style.display != 'none') Effect.Fade(el, { duration: 0.6 });

        el = $(galleryName + '_thumb_' + i);
        if (i == index) {
            el.style.borderColor = 'white';
            el.onmouseover = null;
            el.onmouseout = null;
        } else {
            el.style.borderColor = '#5D5D5D';
            el.onmouseover = function () { el.style.borderColor = 'white' };
            el.onmouseout = function () { el.style.borderColor = '#5D5D5D' };
        }
    }

    Effect.Appear(target, { duration: 0.6 });

    if($(caption).innerHTML != '') {
        $(galleryName + '_caption').style.display = 'block';
        $(galleryName + '_caption').innerHTML = $(caption).innerHTML;
    } else {
        $(galleryName + '_caption').style.display = 'none';
    }

    prevIndex = index == 0 ? gallerySize[galleryName] - 1 : index-1;
    nextIndex = index == gallerySize[galleryName] - 1 ? 0 : index+1;
    $(galleryName + '_prev_button').onclick = function () { changeGalleryImage(galleryName, prevIndex) };
    $(galleryName + '_next_button').onclick = function () { changeGalleryImage(galleryName, nextIndex) };
}

function startSlideShow(galleryName) {
  if (typeof(galleryName) == 'undefined') galleryName = 'gallery_1';
  showDojoDialog('slideshow');
  $(galleryName + '_play_button').onclick();
}

function stopSlideShow(galleryName) {
  if (typeof(galleryName) == 'undefined') galleryName = 'gallery_1';
  hideDojoDialog('slideshow');
  $(galleryName + '_pause_button').onclick();
}

