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('../InTheStudio_files/P3260065.jpg', '480', '640', 'Getting ready to leave!');
slides[1] = new Slide('../InTheStudio_files/P3260062.jpg', '480', '640', 'P3260062');
slides[2] = new Slide('../InTheStudio_files/P3240054.jpg', '480', '640', 'coming through Atlanta...');
slides[3] = new Slide('../InTheStudio_files/P3240055.jpg', '480', '640', 'P3240055');
slides[4] = new Slide('../InTheStudio_files/P3260074.jpg', '480', '640', 'Those are REAL FISH!!');
slides[5] = new Slide('../InTheStudio_files/P3260077.jpg', '480', '640', 'P3260077');
slides[6] = new Slide('../InTheStudio_files/P3260080.jpg', '480', '640', 'P3260080');
slides[7] = new Slide('../InTheStudio_files/P3260083.jpg', '480', '640', 'P3260083');
slides[8] = new Slide('../InTheStudio_files/P3260100.jpg', '480', '640', 'P3260100');
slides[9] = new Slide('../InTheStudio_files/P3260114.jpg', '480', '640', 'P3260114');
slides[10] = new Slide('../InTheStudio_files/P3260124.jpg', '480', '640', 'P3260124');
slides[11] = new Slide('../InTheStudio_files/P3260125.jpg', '480', '640', 'P3260125');
slides[12] = new Slide('../InTheStudio_files/P3260126.jpg', '480', '640', 'P3260126');
slides[13] = new Slide('../InTheStudio_files/P3260127.jpg', '480', '640', 'P3260127');
slides[14] = new Slide('../InTheStudio_files/P3260128.jpg', '480', '640', 'OUCH!  Isn’t this supposed to relax me!?!?');
slides[15] = new Slide('../InTheStudio_files/P3260129.jpg', '480', '640', 'P3260129');
slides[16] = new Slide('../InTheStudio_files/P3260132.jpg', '480', '640', 'Git’r Done!');
slides[17] = new Slide('../InTheStudio_files/P3260133.jpg', '480', '640', 'What’cha doin’ Mr. Crook?');
slides[18] = new Slide('../InTheStudio_files/P3260136.jpg', '480', '640', 'Kaila signs a writing contract with Eddie Crook');
slides[19] = new Slide('../InTheStudio_files/P3260137.jpg', '480', '640', 'Kaila and Scott Russell');
slides[20] = new Slide('../InTheStudio_files/P3260138.jpg', '480', '640', 'P3260138');
slides[21] = new Slide('../InTheStudio_files/P3260139.jpg', '480', '640', 'Sylvia signs...');
slides[22] = new Slide('../InTheStudio_files/P3260140.jpg', '480', '640', 'Alan hangs out - ha!');
slides[23] = new Slide('../InTheStudio_files/P3260141.jpg', '480', '640', 'Jon Michael is ALWAYS on the phone!');
slides[24] = new Slide('../InTheStudio_files/P3260144.jpg', '480', '640', 'P3260144');
slides[25] = new Slide('../InTheStudio_files/P3260146.jpg', '480', '640', 'P3260146');
slides[26] = new Slide('../InTheStudio_files/P3260149.jpg', '480', '640', 'P3260149');
slides[27] = new Slide('../InTheStudio_files/P3260151.jpg', '480', '640', 'P3260151');
slides[28] = new Slide('../InTheStudio_files/P3270156.jpg', '480', '640', 'P3270156');
slides[29] = new Slide('../InTheStudio_files/P3270157.jpg', '480', '640', 'P3270157');
slides[30] = new Slide('../InTheStudio_files/P3270158.jpg', '480', '640', 'P3270158');
slides[31] = new Slide('../InTheStudio_files/P3270159.jpg', '480', '640', 'P3270159');
slides[32] = new Slide('../InTheStudio_files/P3270161.jpg', '480', '640', 'P3270161');
slides[33] = new Slide('../InTheStudio_files/P3270162.jpg', '480', '640', 'P3270162');
slides[34] = new Slide('../InTheStudio_files/P3270163.jpg', '480', '640', 'P3270163');
slides[35] = new Slide('../InTheStudio_files/P3270166.jpg', '480', '640', 'P3270166');
slides[36] = new Slide('../InTheStudio_files/P3270168.jpg', '480', '640', 'P3270168');
slides[37] = new Slide('../InTheStudio_files/P3270169.jpg', '480', '640', 'P3270169');
slides[38] = new Slide('../InTheStudio_files/P3270170.jpg', '480', '640', 'P3270170');
slides[39] = new Slide('../InTheStudio_files/P3270171.jpg', '480', '640', 'P3270171');
slides[40] = new Slide('../InTheStudio_files/P3270172.jpg', '480', '640', 'P3270172');
slides[41] = new Slide('../InTheStudio_files/P3270173.jpg', '480', '640', 'P3270173');
slides[42] = new Slide('../InTheStudio_files/P3270174.jpg', '480', '640', 'P3270174');
slides[43] = new Slide('../InTheStudio_files/P3270175.jpg', '480', '640', 'P3270175');
slides[44] = new Slide('../InTheStudio_files/P3270176.jpg', '480', '640', 'P3270176');
slides[45] = new Slide('../InTheStudio_files/P3270180.jpg', '480', '640', 'P3270180');
slides[46] = new Slide('../InTheStudio_files/P3270183.jpg', '480', '640', 'P3270183');
slides[47] = new Slide('../InTheStudio_files/P3270184.jpg', '480', '640', 'P3270184');
slides[48] = new Slide('../InTheStudio_files/P3270185.jpg', '480', '640', 'P3270185');
slides[49] = new Slide('../InTheStudio_files/P3270186.jpg', '480', '640', 'P3270186');
slides[50] = new Slide('../InTheStudio_files/P3270187.jpg', '480', '640', 'P3270187');
slides[51] = new Slide('../InTheStudio_files/P3270188.jpg', '480', '640', 'P3270188');
slides[52] = new Slide('../InTheStudio_files/P3270191.jpg', '480', '640', 'P3270191');
slides[53] = new Slide('../InTheStudio_files/P3270196.jpg', '480', '640', 'P3270196');
slides[54] = new Slide('../InTheStudio_files/P3270201.jpg', '480', '640', 'P3270201');
slides[55] = new Slide('../InTheStudio_files/P3270203.jpg', '480', '640', 'P3270203');
slides[56] = new Slide('../InTheStudio_files/P3280205.jpg', '480', '640', 'P3280205');
slides[57] = new Slide('../InTheStudio_files/P3280206.jpg', '480', '640', 'P3280206');
slides[58] = new Slide('../InTheStudio_files/P3280207.jpg', '480', '640', 'P3280207');
slides[59] = new Slide('../InTheStudio_files/P3280209.jpg', '480', '640', 'P3280209');
slides[60] = new Slide('../InTheStudio_files/P3280210.jpg', '480', '640', 'P3280210');
slides[61] = new Slide('../InTheStudio_files/P3280211.jpg', '480', '640', 'P3280211');
slides[62] = new Slide('../InTheStudio_files/P3280212.jpg', '480', '640', 'P3280212');
slides[63] = new Slide('../InTheStudio_files/P3280214.jpg', '480', '640', 'P3280214');
slides[64] = new Slide('../InTheStudio_files/P3270200.jpg', '480', '361', 'P3270200');
slides[65] = new Slide('../InTheStudio_files/P3270202.jpg', '480', '568', 'P3270202');
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;
    }
}

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 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");
    fixupAllIEPNGBGs();
    return true;
}

