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

slides = new Array();
slides[0] = new Slide('../Outfitting4List_files/Pans.jpg', '800', '600', 'Converting the wet locker to storage for the pots and pans (six altogether).  Bungee cord will secure them at sea.');
slides[1] = new Slide('../Outfitting4List_files/Dinner.jpg', '600', '800', 'Taking a break for dinner.');
slides[2] = new Slide('../Outfitting4List_files/TrackDown.jpg', '600', '800', 'Removing the last section of Battcar track so our Strong Track can be installed. There were 78 screws to remove. Yay! No more battens!');
slides[3] = new Slide('../Outfitting4List_files/DeckHoles.jpg', '600', '800', 'Over-drilling and filling the tack plate holes with epoxy, which are then under-drilled for the through bolts, first step in converting to a cutter.');
slides[4] = new Slide('../Outfitting4List_files/TackPlate.jpg', '600', '800', 'The new tack plate for the staysail stay.');
slides[5] = new Slide('../Outfitting4List_files/RonnieCrew.jpg', '600', '800', 'Rhonda’s brother, Ronnie, and friends, Otis and Shaun, visit from Texas.');
slides[6] = new Slide('../Outfitting4List_files/StrongTrack.jpg', '800', '600', 'Feeding the new Strong Track into the mast groove. Our mainsail was made with slides to fit this track (Port Townsend Sailmakers).');
slides[7] = new Slide('../Outfitting4List_files/NewMain.jpg', '800', '600', 'Our mainsail, in the bag for five months, is finally set. What a pleasure to hoist, reef and furl without battens!');
slides[8] = new Slide('../Outfitting4List_files/HalyardBad.jpg', '800', '600', 'This halyard shackle won’t lead fair (the splice is too tight). This will need to be replaced.');
slides[9] = new Slide('../Outfitting4List_files/HatchSeal.jpg', '600', '800', 'Attaching and cementing a new seal for the engine hatch cover.');
slides[10] = new Slide('../Outfitting4List_files/EngineWork.jpg', '600', '800', 'Checking the raw water strainer. The PSC 34’s cockpit engine hatch is a wonderful improvement on small boat engine access.');
slides[11] = new Slide('../Outfitting4List_files/RawStrainer.jpg', '800', '600', 'This is why it’s a good idea to check the raw water strainer. It was partly blocked with seaweed and other denizens of the sea.');
slides[12] = new Slide('../Outfitting4List_files/Hayn.jpg', '600', '800', 'Fitting the cone over the core wires during the install of a Hayn Hi-Mod backstay insulator.');
slides[13] = new Slide('../Outfitting4List_files/Backstay.jpg', '600', '800', 'The new backstay, turnbuckle and Hi-Mod terminal. Now, there are just seven more wires to go, all will be 316 SS 9/32” (up from 1/4”).');
slides[14] = new Slide('../Outfitting4List_files/JibCover.jpg', '600', '800', 'The sweetest way to store a jib on deck and save some space in the cabin. This cover was made by Lee Sail Covers (leesailcovers.com).');
isPureISOLatin1 = true;
contentEncodingConstant = 4;
feedbackURL = "TODO";
showFeedbackButton = false;
feedbackEnabled = true;

function getParaDescendantsRec(oAncestor, aResultArray, index)
{
    if (index == -1)
    {
        if ((oAncestor.nodeName == "DIV") &&
            (oAncestor.className.lastIndexOf("paragraph") != -1))
        {
            aResultArray[aResultArray.length] = oAncestor;
        }
        else if ((oAncestor.nodeName == "DIV") ||
                 (oAncestor.nodeName == "LI") ||
                 (oAncestor.nodeName == "OL") ||
                 (oAncestor.nodeName == "UL"))
        {
            getParaDescendantsRec(oAncestor, aResultArray, 0);
        }
    }
    else
    {
        getParaDescendantsRec(oAncestor.childNodes[index], aResultArray, -1);
        if (index < (oAncestor.childNodes.length - 1))
        {
            getParaDescendantsRec(oAncestor, aResultArray, index + 1);
        }
    }
}

function getParaDescendants(oAncestor)
{
    var aResultArray = new Array();
    getParaDescendantsRec(oAncestor, aResultArray, -1);

    return aResultArray;
}

