slideShowURL = 'SlideShow_assets/SlideShow.html';       // parameter from openSlideShowWindow.js
slideShowNS4URL = 'SlideShow_assets/SlideShowNS4.html'; // parameter from openSlideShowWindow.js

slides = new Array();
slides[0] = new Slide('../JASA_files/070126 132652 0013.jpg', '801', '641', 'Nick');
slides[1] = new Slide('../JASA_files/070126 132728 0014.jpg', '800', '640', 'Shawn');
slides[2] = new Slide('../JASA_files/070126 132644 0011.jpg', '800', '641', 'Oscar');
slides[3] = new Slide('../JASA_files/Shear Water running.jpg', '534', '800', 'Shear Water under way');
slides[4] = new Slide('../JASA_files/070123 155332 0105.jpg', '640', '801', 'Nick with LMI BlueFin and Sony FX1');
slides[5] = new Slide('../JASA_files/070124 133348 0414.jpg', '534', '800', 'A Tiger passes under the Shear Water at Tiger Beach');
slides[6] = new Slide('../JASA_files/_MG_1220a.jpg', '534', '800', 'Nick & ‘Emma’ at Tiger Beach (photo: Nadine Umbscheiden)');
slides[7] = new Slide('../JASA_files/070124 125704 0195.jpg', '534', '800', 'Shawn and Tiger, Tiger Beach');
slides[8] = new Slide('../JASA_files/070124 124654 0161.jpg', '534', '800', 'Oscar and Tiger, Tiger Beach');
slides[9] = new Slide('../JASA_files/070124 124604 0157.jpg', '534', '800', 'Oscar gets a close up');
slides[10] = new Slide('../JASA_files/070124 125634 0189.jpg', '534', '800', 'Tiger Beach');
slides[11] = new Slide('../JASA_files/070124 125652 0192.jpg', '534', '800', 'Tiger Beach');
slides[12] = new Slide('../JASA_files/070124 125756 0202.jpg', '534', '800', 'Tiger Beach');
slides[13] = new Slide('../JASA_files/070124 125950 0223.jpg', '534', '800', 'Tiger Beach');
slides[14] = new Slide('../JASA_files/070124 125958 0227.jpg', '534', '800', 'Tiger Beach');
slides[15] = new Slide('../JASA_files/070124 130006 0232.jpg', '534', '800', 'Tiger Beach');
slides[16] = new Slide('../JASA_files/070124 130356 0255.jpg', '534', '800', 'Tiger Beach');
slides[17] = new Slide('../JASA_files/070124 130706 0266.jpg', '640', '800', 'Tiger Beach');
slides[18] = new Slide('../JASA_files/070124 130746 0272.jpg', '534', '800', 'Tiger Beach');
slides[19] = new Slide('../JASA_files/070124 131852 0337.jpg', '534', '800', 'Tiger Beach');
slides[20] = new Slide('../JASA_files/070124 131856 0339.jpg', '641', '800', 'Tiger Beach');
slides[21] = new Slide('../JASA_files/070124 133158 0394.jpg', '534', '800', 'Tiger Beach');
slides[22] = new Slide('../JASA_files/070124 133448 0418.jpg', '534', '800', 'Shawn and Lemon Shark, Tiger Beach');
slides[23] = new Slide('../JASA_files/070124 133948 0423.jpg', '640', '800', 'Videoing remora fish cleaning a Lemon Shark’s teeth');
slides[24] = new Slide('../JASA_files/070126 151348 0089.jpg', '534', '800', 'After the dives - boarding the Shear Water');
slides[25] = new Slide('../JASA_files/070126 150302 0032.jpg', '534', '800', 'Nick with Dolphins');
slides[26] = new Slide('../JASA_files/070126 150456 0065.jpg', '534', '800', 'Dolphin snorkel at sea');
slides[27] = new Slide('../JASA_files/070127 105236 0075.jpg', '640', '800', 'Bull Shark at ‘Mount Mokarran’');
slides[28] = new Slide('../JASA_files/070127 143512 0155.jpg', '534', '800', 'Tiger at ‘Mount Mokarran’');
slides[29] = new Slide('../JASA_files/070128 175010 0011.jpg', '534', '800', 'The ‘Galapagos’ Team');
slides[30] = new Slide('../JASA_files/070128 175720 0029.jpg', '534', '800', 'Crew: Jim, Jake, John & Wade at back,  plus rest of us');
slides[31] = new Slide('../JASA_files/070128 175738 0030.jpg', '534', '800', '“Make like a tiger” said Jim');
isPureISOLatin1 = true;
contentEncodingConstant = 4;
feedbackURL = "TODO";
showFeedbackButton = false;
feedbackEnabled = true;

