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('../Bunsen_files/DCP_0434.jpg', '573', '800', 'Now doesn\u0027t he look smart?');
slides[1] = new Slide('../Bunsen_files/DCP_0613.jpg', '534', '800', 'Bunsen in the tub');
slides[2] = new Slide('../Bunsen_files/52_1.jpg', '534', '800', 'Playing in the bathtub');
slides[3] = new Slide('../Bunsen_files/DCP_0615.jpg', '534', '800', 'Is that a waterfall?');
slides[4] = new Slide('../Bunsen_files/DCP_0616.jpg', '534', '800', 'Works for him!');
slides[5] = new Slide('../Bunsen_files/DCP_0618.jpg', '534', '800', 'Wethead');
slides[6] = new Slide('../Bunsen_files/DCP_0620.jpg', '534', '800', 'Wet bird');
slides[7] = new Slide('../Bunsen_files/DCP_0621.jpg', '534', '800', 'Wet bird');
slides[8] = new Slide('../Bunsen_files/DCP_0619.jpg', '534', '800', 'Really wet bird');
slides[9] = new Slide('../Bunsen_files/DCP_0022.jpg', '534', '800', 'Growling at the hair/bird dryer');
slides[10] = new Slide('../Bunsen_files/DCP_0025.jpg', '534', '800', 'More growling');
slides[11] = new Slide('../Bunsen_files/DCP_0026.jpg', '624', '801', 'Spread those wingies...');
slides[12] = new Slide('../Bunsen_files/DCP_0027.jpg', '503', '800', 'That\u0027s it!');
slides[13] = new Slide('../Bunsen_files/DCP_0024.jpg', '600', '800', 'Dry yet?');
slides[14] = new Slide('../Bunsen_files/DCP_0611.jpg', '601', '800', 'Bunsen posing with wings flared.');
slides[15] = new Slide('../Bunsen_files/DCP_0641.jpg', '534', '800', 'Bunsen in his tissue box.');
slides[16] = new Slide('../Bunsen_files/Bunsen in his Tissue Box.jpg', '579', '800', 'Bunsen in his Tissue Box');
slides[17] = new Slide('../Bunsen_files/DCP_0076.jpg', '534', '800', 'Bunsen scales the lamp cord');
slides[18] = new Slide('../Bunsen_files/DCP_0077.jpg', '800', '534', 'He made it all the way to the top.');
slides[19] = new Slide('../Bunsen_files/DCP_0023.jpg', '534', '800', 'What\u0027s that on the light fixture?');
slides[20] = new Slide('../Bunsen_files/DCP_0021.jpg', '534', '800', 'It\u0027s just a green bird.');
slides[21] = new Slide('../Bunsen_files/DCP_0022_2.jpg', '534', '800', 'A big green bird.');
slides[22] = new Slide('../Bunsen_files/DCP_52.jpg', '709', '801', 'That biscuit is as big as his head!');
slides[23] = new Slide('../Bunsen_files/DCP_0119.jpg', '671', '800', 'Bunsen waves his wingies.');
slides[24] = new Slide('../Bunsen_files/DCP_166.jpg', '800', '737', 'Bunsen waves his wingies.');
slides[25] = new Slide('../Bunsen_files/DCP_167.jpg', '534', '800', 'Bunsen lies down when you ignore him.');
slides[26] = new Slide('../Bunsen_files/DCP_168.jpg', '534', '800', 'Peekaboo!');
slides[27] = new Slide('../Bunsen_files/DCP_169.jpg', '602', '800', 'Wave!');
slides[28] = new Slide('../Bunsen_files/DCP_0166.jpg', '700', '800', 'Bunsen lying down again.');
slides[29] = new Slide('../Bunsen_files/DCP_0182.jpg', '800', '678', 'Bunsen does his Dr. Evil.');
slides[30] = new Slide('../Bunsen_files/DCP_0483.jpg', '534', '800', 'Bunsen watches from above the doorway.');
slides[31] = new Slide('../Bunsen_files/DCP_0488.jpg', '800', '611', 'Wet bird.');
slides[32] = new Slide('../Bunsen_files/IMG_4022.jpg', '800', '519', 'Beauty shots in front of a black cloth.');
slides[33] = new Slide('../Bunsen_files/IMG_4023.jpg', '534', '800', 'Posing.');
slides[34] = new Slide('../Bunsen_files/IMG_4024.jpg', '534', '800', 'He\u0027s aloof.');
slides[35] = new Slide('../Bunsen_files/IMG_4026.jpg', '534', '800', 'Now he\u0027s a little more regal.');
slides[36] = new Slide('../Bunsen_files/IMG_4027.jpg', '534', '800', 'Straight on, it\u0027s a wonder he can see anything.');
slides[37] = new Slide('../Bunsen_files/IMG_4028.jpg', '534', '800', 'Sitting on his cage.');
slides[38] = new Slide('../Bunsen_files/IMG_4030.jpg', '534', '800', 'He was pretty scared of the cloth so I had to hold him.');
slides[39] = new Slide('../Bunsen_files/IMG_4031.jpg', '534', '800', 'Pose.');
slides[40] = new Slide('../Bunsen_files/IMG_4032.jpg', '534', '800', 'Pose.');
slides[41] = new Slide('../Bunsen_files/IMG_4033.jpg', '534', '800', 'Pose.');
slides[42] = new Slide('../Bunsen_files/IMG_4034.jpg', '534', '800', 'Wingies.');
slides[43] = new Slide('../Bunsen_files/IMG_4035.jpg', '534', '800', 'He hides behind something on the stairs.');
slides[44] = new Slide('../Bunsen_files/DCP_0010.jpg', '534', '800', 'June 2005: We find out Bunsen is very sick.');
slides[45] = new Slide('../Bunsen_files/DCP_0011.jpg', '534', '800', 'I took these pics because I thought he wouldn\u0027t be around much longer.');
slides[46] = new Slide('../Bunsen_files/DCP_0012.jpg', '534', '800', 'He had a bad day at the vet.');
slides[47] = new Slide('../Bunsen_files/DCP_0016.jpg', '534', '800', 'The doctor said to feed him anything he wanted.');
slides[48] = new Slide('../Bunsen_files/DCP_0103.jpg', '534', '800', 'Three months later, he\u0027s still around.');
slides[49] = new Slide('../Bunsen_files/DCP_0099.jpg', '593', '800', 'He\u0027s not giving up on life.');
slides[50] = new Slide('../Bunsen_files/DCP_0122.jpg', '414', '621', 'Although sometimes he doesn\u0027t care for the attention.');
slides[51] = new Slide('../Bunsen_files/DCP_0112.jpg', '534', '800', 'He doesn\u0027t chew tissue boxes anymore.');
slides[52] = new Slide('../Bunsen_files/DCP_0324.jpg', '800', '670', 'Bunsen sits on the pitcher.');
slides[53] = new Slide('../Bunsen_files/DCP_0325.jpg', '538', '801', 'So what if he\u0027s sick?  He wanted to sit here.');
slides[54] = new Slide('../Bunsen_files/DCP_0432.jpg', '474', '800', 'Oct 2006: Bunsen gets a shower.');
slides[55] = new Slide('../Bunsen_files/DCP_0433.jpg', '438', '800', 'He\u0027s very happy today.');
slides[56] = new Slide('../Bunsen_files/DCP_0434_2.jpg', '534', '800', 'Upside-down birdie!');
slides[57] = new Slide('../Bunsen_files/DCP_0435.jpg', '534', '800', 'Waiting to be dried.');
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");
    fixupIEPNG("id2", "Bunsen_files/transparent.gif");
    fixupIEPNG("id3", "Bunsen_files/transparent.gif");
    return true;
}