function onPageLoad()
{
    detectBrowser();
    fixupIEPNGBG("id1");
    fixupIEPNGBG("id2");
    fixupIEPNGBG("id3");
    fixupIEPNGBG("id4");
    fixupIEPNGBG("id5");
    fixupIEPNGBG("navbar_0_normal");
    fixupIEPNGBG("navbar_0_rollover");
    fixupIEPNGBG("navbar_1_normal");
    fixupIEPNGBG("navbar_1_rollover");
    fixupIEPNGBG("navbar_2_normal");
    fixupIEPNGBG("navbar_2_rollover");
    fixupIEPNGBG("navbar_3_normal");
    fixupIEPNGBG("navbar_3_rollover");
    fixupIEPNGBG("navbar_4_normal");
    fixupIEPNGBG("navbar_4_rollover");
    fixupIEPNGBG("navbar_5_normal");
    fixupIEPNGBG("navbar_5_rollover");
    fixupIEPNG("id6", "Outfitting4List_files/transparent.gif");
    fixupIEPNGBG("id7");
    fixupIEPNG("id8", "Outfitting4List_files/transparent.gif");
    fixupIEPNGBG("id9");
    fixupIEPNG("id10", "Outfitting4List_files/transparent.gif");
    fixupIEPNGBG("id11");
    fixupIEPNG("id12", "Outfitting4List_files/transparent.gif");
    fixupIEPNGBG("id13");
    fixupIEPNG("id14", "Outfitting4List_files/transparent.gif");
    fixupIEPNGBG("id15");
    fixupIEPNG("id16", "Outfitting4List_files/transparent.gif");
    fixupIEPNGBG("id17");
    fixupIEPNG("id18", "Outfitting4List_files/transparent.gif");
    fixupIEPNGBG("id19");
    fixupIEPNG("id20", "Outfitting4List_files/transparent.gif");
    fixupIEPNGBG("id21");
    fixupIEPNG("id22", "Outfitting4List_files/transparent.gif");
    fixupIEPNGBG("id23");
    fixupIEPNG("id24", "Outfitting4List_files/transparent.gif");
    fixupIEPNGBG("id25");
    fixupIEPNG("id26", "Outfitting4List_files/transparent.gif");
    fixupIEPNGBG("id27");
    fixupIEPNG("id28", "Outfitting4List_files/transparent.gif");
    fixupIEPNGBG("id29");
    fixupIEPNG("id30", "Outfitting4List_files/transparent.gif");
    fixupIEPNGBG("id31");
    fixupIEPNG("id32", "Outfitting4List_files/transparent.gif");
    fixupIEPNGBG("id33");
    fixupIEPNG("id34", "Outfitting4List_files/transparent.gif");
    fixupIEPNGBG("id35");
    adjustLineHeightIfTooBig("id36");
    adjustFontSizeIfTooBig("id36");
    adjustLineHeightIfTooBig("id37");
    adjustFontSizeIfTooBig("id37");
    fixupIEPNG("id38", "Outfitting4List_files/transparent.gif");
    adjustLineHeightIfTooBig("id39");
    adjustFontSizeIfTooBig("id39");
    fixupIEPNG("id40", "Outfitting4List_files/transparent.gif");
    fixupIEPNG("id41", "Outfitting4List_files/transparent.gif");
    return true;
}

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 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 getChildOfType(oParent, sNodeName, requestedIndex)
{
    var index = 0;
    for (i = 0; i < oParent.childNodes.length; i++)
    {
        if (oParent.childNodes[i].nodeName == sNodeName)
        {
            if (index == requestedIndex)
            {
                return oParent.childNodes[i];
            }
            else
            {
                index++;
            }
        }
    }
    return null;
}

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

var MINIMUM_FONT = "10";
var UNITS = "";

function elementFontSize(element)
{
    var fontSize = MINIMUM_FONT; 

    if (document.defaultView)
    {
        fontSize = document.defaultView.getComputedStyle(element, null).getPropertyValue("font-size");
    }
    else if (element.currentStyle)
    {
        fontSize = element.currentStyle.fontSize;
    }

    if ((UNITS.length == 0) && (fontSize != MINIMUM_FONT))
    {
        UNITS = fontSize.substring(fontSize.length - 2, fontSize.length)
    }

    return parseFloat(fontSize);
}

