/**
 * Gallery module image enlarging
 */
function enlarge (thumb, src, width, height, caption) 
{

    if (document.getElementById) {

        var imageitem = document.getElementById('imageitem');

        if (imageitem.src != src) 
        {
            $("#imageframe").fadeOut('fast', 
                function() { 
                    $("#imageitem").remove();  
                    $("#imagecaption").remove();
                    $("#imageframe").append('<img id="imageitem" src="' + src +'" width="'+ width +'" height="'+ height +'" alt="'+ caption +'" />');
                    $("#imageframe").append('<p id="imagecaption">'+ caption +'</p>');
                    $("#imageframe").fadeIn('fast');
                }
            );
        }
//        thumb.parentNode.focus();
    }

    return false;
}


$(document).ready(function() {

    $("a.active").click(function() {
        //strip the path from the src
        var image_src = $(this).find('img').attr('src').substr('/_media/images/t-'.length);
        var image_title = $(this).find('img').attr('title');
        //alert('clicked ' + image_src);
        //alert( $("img#key_image").attr('src'));

        $("img#key_image").attr('src', '/_media/images/'+image_src);
        $("img#key_image").attr('alt', image_title);
        return false;
    });

});


jQuery.preloadImages = function()
{
    for(var i = 0; i<arguments.length; i++)
    {
        jQuery("<img>").attr("src", arguments[i]);
    }
    //alert(arguments.length + ' images loaded');
}