
var current_thumb;

function switchImage(src, image_url, flash_url)
{
    new_thumb = src.firstChild;
    try
    {
        current_thumb.className = '';
    }
    catch (e)
    {
        //swallow this
    }

    container = document.getElementById('gallery_image_container');

    var title = new_thumb.getAttribute('title');
    if (!title)
    {
        title = new_thumb.getAttribute('alt');
    }
    new_image_tag = '<img id="gallery_image" src="' + image_url + '" alt="' + new_thumb.getAttribute('alt') + '" title="' + title + '" />';

    container.innerHTML = new_image_tag;

    if (flash_url)
    {
        var fo = new FlashObject(flash_url, "gallery_flash", "176", "208", "5", "#FFFFFF");
        fo.write("gallery_image_container");
    }

    if (document.getElementById('gallery_image_caption').firstChild)
    {
        document.getElementById('gallery_image_caption').firstChild.nodeValue = new_thumb.getAttribute('alt');
    }
    else
    {
        document.getElementById('gallery_image_caption').innerText = new_thumb.getAttribute('alt');
    }

     document.getElementById('gallery_image_caption').className = document.getElementById('gallery_image_caption').className.replace(/(^|\s)invisible(\s|$)/, '');
    if ('' == new_thumb.getAttribute('alt'))
    {
        document.getElementById('gallery_image_caption').className += ' invisible';
    }

    // alert(src.getAttribute('alt'));

    // alert(caption.nodeValue);

    current_thumb = src;

    src.className = 'active';

    return false;
}