function adjustFontSizeIfTooBig(idOfElement)
{
    var oTextBoxOuterDiv;
    var oTextBoxMiddleDiv;
    var oTextBoxInnerDiv;
    var oTextBoxOuterDiv = document.getElementById(idOfElement);
    
    if (oTextBoxOuterDiv)
    {
        oTextBoxMiddleDiv = getChildOfType(oTextBoxOuterDiv, "DIV", 0);
        if (oTextBoxMiddleDiv)
        {
            oTextBoxInnerDiv = getChildOfType(oTextBoxMiddleDiv, "DIV", 0);
            if (oTextBoxInnerDiv)
            {
                var oCachedHeight;
                if (windowsInternetExplorer)
                {
                    oCachedHeight = oTextBoxInnerDiv.style.height;
                    oTextBoxInnerDiv.style.height = "100px";
                }
                
                var clientHeight = oTextBoxInnerDiv.clientHeight;
                var specifiedHeight = clientHeight;
                if (oTextBoxMiddleDiv.style.height != "")
                {
                    specifiedHeight = parseFloat(oTextBoxMiddleDiv.style.height);
                }
                else if (oTextBoxOuterDiv.style.height != "")
                {
                    specifiedHeight = parseFloat(oTextBoxOuterDiv.style.height);
                }
                if ((windowsInternetExplorer) && (clientHeight == 100))
                {
                    clientHeight = specifiedHeight;
                }
                if (clientHeight > specifiedHeight)
                {
                    // compute smallest font in text box for scale purposes.
                    var smallestFontSize = 200;
                    
                    var aParaChildren = getParaDescendants(oTextBoxInnerDiv);
                    var oneLine = false;
                    for (i = 0; i < aParaChildren.length; i++)
                    {
                        var oParagraphDiv = aParaChildren[i];
                        var lineHeight = elementLineHeight(oParagraphDiv);
                        oneLine = oneLine || (lineHeight * 1.5 >= specifiedHeight);
                        if (oParagraphDiv.nodeName == "DIV")
                        {
                            var fontSize = elementFontSize(oParagraphDiv);
                            smallestFontSize = Math.min( smallestFontSize, fontSize );
                            for (j = 0; j < oParagraphDiv.childNodes.length; j++)
                            {
                                var oSpan = oParagraphDiv.childNodes[j];
                                if (oSpan.nodeName == "SPAN")
                                {
                                    fontSize = elementFontSize(oSpan);
                                    smallestFontSize = Math.min( smallestFontSize, fontSize );
                                }
                            }
                        }
                    }
                    var minimum = parseFloat(MINIMUM_FONT);
                    
                    var count = 0
                    while ((smallestFontSize > minimum) && (clientHeight > specifiedHeight) && (count < 10))
                    {
                        ++ count;
                        if (oneLine)
                        {
                            var oldWidth = parseInt(oTextBoxOuterDiv.style.width);
                            oTextBoxInnerDiv.style.width =
                                "" + oldWidth * Math.pow(1.05, count) + "px";
                        }
                        else
                        {
                            var scale = Math.max(0.95, minimum / smallestFontSize);
                            
                            // Scale all the fonts in the text box.
                            for (i = 0; i < aParaChildren.length; i++)
                            {
                                var oParagraphDiv = aParaChildren[i];
                                if (oParagraphDiv.nodeName == "DIV")
                                {
                                    var fontSize = elementFontSize(oParagraphDiv) * scale;
                                    oParagraphDiv.style.fontSize = fontSize + UNITS;
                                    oParagraphDiv.style.lineHeight = fontSize + UNITS;
                                    smallestFontSize = Math.min( smallestFontSize, fontSize );
                                    for (j = 0; j < oParagraphDiv.childNodes.length; j++)
                                    {
                                        var oSpan = oParagraphDiv.childNodes[j];
                                        if (oSpan.nodeName == "SPAN")
                                        {
                                            fontSize = elementFontSize(oSpan) * scale;
                                            oSpan.style.fontSize = fontSize + UNITS;
                                            oSpan.style.lineHeight = fontSize + UNITS;
                                            smallestFontSize = Math.min( smallestFontSize, fontSize );
                                        }
                                    }
                                }
                            }
                        }
                        
                        clientHeight = oTextBoxInnerDiv.clientHeight;
                    }
                }
                if (windowsInternetExplorer)
                {
                    oTextBoxInnerDiv.style.height = oCachedHeight;
                }
            }
        }
    }
}


function elementLineHeight(element)
{
    var lineHeight = MINIMUM_FONT; 
    
    if (document.defaultView)
    {
        lineHeight = document.defaultView.getComputedStyle(element, null).getPropertyValue("line-height");
    }
    else if (element.currentStyle)
    {
        lineHeight = element.currentStyle.lineHeight;
    }
    
    if ((UNITS.length == 0) && (lineHeight != MINIMUM_FONT))
    {
        UNITS = lineHeight.substring(lineHeight.length - 2, lineHeight.length)
    }
    
    return parseFloat(lineHeight);
}

