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('../Art_files/A-Red-Line-Composte02-small.jpg', '151', '800', 'A-Red-Line-Composte02-small.jpg');
slides[1] = new Slide('../Art_files/Three Red Blocks.jpg', '451', '801', 'Three Red Blocks.jpg');
slides[2] = new Slide('../Art_files/A-Day-Out.jpg', '800', '800', 'A-Day-Out.jpg');
slides[3] = new Slide('../Art_files/And So They Walked.jpg', '531', '800', 'And So They Walked.jpg');
slides[4] = new Slide('../Art_files/And So They Walked02.jpg', '476', '800', 'And So They Walked02.jpg');
slides[5] = new Slide('../Art_files/And So They Walked03.jpg', '549', '800', 'And So They Walked03.jpg');
slides[6] = new Slide('../Art_files/Art in the Park 03.jpg', '600', '800', 'Art in the Park 03.jpg');
slides[7] = new Slide('../Art_files/Art in the Park 05.jpg', '800', '600', 'Art in the Park 05.jpg');
slides[8] = new Slide('../Art_files/IMG_7282.jpg', '800', '600', 'IMG_7282.jpg');
slides[9] = new Slide('../Art_files/IMG_7283.jpg', '800', '600', 'IMG_7283.jpg');
slides[10] = new Slide('../Art_files/IMG_7284.jpg', '800', '600', 'IMG_7284.jpg');
slides[11] = new Slide('../Art_files/DSCF2853.jpg', '800', '588', 'DSCF2853.jpg');
slides[12] = new Slide('../Art_files/DSCF2854.jpg', '800', '600', 'DSCF2854.jpg');
slides[13] = new Slide('../Art_files/DSCF3043.jpg', '600', '800', 'DSCF3043.jpg');
slides[14] = new Slide('../Art_files/DSCF3044.jpg', '800', '600', 'DSCF3044.jpg');
slides[15] = new Slide('../Art_files/DSCF3048.jpg', '600', '800', 'DSCF3048.jpg');
slides[16] = new Slide('../Art_files/DSCF3049.jpg', '600', '800', 'DSCF3049.jpg');
slides[17] = new Slide('../Art_files/DSCF3050.jpg', '600', '800', 'DSCF3050.jpg');
slides[18] = new Slide('../Art_files/DSCF3051.jpg', '600', '800', 'DSCF3051.jpg');
slides[19] = new Slide('../Art_files/DSCF3052.jpg', '600', '800', 'DSCF3052.jpg');
slides[20] = new Slide('../Art_files/DSCF3053.jpg', '600', '800', 'DSCF3053.jpg');
slides[21] = new Slide('../Art_files/DSCF3054.jpg', '600', '800', 'DSCF3054.jpg');
slides[22] = new Slide('../Art_files/marians picks - 08.jpg', '480', '640', 'marians picks - 08.jpg');
slides[23] = new Slide('../Art_files/marians picks - 09.jpg', '480', '640', 'marians picks - 09.jpg');
slides[24] = new Slide('../Art_files/marians picks - 10.jpg', '480', '640', 'marians picks - 10.jpg');
slides[25] = new Slide('../Art_files/marians picks - 11.jpg', '480', '640', 'marians picks - 11.jpg');
slides[26] = new Slide('../Art_files/Panels 123.jpg', '800', '600', 'Panels 123.jpg');
slides[27] = new Slide('../Art_files/02.jpg', '375', '281', '02.jpg');
slides[28] = new Slide('../Art_files/04.jpg', '375', '281', '04.jpg');
slides[29] = new Slide('../Art_files/DSCF3021.jpg', '800', '600', 'DSCF3021.jpg');
slides[30] = new Slide('../Art_files/DSCF3022.jpg', '800', '600', 'DSCF3022.jpg');
slides[31] = new Slide('../Art_files/DSCF3023.jpg', '800', '600', 'DSCF3023.jpg');
slides[32] = new Slide('../Art_files/DSCF3024.jpg', '800', '600', 'DSCF3024.jpg');
slides[33] = new Slide('../Art_files/DSCF3025.jpg', '800', '600', 'DSCF3025.jpg');
slides[34] = new Slide('../Art_files/DSCF3026.jpg', '800', '600', 'DSCF3026.jpg');
slides[35] = new Slide('../Art_files/DSCF3027.jpg', '800', '600', 'DSCF3027.jpg');
slides[36] = new Slide('../Art_files/DSCF3028.jpg', '800', '600', 'DSCF3028.jpg');
slides[37] = new Slide('../Art_files/DSCF3055.jpg', '800', '617', 'DSCF3055.jpg');
slides[38] = new Slide('../Art_files/DSCF3061.jpg', '701', '800', 'DSCF3061.jpg');
slides[39] = new Slide('../Art_files/DSCF3072.jpg', '800', '448', 'DSCF3072.jpg');
slides[40] = new Slide('../Art_files/DSCF3075.jpg', '800', '458', 'DSCF3075.jpg');
slides[41] = new Slide('../Art_files/Enlarge01.jpg', '280', '800', 'Enlarge01.jpg');
slides[42] = new Slide('../Art_files/Enlarge02.jpg', '280', '800', 'Enlarge02.jpg');
slides[43] = new Slide('../Art_files/Enlarge03.jpg', '280', '800', 'Enlarge03.jpg');
slides[44] = new Slide('../Art_files/Enlarge04.jpg', '280', '800', 'Enlarge04.jpg');
slides[45] = new Slide('../Art_files/A Nights Tale Zoom01.jpg', '800', '600', 'A Nights Tale Zoom01.jpg');
slides[46] = new Slide('../Art_files/A Nights Tale Zoom 02.jpg', '600', '800', 'A Nights Tale Zoom 02.jpg');
slides[47] = new Slide('../Art_files/Between the Lines.jpg', '701', '800', 'Between the Lines.jpg');
slides[48] = new Slide('../Art_files/Colour Field I.jpg', '419', '801', 'Colour Field I.jpg');
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("id3");
    adjustFontSizeIfTooBig("id3");
    adjustLineHeightIfTooBig("id4");
    adjustFontSizeIfTooBig("id4");
    adjustLineHeightIfTooBig("id5");
    adjustFontSizeIfTooBig("id5");
    adjustLineHeightIfTooBig("id6");
    adjustFontSizeIfTooBig("id6");
    adjustLineHeightIfTooBig("id7");
    adjustFontSizeIfTooBig("id7");
    adjustLineHeightIfTooBig("id8");
    adjustFontSizeIfTooBig("id8");
    adjustLineHeightIfTooBig("id9");
    adjustFontSizeIfTooBig("id9");
    adjustLineHeightIfTooBig("id10");
    adjustFontSizeIfTooBig("id10");
    adjustLineHeightIfTooBig("id15");
    adjustFontSizeIfTooBig("id15");
    adjustLineHeightIfTooBig("id16");
    adjustFontSizeIfTooBig("id16");
    adjustLineHeightIfTooBig("id17");
    adjustFontSizeIfTooBig("id17");
    adjustLineHeightIfTooBig("id20");
    adjustFontSizeIfTooBig("id20");
    adjustLineHeightIfTooBig("id21");
    adjustFontSizeIfTooBig("id21");
    adjustLineHeightIfTooBig("id22");
    adjustFontSizeIfTooBig("id22");
    adjustLineHeightIfTooBig("id23");
    adjustFontSizeIfTooBig("id23");
    adjustLineHeightIfTooBig("id24");
    adjustFontSizeIfTooBig("id24");
    adjustLineHeightIfTooBig("id25");
    adjustFontSizeIfTooBig("id25");
    adjustLineHeightIfTooBig("id26");
    adjustFontSizeIfTooBig("id26");
    adjustLineHeightIfTooBig("id27");
    adjustFontSizeIfTooBig("id27");
    adjustLineHeightIfTooBig("id28");
    adjustFontSizeIfTooBig("id28");
    fixupIEPNG("id2", "Art_files/transparent.gif");
    fixupIEPNG("id11", "Art_files/transparent.gif");
    fixupIEPNG("id12", "Art_files/transparent.gif");
    fixupIEPNG("id13", "Art_files/transparent.gif");
    fixupIEPNG("id14", "Art_files/transparent.gif");
    fixupIEPNG("id18", "Art_files/transparent.gif");
    fixupIEPNG("id19", "Art_files/transparent.gif");
    return true;
}

