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('../Walk Photos Day 35 to End_files/DSC02657.jpg', '600', '800', 'Another day begins');
slides[1] = new Slide('../Walk Photos Day 35 to End_files/DSC02660.jpg', '600', '800', '');
slides[2] = new Slide('../Walk Photos Day 35 to End_files/DSC02667.jpg', '800', '600', 'Finishing another climb');
slides[3] = new Slide('../Walk Photos Day 35 to End_files/DSC02677.jpg', '600', '800', 'Utah is 6 miles ahead');
slides[4] = new Slide('../Walk Photos Day 35 to End_files/DSC02681.jpg', '800', '600', 'YEAH UTAH !!');
slides[5] = new Slide('../Walk Photos Day 35 to End_files/For Neil.jpg', '238', '271', '');
slides[6] = new Slide('../Walk Photos Day 35 to End_files/DSC02682.jpg', '600', '800', 'Ursula, our wonderful host at The Border Inn');
slides[7] = new Slide('../Walk Photos Day 35 to End_files/DSC02687.jpg', '535', '800', '');
slides[8] = new Slide('../Walk Photos Day 35 to End_files/DSC02690.jpg', '535', '800', '');
slides[9] = new Slide('../Walk Photos Day 35 to End_files/DSC02699.jpg', '535', '800', '');
slides[10] = new Slide('../Walk Photos Day 35 to End_files/DSC02705.jpg', '800', '535', '');
slides[11] = new Slide('../Walk Photos Day 35 to End_files/DSC02717.jpg', '535', '800', 'I meet fellow walkers');
slides[12] = new Slide('../Walk Photos Day 35 to End_files/DSC02718.jpg', '535', '800', 'David, Stuart & Jon');
slides[13] = new Slide('../Walk Photos Day 35 to End_files/DSC02719.jpg', '535', '800', '');
slides[14] = new Slide('../Walk Photos Day 35 to End_files/DSC02727.jpg', '535', '800', '');
slides[15] = new Slide('../Walk Photos Day 35 to End_files/DSC02753.jpg', '600', '800', 'Another day begins');
slides[16] = new Slide('../Walk Photos Day 35 to End_files/DSC02761.jpg', '600', '800', '');
slides[17] = new Slide('../Walk Photos Day 35 to End_files/DSC02754.jpg', '800', '600', '');
slides[18] = new Slide('../Walk Photos Day 35 to End_files/DSC02767.jpg', '800', '600', '');
slides[19] = new Slide('../Walk Photos Day 35 to End_files/DSC02770.jpg', '600', '800', 'Salt Flats: Ancient ocean floor');
slides[20] = new Slide('../Walk Photos Day 35 to End_files/DSC02776.jpg', '535', '800', 'My new (Italian) friends Silvia & Matteo\nof Aspen, CO');
slides[21] = new Slide('../Walk Photos Day 35 to End_files/DSC02778.jpg', '800', '535', 'The shadows tell of a long day');
slides[22] = new Slide('../Walk Photos Day 35 to End_files/For Neil_2.jpg', '238', '271', '');
slides[23] = new Slide('../Walk Photos Day 35 to End_files/For Neil_4.jpg', '238', '271', '');
slides[24] = new Slide('../Walk Photos Day 35 to End_files/DSC00020.jpg', '535', '800', '');
slides[25] = new Slide('../Walk Photos Day 35 to End_files/DSC00022.jpg', '535', '800', '');
slides[26] = new Slide('../Walk Photos Day 35 to End_files/DSC00029.jpg', '800', '535', 'Hey Craig, reflections in glass?');
slides[27] = new Slide('../Walk Photos Day 35 to End_files/DSC00031.jpg', '535', '800', 'Old charcoal making ovens');
slides[28] = new Slide('../Walk Photos Day 35 to End_files/DSC00032.jpg', '535', '800', 'Big rattler that William almost stepped on');
slides[29] = new Slide('../Walk Photos Day 35 to End_files/DSC00037.jpg', '535', '800', '');
slides[30] = new Slide('../Walk Photos Day 35 to End_files/DSC00038.jpg', '535', '800', 'The Wasatch range comes into view');
slides[31] = new Slide('../Walk Photos Day 35 to End_files/DSC00040.jpg', '800', '535', 'I love you Leo Hollingshead');
slides[32] = new Slide('../Walk Photos Day 35 to End_files/For Neil_6.jpg', '238', '271', '');
slides[33] = new Slide('../Walk Photos Day 35 to End_files/DSC00059.jpg', '535', '800', '');
slides[34] = new Slide('../Walk Photos Day 35 to End_files/For Neil_8.jpg', '238', '271', '');
slides[35] = new Slide('../Walk Photos Day 35 to End_files/DSC00071.jpg', '535', '800', 'Coming down into Nephi, UT');
slides[36] = new Slide('../Walk Photos Day 35 to End_files/DSC00080.jpg', '535', '800', '');
slides[37] = new Slide('../Walk Photos Day 35 to End_files/DSC00082.jpg', '600', '800', '');
slides[38] = new Slide('../Walk Photos Day 35 to End_files/DSC00084.jpg', '600', '800', '');
slides[39] = new Slide('../Walk Photos Day 35 to End_files/DSC00091.jpg', '600', '800', 'Essential oils from here helped me post surgery');
slides[40] = new Slide('../Walk Photos Day 35 to End_files/DSC00088.jpg', '600', '800', 'Talking to my Mom in law Kathy');
slides[41] = new Slide('../Walk Photos Day 35 to End_files/DSC00096.jpg', '600', '800', '');
slides[42] = new Slide('../Walk Photos Day 35 to End_files/DSC00083.jpg', '600', '800', 'Is this fish female or mail?');
slides[43] = new Slide('../Walk Photos Day 35 to End_files/For Neil_10.jpg', '238', '271', '');
slides[44] = new Slide('../Walk Photos Day 35 to End_files/For Neil_12.jpg', '238', '271', '');
slides[45] = new Slide('../Walk Photos Day 35 to End_files/DSC00110.jpg', '800', '535', '');
slides[46] = new Slide('../Walk Photos Day 35 to End_files/DSC00131.jpg', '535', '800', '');
slides[47] = new Slide('../Walk Photos Day 35 to End_files/DSC00123.jpg', '800', '535', '');
slides[48] = new Slide('../Walk Photos Day 35 to End_files/DSC00137.jpg', '535', '800', '');
slides[49] = new Slide('../Walk Photos Day 35 to End_files/DSC00149.jpg', '535', '800', '');
slides[50] = new Slide('../Walk Photos Day 35 to End_files/DSC00144.jpg', '535', '800', 'Vest was courtesy of Ames Construction');
slides[51] = new Slide('../Walk Photos Day 35 to End_files/DSC00157.jpg', '535', '800', '');
slides[52] = new Slide('../Walk Photos Day 35 to End_files/DSC00162.jpg', '535', '800', '');
slides[53] = new Slide('../Walk Photos Day 35 to End_files/DSC00171.jpg', '535', '800', '');
slides[54] = new Slide('../Walk Photos Day 35 to End_files/DSC00175.jpg', '535', '800', '');
slides[55] = new Slide('../Walk Photos Day 35 to End_files/DSC00184.jpg', '535', '800', '');
slides[56] = new Slide('../Walk Photos Day 35 to End_files/DSC00189.jpg', '535', '800', '');
isPureISOLatin1 = true;
contentEncodingConstant = 4;
feedbackURL = "TODO";
showFeedbackButton = false;
feedbackEnabled = true;

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