function adjustLineHeightIfTooBig(idOfElement)
{
    var oTextBoxOuterDiv;
    var oTextBoxMiddleDiv;
    var oTextBoxInnerDiv;
    var oTextBoxOuterDiv = document.getElementById(idOfElement);
    
    if (oTextBoxOuterDiv)
    {
        oTextBoxMiddleDiv = getChildOfType(oTextBoxOuterDiv, "DIV", 0);
        if (oTextBoxMiddleDiv)
        {
            oTextBoxInnerDiv = getChildOfType(oTextBoxMiddleDiv, "DIV", 0);
            if (oTextBoxInnerDiv)
            {
                var oCachedHeight;
                if (windowsInternetExplorer)
                {
                    oCachedHeight = oTextBoxInnerDiv.style.height;
                    oTextBoxInnerDiv.style.height = "100px";
                }
                
                var clientHeight = oTextBoxInnerDiv.clientHeight;
                var specifiedHeight = clientHeight;
                if (oTextBoxMiddleDiv.style.height != "")
                {
                    specifiedHeight = parseFloat(oTextBoxMiddleDiv.style.height);
                }
                else if (oTextBoxOuterDiv.style.height != "")
                {
                    specifiedHeight = parseFloat(oTextBoxOuterDiv.style.height);
                }
                if ((windowsInternetExplorer) && (clientHeight == 100))
                {
                    clientHeight = specifiedHeight;
                }
                if (clientHeight > specifiedHeight)
                {
                    var adjusted = true;
                    var count = 0;
                    while ((adjusted) && (clientHeight > specifiedHeight) && (count < 10))
                    {
                        adjusted = false;
                        ++ count;
                        
                        // Scale all the line heights in the text box.
                        var aParaChildren = getParaDescendants(oTextBoxInnerDiv);
                        for (i = 0; i < aParaChildren.length; i++)
                        {
                            var oParagraphDiv = aParaChildren[i];
                            if (oParagraphDiv.nodeName == "DIV")
                            {
                                var fontSize = elementFontSize(oParagraphDiv);
                                var lineHeight = elementLineHeight(oParagraphDiv) * 0.95;
                                if (lineHeight >= (fontSize * 1.1))
                                {
                                    oParagraphDiv.style.lineHeight = lineHeight + UNITS;
                                    adjusted = true;
                                }
                                
                                
                                
                                for (j = 0; j < oParagraphDiv.childNodes.length; j++)
                                {
                                    var oSpan = oParagraphDiv.childNodes[j];
                                    if (oSpan.nodeName == "SPAN")
                                    {
                                        var fontSize = elementFontSize(oSpan);
                                        var lineHeight = elementLineHeight(oSpan) * 0.95;
                                        if (lineHeight >= (fontSize * 1.1))
                                        {
                                            oSpan.style.lineHeight = lineHeight + UNITS;
                                            var adjusted = true;
                                        }
                                    }
                                }
                            }
                        }
                        
                        clientHeight = oTextBoxInnerDiv.clientHeight;
                    }
                }
                if (windowsInternetExplorer)
                {
                    oTextBoxInnerDiv.style.height = oCachedHeight;
                }
            }
        }
    }
}

var smallTransparentGif = "";
function fixupIEPNG(strImageID, transparentGif) 
{
    smallTransparentGif = transparentGif;
    if (windowsInternetExplorer)
    {
        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(strImageID) 
{
    if (windowsInternetExplorer)
    {
        var oBlock = document.getElementById(strImageID);
        if (oBlock)
        {
            var currentBGStyle = oBlock.style.background;
            var urlStart = currentBGStyle.indexOf("url(");
            var urlEnd = currentBGStyle.indexOf(")", urlStart);
            var imageURL = currentBGStyle.substring(urlStart + 4, urlEnd);
            var filterStyle =
                "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" +
                imageURL +
                "', sizingMethod='crop');";

            oBlock.style.filter = filterStyle;
            oBlock.style.background = "";
        }
    }
}

var windowsInternetExplorer = false;
function detectBrowser()
{
    windowsInternetExplorer = false;
    var appVersion = navigator.appVersion;
    if ((appVersion.indexOf("MSIE") != -1) &&
        (appVersion.indexOf("Macintosh") == -1))
    {
        windowsInternetExplorer = true;
    }
}