var windowsInternetExplorer = false;
var browserVersion = 0;
function detectBrowser()
{
    windowsInternetExplorer = false;
    var appVersion = navigator.appVersion;
    if ((appVersion.indexOf("MSIE") != -1) &&
        (appVersion.indexOf("Macintosh") == -1))
    {
        var temp = appVersion.split("MSIE");
        browserVersion = parseFloat(temp[1]);
        windowsInternetExplorer = true;
    }
}

function onPageLoad()
{
    detectBrowser();
    fixupAllIEPNGBGs();
    fixupIEPNG("id1", "JASA_files/transparent.gif");
    fixupIEPNG("id2", "JASA_files/transparent.gif");
    fixupIEPNG("id3", "JASA_files/transparent.gif");
    fixupIEPNG("id4", "JASA_files/transparent.gif");
    return true;
}

var inImgPropertyChanged = false;
function imgPropertyChanged()
{
    if ((window.event.propertyName == "src") && (! inImgPropertyChanged))
    {
        inImgPropertyChanged = true;
        var el = window.event.srcElement;
        if (el.src != smallTransparentGif)
        {
            el.filters.item(0).src = el.src;
            el.src = smallTransparentGif;
        }
        inImgPropertyChanged = false;
    }
}

function NBmouseover(index)
{
    var normal = document.getElementById("navbar_"+index+"_normal");
    var rollover = document.getElementById("navbar_"+index+"_rollover");
    if (normal && rollover)
    {
        normal.style.visibility = "hidden";
        rollover.style.visibility = "visible";
    }
    return true;
}

var smallTransparentGif = "";
function fixupIEPNG(strImageID, transparentGif) 
{
    smallTransparentGif = transparentGif;
    if (windowsInternetExplorer && (browserVersion < 7))
    {
        var img = document.getElementById(strImageID);
        if (img)
        {
            var src = img.src;
            img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')";
            img.src = transparentGif;
            img.attachEvent("onpropertychange", imgPropertyChanged);
        }
    }
}