function elementFontSize(element)
{
    var fontSize = MINIMUM_FONT; 

    if (document.defaultView)
    {
        var computedStyle = document.defaultView.getComputedStyle(element, null);
        if (computedStyle)
        {
            fontSize = computedStyle.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 offsetHeight = oTextBoxInnerDiv.offsetHeight;
                var specifiedHeight = offsetHeight;
                if (oTextBoxMiddleDiv.style.height != "")
                {
                    specifiedHeight = parseFloat(oTextBoxMiddleDiv.style.height);
                }
                else if (oTextBoxOuterDiv.style.height != "")
                {
                    specifiedHeight = parseFloat(oTextBoxOuterDiv.style.height);
                }
                if (offsetHeight > specifiedHeight)
                {
                    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") || (oSpan.nodeName == "A"))
                                {
                                    fontSize = elementFontSize(oSpan);
                                    smallestFontSize = Math.min( smallestFontSize, fontSize );
                                }
                            }
                        }
                    }
                    var minimum = parseFloat(MINIMUM_FONT);
                    
                    var count = 0
                    while ((smallestFontSize > minimum) && (offsetHeight > 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);
                            
                            for (i = 0; i < aParaChildren.length; i++)
                            {
                                var oParagraphDiv = aParaChildren[i];
                                if (oParagraphDiv.nodeName == "DIV")
                                {
                                    var paraFontSize = elementFontSize(oParagraphDiv) * scale;
                                    var paraLineHeight = elementLineHeight(oParagraphDiv) * scale;
                                    for (j = 0; j < oParagraphDiv.childNodes.length; j++)
                                    {
                                        var oSpan = oParagraphDiv.childNodes[j];
                                        if ((oSpan.nodeName == "SPAN") || (oSpan.nodeName == "A"))
                                        {
                                            var spanFontSize = elementFontSize(oSpan) * scale;
                                            var spanLineHeight = elementLineHeight(oSpan) * scale;
                                            oSpan.style.fontSize = spanFontSize + UNITS;
                                            oSpan.style.lineHeight = spanLineHeight + UNITS;
                                            smallestFontSize = Math.min( smallestFontSize, spanFontSize );
                                        }
                                    }
                                    oParagraphDiv.style.fontSize = paraFontSize + UNITS;
                                    oParagraphDiv.style.lineHeight = paraLineHeight + UNITS;
                                    smallestFontSize = Math.min( smallestFontSize, paraFontSize );
                                }
                            }
                        }
                        
                        offsetHeight = oTextBoxInnerDiv.offsetHeight;
                    }
                }
            }
        }
    }
}


