// extract photos and setup fancy box
function _globalSetupFancyBox() 
{
    $(function () {
        var imgArray = new Array();
        //$("#photo-slideshow .caption").css("background-color", "#eee");
        $("#photo-slideshow img").each(function (index, img) {
            var imgSrc = $(img).attr("src");
            var imgTitle = $(img).attr("title");
            var imgSrcTokens = imgSrc.split("_");
            var trueSrc = "";
            if (imgSrcTokens.length > 1) {
                // always 2 tokens => [fitbox] [size]
                for (var i = 0; i < imgSrcTokens.length - 2; i++) {
                    if (i > 0) trueSrc += "_";
                    trueSrc += imgSrcTokens[i];
                }
                trueSrc += "." + imgSrcTokens[imgSrcTokens.length - 1].split(".")[1];
            } else {
                trueSrc += imgSrcTokens[0];
            }
            trueSrc = trueSrc.replace("/thumb", "");
            imgArray.push({ 'href': trueSrc, 'title': imgTitle });
            $(img).attr('index', index);
        });
        if (imgArray.length > 1) {
            for (var i = 0; i < imgArray.length; i++) {
                if (imgArray[i].title != "") {
                    imgArray[i].title += "<br/><br/>";
                }
                imgArray[i].title += "<small>Use your mouse wheel, or click near the border of the photos to move between photos.</small>";
            }
        }
        var options = {
            'padding': 10,
            'titlePosition': 'inside',
            'transitionIn': 'none',
            'transitionOut': 'none',
            'type': 'image',
            'changeFade': 0
        };
        $("#show-lightbox").css('cursor', 'pointer').click(function () {
            $.fancybox(imgArray, options);
        });
        $("#photo-slideshow img").css('cursor', 'pointer').click(function () {
            options['index'] = $(this).attr('index');
            $.fancybox(imgArray, options);
        });
    });
}