function fixupIEPNGBG(oBlock) 
{
    if (oBlock)
    {
        var currentBGImage = oBlock.currentStyle.backgroundImage;
        var currentBGRepeat = oBlock.currentStyle.backgroundRepeat;
        var urlStart = currentBGImage.indexOf('url(');
        var urlEnd = currentBGImage.indexOf(')', urlStart);
        var imageURL = currentBGImage.substring(urlStart + 4, urlEnd);

        if (imageURL.charAt(0) == '"')
        {
            imageURL = imageURL.substring(1);
        }
        
        if (imageURL.charAt(imageURL.length - 1) == '"')
        {
            imageURL = imageURL.substring(0, imageURL.length - 1);
        }

        var overrideRepeat = false;

        var filterStyle =
            "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" +
            imageURL +
            "', sizingMethod='crop');";

        if (RegExp("/C[0-9A-F]{8}.png$").exec(imageURL) != null)
        {
            filterStyle =
                "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" +
                imageURL +
                "', sizingMethod='scale');";

            overrideRepeat = true;
        }

        var backgroundImage = new Image();
        backgroundImage.src = imageURL;
        var tileWidth = backgroundImage.width;
        var tileHeight = backgroundImage.height; 
        
        var blockWidth = 0;
        var blockHeight = 0;
        if (oBlock.style.width)
        {
            blockWidth = parseInt(oBlock.style.width);
        }
        else
        {
            blockWidth = oBlock.offsetWidth;
        }
        if (oBlock.style.height)
        {
            blockHeight = parseInt(oBlock.style.height);
        }
        else
        {
            blockHeight = oBlock.offsetHeight;
        }

        if ((blockWidth == 0) || (blockHeight == 0))
        {
            return;
        }
        
        var wholeRows = 1;
        var wholeCols = 1;
        var extraHeight = 0;
        var extraWidth = 0;
        
        if ((currentBGRepeat.indexOf("no-repeat") != -1) ||
              ((tileWidth == 0) && (tileHeight == 0)) ||
              overrideRepeat)
        {
            tileWidth = blockWidth;
            tileHeight = blockHeight;

        }
        else if ((currentBGRepeat.indexOf("repeat-x") != -1) ||
              (tileHeight == 0))
        {
            wholeCols = Math.floor(blockWidth / tileWidth);
            extraWidth = blockWidth - (tileWidth * wholeCols);
            tileHeight = blockHeight;

        }
        else if (currentBGRepeat.indexOf("repeat-y") != -1)
        {
            wholeRows = Math.floor(blockHeight / tileHeight);
            extraHeight = blockHeight - (tileHeight * wholeRows);
            tileWidth = blockWidth;

        }
        else
        {
            wholeCols = Math.floor(blockWidth / tileWidth);
            wholeRows = Math.floor(blockHeight / tileHeight);
            extraWidth = blockWidth - (tileWidth * wholeCols);
            extraHeight = blockHeight - (tileHeight * wholeRows);
        }
        
        var wrappedContent = document.createElement("div");
        wrappedContent.style.position = "relative";
        wrappedContent.style.zIndex = "1";
        wrappedContent.style.left = "0px";
        wrappedContent.style.top = "0px";
        if (!isNaN(parseInt(oBlock.style.width)))
        {
            wrappedContent.style.width = "" + blockWidth + "px";
        }
        if (!isNaN(parseInt(oBlock.style.height)))
        {
            wrappedContent.style.height = "" + blockHeight + "px";
        }
        var pngBGFixIsWrappedContentEmpty = true;
        while (oBlock.hasChildNodes())
        {
            if (oBlock.firstChild.nodeType == 3)
            {
                if (RegExp("^ *$").exec(oBlock.firstChild.data) == null)
                {
                    pngBGFixIsWrappedContentEmpty = false;
                }
            }
            else
            {
                pngBGFixIsWrappedContentEmpty = false;
            }
            wrappedContent.appendChild(oBlock.firstChild);
        }
        if (pngBGFixIsWrappedContentEmpty)
        {
            wrappedContent.style.lineHeight = "0px";
        }
        
        var newMarkup = "";
        for (var currentRow = 0; 
             currentRow < wholeRows; 
             currentRow++)
        {
            for (currentCol = 0; 
                 currentCol < wholeCols; 
                 currentCol++)
            {
                newMarkup += "<div style=" +
                        "\"position: absolute; line-height: 0px; " +
                        "width: " + tileWidth + "px; " +
                        "height: " + tileHeight + "px; " +
                        "left:" + currentCol *  tileWidth + "px; " +
                        "top:" + currentRow *  tileHeight + "px; " +
                        "filter:" + filterStyle + 
                        "\" > </div>";
            }
            
            if (extraWidth != 0)
            {
                newMarkup += "<div style=" +
                        "\"position: absolute; line-height: 0px; " +
                        "width: " + extraWidth + "px; " +
                        "height: " + tileHeight + "px; " +
                        "left:" + currentCol *  tileWidth + "px; " +
                        "top:" + currentRow *  tileHeight + "px; " +
                        "filter:" + filterStyle + 
                        "\" > </div>";
            }
        }
        
        if (extraHeight != 0)
        {
            for (currentCol = 0; 
                 currentCol < wholeCols; 
                 currentCol++)
            {
                newMarkup += "<div style=" +
                        "\"position: absolute; line-height: 0px; " +
                        "width: " + tileWidth + "px; " +
                        "height: " + extraHeight + "px; " +
                        "left:" + currentCol *  tileWidth + "px; " +
                        "top:" + currentRow *  tileHeight + "px; " +
                        "filter:" + filterStyle + 
                        "\" > </div>";
            }
            
            if (extraWidth != 0)
            {
                newMarkup += "<div style=" +
                        "\"position: absolute; line-height: 0px; " +
                        "width: " + extraWidth + "px; " +
                        "height: " + extraHeight + "px; " +
                        "left:" + currentCol *  tileWidth + "px; " +
                        "top:" + currentRow *  tileHeight + "px; " +
                        "filter:" + filterStyle + 
                        "\" > </div>";
            }
        }
        oBlock.innerHTML = newMarkup;

        oBlock.appendChild(wrappedContent);
        oBlock.style.background= "";
    }
}

function fixupAllIEPNGBGs()
{
    if (windowsInternetExplorer && (browserVersion < 7))
    {
        try
        {
            var oDivNodes = document.getElementsByTagName('DIV');
            for (var iIndex=0; iIndex<oDivNodes.length; iIndex++)
            {
                var oNode = oDivNodes.item(iIndex);
                if (oNode.currentStyle &&
                    oNode.currentStyle.backgroundImage &&
                    (oNode.currentStyle.backgroundImage.indexOf('url(') != -1) &&
                    (oNode.currentStyle.backgroundImage.indexOf('.png")') != -1))
                {
                    fixupIEPNGBG(oNode);
                }
            }
        }
        catch (e)
        {
        }
    }
}

function NBmouseout(index)
{
    var normal = document.getElementById("navbar_"+index+"_normal");
    var rollover = document.getElementById("navbar_"+index+"_rollover");
    if (normal && rollover)
    {
        normal.style.visibility = "visible";
        rollover.style.visibility = "hidden";
    }
    return true;
}

