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('../Costa Rica_files/IMG_0052.jpg', '600', '800', 'San Jose Theatro');
slides[1] = new Slide('../Costa Rica_files/IMG_0059.jpg', '600', '800', 'Pre-Columbian gold');
slides[2] = new Slide('../Costa Rica_files/DSC_6846.jpg', '532', '800', 'Poas Volcano');
slides[3] = new Slide('../Costa Rica_files/DSC_6856.jpg', '800', '532', 'near Poas');
slides[4] = new Slide('../Costa Rica_files/DSC_6860.jpg', '532', '800', 'near Poas');
slides[5] = new Slide('../Costa Rica_files/DSC_6866.jpg', '532', '800', 'outside Poas');
slides[6] = new Slide('../Costa Rica_files/DSC_6873.jpg', '532', '800', 'Coatis');
slides[7] = new Slide('../Costa Rica_files/DSC_6879.jpg', '532', '800', 'our hotel Tabacon');
slides[8] = new Slide('../Costa Rica_files/DSC_6882.jpg', '532', '800', 'Tabacon');
slides[9] = new Slide('../Costa Rica_files/IMG_1727.jpg', '600', '800', 'Typical dinner');
slides[10] = new Slide('../Costa Rica_files/IMG_0067.jpg', '600', '800', 'Tabacon');
slides[11] = new Slide('../Costa Rica_files/IMG_0068.jpg', '600', '800', 'Tabacon');
slides[12] = new Slide('../Costa Rica_files/DSC_6886.jpg', '532', '800', 'Arenal Volcano');
slides[13] = new Slide('../Costa Rica_files/IMG_1739.jpg', '600', '800', 'Zip Line');
slides[14] = new Slide('../Costa Rica_files/IMG_1740.jpg', '800', '600', 'Zip Line');
slides[15] = new Slide('../Costa Rica_files/IMG_1762.jpg', '800', '600', 'Zip');
slides[16] = new Slide('../Costa Rica_files/IMG_0074.jpg', '600', '800', 'Zip');
slides[17] = new Slide('../Costa Rica_files/IMG_0080.jpg', '600', '800', 'Zip');
slides[18] = new Slide('../Costa Rica_files/DSC_6894.jpg', '800', '532', 'beautiful foliage');
slides[19] = new Slide('../Costa Rica_files/DSC_6904.jpg', '532', '800', 'unique flowers');
slides[20] = new Slide('../Costa Rica_files/DSC_6916.jpg', '532', '800', 'Tabacon');
slides[21] = new Slide('../Costa Rica_files/DSC_6918.jpg', '532', '800', 'Tabacon');
slides[22] = new Slide('../Costa Rica_files/DSC_6922.jpg', '532', '800', 'Tabacon');
slides[23] = new Slide('../Costa Rica_files/DSC_6943.jpg', '532', '800', 'near Arenal');
slides[24] = new Slide('../Costa Rica_files/IMG_0088.jpg', '600', '800', 'pastures');
slides[25] = new Slide('../Costa Rica_files/IMG_0091.jpg', '600', '800', 'primitive trails');
slides[26] = new Slide('../Costa Rica_files/DSC_6954.jpg', '800', '532', 'Monteverde');
slides[27] = new Slide('../Costa Rica_files/DSC_6956.jpg', '800', '532', 'hanging bridges');
slides[28] = new Slide('../Costa Rica_files/DSC_6972.jpg', '532', '800', 'Monteverde');
slides[29] = new Slide('../Costa Rica_files/DSC_6987.jpg', '800', '532', 'hanging bridges');
slides[30] = new Slide('../Costa Rica_files/DSC_6998.jpg', '532', '800', 'butterfly');
slides[31] = new Slide('../Costa Rica_files/IMG_0094.jpg', '600', '800', 'hanging bridges ');
slides[32] = new Slide('../Costa Rica_files/DSC_7026.jpg', '532', '800', 'Jesus Christ Lizard');
slides[33] = new Slide('../Costa Rica_files/DSC_7053.jpg', '532', '800', 'Tabacon Hot Springs');
slides[34] = new Slide('../Costa Rica_files/DSC_7055.jpg', '532', '800', 'Hot Springs');
slides[35] = new Slide('../Costa Rica_files/DSC_7056.jpg', '532', '800', 'Hot Springs');
slides[36] = new Slide('../Costa Rica_files/DSC_7058.jpg', '532', '800', 'Hot Springs');
slides[37] = new Slide('../Costa Rica_files/DSC_7065.jpg', '532', '800', 'Hot Springs');
slides[38] = new Slide('../Costa Rica_files/DSC_7067.jpg', '532', '800', 'Hot Springs');
slides[39] = new Slide('../Costa Rica_files/DSC_7069.jpg', '532', '800', 'Hot Springs');
slides[40] = new Slide('../Costa Rica_files/DSC_7071.jpg', '532', '800', 'Hot Springs');
slides[41] = new Slide('../Costa Rica_files/DSC_7074.jpg', '532', '800', 'Resort flowers\n ');
slides[42] = new Slide('../Costa Rica_files/DSC_7077.jpg', '532', '800', 'Bar at hot springs');
slides[43] = new Slide('../Costa Rica_files/DSC_7081.jpg', '800', '532', 'landscaping at Hot Springs');
slides[44] = new Slide('../Costa Rica_files/DSC_7085.jpg', '800', '532', 'Aaaahhh');
slides[45] = new Slide('../Costa Rica_files/DSC_7086.jpg', '532', '800', 'Does is get any better than this?');
slides[46] = new Slide('../Costa Rica_files/DSC_7089.jpg', '532', '800', 'Resort');
slides[47] = new Slide('../Costa Rica_files/DSC_7092.jpg', '800', '532', 'many different flowers');
slides[48] = new Slide('../Costa Rica_files/DSC_7093.jpg', '532', '800', 'flowers');
slides[49] = new Slide('../Costa Rica_files/DSC_7094.jpg', '800', '532', 'flowers');
slides[50] = new Slide('../Costa Rica_files/DSC_7099.jpg', '532', '800', 'Bar');
slides[51] = new Slide('../Costa Rica_files/DSC_7106.jpg', '800', '532', 'foliage');
slides[52] = new Slide('../Costa Rica_files/DSC_7108.jpg', '800', '532', 'flowers everywhere you look');
slides[53] = new Slide('../Costa Rica_files/IMG_0125.jpg', '800', '600', 'grounds are perfect');
slides[54] = new Slide('../Costa Rica_files/DSC_7137.jpg', '532', '800', 'Manuel Antonio National Park');
slides[55] = new Slide('../Costa Rica_files/DSC_7138.jpg', '532', '800', 'Manuel Antonio');
slides[56] = new Slide('../Costa Rica_files/DSC_7139.jpg', '532', '800', 'fight the crowds');
slides[57] = new Slide('../Costa Rica_files/DSC_7141.jpg', '532', '800', 'always something to buy');
slides[58] = new Slide('../Costa Rica_files/DSC_7144.jpg', '532', '800', 'iguana');
slides[59] = new Slide('../Costa Rica_files/DSC_7151.jpg', '532', '800', 'friendly monkeys');
slides[60] = new Slide('../Costa Rica_files/DSC_7156.jpg', '532', '800', 'show off');
slides[61] = new Slide('../Costa Rica_files/DSC_7165.jpg', '532', '800', 'quiet spot');
slides[62] = new Slide('../Costa Rica_files/DSC_7172.jpg', '532', '800', 'don’t steal my lunch!');
slides[63] = new Slide('../Costa Rica_files/DSC_7180.jpg', '532', '800', 'hiking in the park');
slides[64] = new Slide('../Costa Rica_files/DSC_7192.jpg', '532', '800', 'View from the top of the trail');
slides[65] = new Slide('../Costa Rica_files/DSC_7197.jpg', '532', '800', 'National Park entrance');
slides[66] = new Slide('../Costa Rica_files/DSC_7204.jpg', '532', '800', 'Iran Contra airplane- now a bar');
slides[67] = new Slide('../Costa Rica_files/DSC_7206.jpg', '532', '800', 'Casitas Eclipse');
slides[68] = new Slide('../Costa Rica_files/DSC_7253.jpg', '532', '800', 'Casitas Eclipse');
slides[69] = new Slide('../Costa Rica_files/DSC_7255.jpg', '800', '532', 'Casitas Eclipse');
slides[70] = new Slide('../Costa Rica_files/DSC_7260.jpg', '532', '800', 'outside our door -Casitas Eclipse');
slides[71] = new Slide('../Costa Rica_files/DSC_7207.jpg', '532', '800', 'Butterfly farm');
slides[72] = new Slide('../Costa Rica_files/DSC_7216.jpg', '532', '800', 'butterflys');
slides[73] = new Slide('../Costa Rica_files/DSC_7218.jpg', '532', '800', 'friendly butterfly');
slides[74] = new Slide('../Costa Rica_files/DSC_7229.jpg', '800', '532', 'famous blue morpho');
slides[75] = new Slide('../Costa Rica_files/DSC_7231.jpg', '800', '532', 'stages of metomorphis');
slides[76] = new Slide('../Costa Rica_files/DSC_7244.jpg', '800', '532', 'blue morpho closed');
slides[77] = new Slide('../Costa Rica_files/IMG_1796.jpg', '600', '800', 'dolphins');
slides[78] = new Slide('../Costa Rica_files/IMG_1798.jpg', '600', '800', 'dolphins');
slides[79] = new Slide('../Costa Rica_files/IMG_1804.jpg', '600', '800', 'snorkel spot');
slides[80] = new Slide('../Costa Rica_files/IMG_1809.jpg', '600', '800', 'snorkeling');
slides[81] = new Slide('../Costa Rica_files/IMG_1814.jpg', '600', '800', 'great variety');
slides[82] = new Slide('../Costa Rica_files/IMG_1831.jpg', '600', '800', 'clear water');
slides[83] = new Slide('../Costa Rica_files/IMG_1833.jpg', '600', '800', 'many fish');
slides[84] = new Slide('../Costa Rica_files/IMG_1838.jpg', '600', '800', 'snorkel');
slides[85] = new Slide('../Costa Rica_files/IMG_1851.jpg', '600', '800', 'more fish');
slides[86] = new Slide('../Costa Rica_files/IMG_1854.jpg', '600', '800', 'and they watch us, too');
slides[87] = new Slide('../Costa Rica_files/IMG_1858.jpg', '600', '800', '');
slides[88] = new Slide('../Costa Rica_files/IMG_1890.jpg', '600', '800', 'our catamaran');
slides[89] = new Slide('../Costa Rica_files/IMG_1909.jpg', '800', '600', 'our ‘Captain’');
slides[90] = new Slide('../Costa Rica_files/IMG_1911.jpg', '600', '800', 'anyone could try');
isPureISOLatin1 = true;
contentEncodingConstant = 4;
feedbackURL = "TODO";
showFeedbackButton = false;
feedbackEnabled = 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;
    }
}

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 onPageLoad()
{
    detectBrowser();
    fixupAllIEPNGBGs();
    fixupIEPNG("id1", "Costa Rica_files/transparent.gif");
    fixupIEPNG("id2", "Costa Rica_files/transparent.gif");
    fixupIEPNG("id3", "Costa Rica_files/transparent.gif");
    fixupIEPNG("id4", "Costa Rica_files/transparent.gif");
    fixupIEPNG("id5", "Costa Rica_files/transparent.gif");
    fixupIEPNG("id6", "Costa Rica_files/transparent.gif");
    fixupIEPNG("id7", "Costa Rica_files/transparent.gif");
    fixupIEPNG("id8", "Costa Rica_files/transparent.gif");
    return true;
}

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 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 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 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;
}