function elementLineHeight(element)
{
    var lineHeight = MINIMUM_FONT; 
    
    if (document.defaultView)
    {
        var computedStyle = document.defaultView.getComputedStyle(element, null);
        if (computedStyle)
        {
            lineHeight = computedStyle.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 offsetHeight = oTextBoxInnerDiv.offsetHeight;
                var specifiedHeight = offsetHeight;
                if (oTextBoxMiddleDiv.style.height != "")
                {
                    specifiedHeight = parseFloat(oTextBoxMiddleDiv.style.height);
                }
                else if (oTextBoxOuterDiv.style.height != "")
                {
                    specifiedHeight = parseFloat(oTextBoxOuterDiv.style.height);
                }
                if (offsetHeight > specifiedHeight)
                {
                    var adjusted = true;
                    var count = 0;
                    while ((adjusted) && (offsetHeight > specifiedHeight) && (count < 10))
                    {
                        adjusted = false;
                        ++ count;
                        
                        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") || (oSpan.nodeName == "A"))
                                    {
                                        var fontSize = elementFontSize(oSpan);
                                        var lineHeight = elementLineHeight(oSpan) * 0.95;
                                        if (lineHeight >= (fontSize * 1.1))
                                        {
                                            oSpan.style.lineHeight = lineHeight + UNITS;
                                            var adjusted = true;
                                        }
                                    }
                                }
                            }
                        }
                        
                        offsetHeight = oTextBoxInnerDiv.offsetHeight;
                    }
                }
            }
        }
    }
}

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

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

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 childrenOfType = oParent.getElementsByTagName(sNodeName);
    return (requestedIndex < childrenOfType.length) ?
           childrenOfType.item(requestedIndex) : null;
}

function getParaDescendants(oAncestor)
{
    var oParaDescendants = new Array();
    var oPotentialParagraphs = oAncestor.getElementsByTagName('DIV');
    for (var iIndex=0; iIndex<oPotentialParagraphs.length; iIndex++)
    {
        var oNode = oPotentialParagraphs.item(iIndex);
        if (oNode.className.lastIndexOf('paragraph') != -1)
        {
            oParaDescendants.push(oNode);
        }
    }
    return oParaDescendants;
}

function onPageLoad()
{
    detectBrowser();
    adjustLineHeightIfTooBig("id1");
    adjustFontSizeIfTooBig("id1");
    adjustLineHeightIfTooBig("id17");
    adjustFontSizeIfTooBig("id17");
    adjustLineHeightIfTooBig("id18");
    adjustFontSizeIfTooBig("id18");
    adjustLineHeightIfTooBig("id19");
    adjustFontSizeIfTooBig("id19");
    adjustLineHeightIfTooBig("id20");
    adjustFontSizeIfTooBig("id20");
    adjustLineHeightIfTooBig("id21");
    adjustFontSizeIfTooBig("id21");
    adjustLineHeightIfTooBig("id22");
    adjustFontSizeIfTooBig("id22");
    adjustLineHeightIfTooBig("id23");
    adjustFontSizeIfTooBig("id23");
    adjustLineHeightIfTooBig("id24");
    adjustFontSizeIfTooBig("id24");
    adjustLineHeightIfTooBig("id25");
    adjustFontSizeIfTooBig("id25");
    fixupIEPNG("id2", "Walk Photos Day 35 to End_files/transparent.gif");
    fixupIEPNG("id3", "Walk Photos Day 35 to End_files/transparent.gif");
    fixupIEPNG("id4", "Walk Photos Day 35 to End_files/transparent.gif");
    fixupIEPNG("id5", "Walk Photos Day 35 to End_files/transparent.gif");
    fixupIEPNG("id6", "Walk Photos Day 35 to End_files/transparent.gif");
    fixupIEPNG("id7", "Walk Photos Day 35 to End_files/transparent.gif");
    fixupIEPNG("id8", "Walk Photos Day 35 to End_files/transparent.gif");
    fixupIEPNG("id9", "Walk Photos Day 35 to End_files/transparent.gif");
    fixupIEPNG("id10", "Walk Photos Day 35 to End_files/transparent.gif");
    fixupIEPNG("id11", "Walk Photos Day 35 to End_files/transparent.gif");
    fixupIEPNG("id12", "Walk Photos Day 35 to End_files/transparent.gif");
    fixupIEPNG("id13", "Walk Photos Day 35 to End_files/transparent.gif");
    fixupIEPNG("id14", "Walk Photos Day 35 to End_files/transparent.gif");
    fixupIEPNG("id15", "Walk Photos Day 35 to End_files/transparent.gif");
    fixupIEPNG("id16", "Walk Photos Day 35 to End_files/transparent.gif");
    return true;
}


