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('../museum-rarities_files/ms-vint-murals2.jpg', '785', '800', 'tile mosaic wall mural by Jane Martz');
slides[1] = new Slide('../museum-rarities_files/ms-vint-murals6.jpg', '800', '489', 'tile mosaic wall mural by Jane Martz');
slides[2] = new Slide('../museum-rarities_files/ms-vint-rare-chess.jpg', '571', '800', 'chess set, possibly unique');
slides[3] = new Slide('../museum-rarities_files/ms-vint-murals5.jpg', '800', '506', 'walnut and tile mosaic wall piece');
slides[4] = new Slide('../museum-rarities_files/ms-vint-murals4.jpg', '586', '800', 'this image might show almost all of the murals Jane made');
slides[5] = new Slide('../museum-rarities_files/ms-vint-murals1.jpg', '800', '661', 'wall murals by Jane Martz');
slides[6] = new Slide('../museum-rarities_files/ms-vint-murals3.jpg', '652', '800', 'a commissioned tile mural');
slides[7] = new Slide('../museum-rarities_files/ms-vint-largebowl.jpg', '703', '800', 'giant pressed slab bowl');
slides[8] = new Slide('../museum-rarities_files/ms-rare-JM-pitcher1950.jpg', '800', '800', 'late 1950 Jane Martz pitcher, after her marriage');
slides[9] = new Slide('../museum-rarities_files/MS_rare_earlytray.jpg', '600', '800', 'rare early Jane Martz tray, courtesy Rick Risser and David Dilley');
slides[10] = new Slide('../museum-rarities_files/ms-tray-earlygreen-1a.jpg', '449', '435', 'early 1950’s production tray with rare figural design');
slides[11] = new Slide('../museum-rarities_files/ms-trays-p10-11-16&p10-11-20-b.jpg', '479', '720', 'early p10 trays with rare figural designs');
slides[12] = new Slide('../museum-rarities_files/ms-rare-GM-slab2.jpg', '385', '801', '1952 slab tray by Gordon Martz, not in catalogs');
slides[13] = new Slide('../museum-rarities_files/ms-rare-GM-slab1.jpg', '442', '801', 'another view of the heavy slab tray');
slides[14] = new Slide('../museum-rarities_files/ms-rare-JM-bird_sculpture.jpg', '524', '801', 'bird sculpture probably by Jane Martz');
slides[15] = new Slide('../museum-rarities_files/ms-addressplaque&dossal.jpg', '532', '800', 'address plaque for 105 Newlin, The Home Accent Shop');
slides[16] = new Slide('../museum-rarities_files/ms-rare-dollhousebowls.jpg', '731', '800', 'Ken collects Martz - rare dollhouse dishes');
slides[17] = new Slide('../museum-rarities_files/ms-rare-hippo.jpg', '555', '800', 'the hippo was a production piece, but it is rare...');
slides[18] = new Slide('../museum-rarities_files/ms-rare-hippo2.jpg', '800', '532', 'especially with a face');
slides[19] = new Slide('../museum-rarities_files/ms-rare-JM-handthrown_crock.jpg', '624', '800', 'handmade crock - this appears in 1980’s cut sheets');
slides[20] = new Slide('../museum-rarities_files/ms-rare-JM-bowl_1992.jpg', '666', '800', '1992 handpainted whiteware studio bowl by Jane');
slides[21] = new Slide('../museum-rarities_files/ms-rare-JM-fishbowl-1994.jpg', '532', '800', '1994 studio fish bowl / wall plaque');
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", "museum-rarities_files/transparent.gif");
    fixupIEPNG("id3", "museum-rarities_files/transparent.gif");
    fixupIEPNG("id4", "museum-rarities_files/transparent.gif");
    fixupIEPNG("id5", "museum-rarities_files/transparent.gif");
    fixupIEPNG("id6", "museum-rarities_files/transparent.gif");
    fixupIEPNG("id7", "museum-rarities_files/transparent.gif");
    fixupIEPNG("id8", "museum-rarities_files/transparent.gif");
    fixupIEPNG("id9", "museum-rarities_files/transparent.gif");
    fixupIEPNG("id10", "museum-rarities_files/transparent.gif");
    fixupIEPNG("id11", "museum-rarities_files/transparent.gif");
    fixupIEPNG("id12", "museum-rarities_files/transparent.gif");
    fixupIEPNG("id13", "museum-rarities_files/transparent.gif");
    fixupIEPNG("id14", "museum-rarities_files/transparent.gif");
    fixupIEPNG("id15", "museum-rarities_files/transparent.gif");
    fixupIEPNG("id16", "museum-rarities_files/transparent.gif");
    fixupIEPNG("id17", "museum-rarities_files/transparent.gif");
    fixupIEPNG("id18", "museum-rarities_files/transparent.gif");
    fixupIEPNG("id19", "museum-rarities_files/transparent.gif");
    fixupIEPNG("id20", "museum-rarities_files/transparent.gif");
    fixupIEPNG("id21", "museum-rarities_files/transparent.gif");
    fixupIEPNG("id22", "museum-rarities_files/transparent.gif");
    fixupIEPNG("id23", "museum-rarities_files/transparent.gif");
    fixupIEPNG("id24", "museum-rarities_files/transparent.gif");
    fixupIEPNG("id25", "museum-rarities_files/transparent.gif");
    return true;
}

