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('../Watson_files/P1040410.jpg', '600', '800', '');
slides[1] = new Slide('../Watson_files/P1040417.jpg', '600', '800', 'Lynda intrigué par un arbre a gomme');
slides[2] = new Slide('../Watson_files/P1040421.jpg', '600', '800', '');
slides[3] = new Slide('../Watson_files/P1040422.jpg', '600', '800', '');
slides[4] = new Slide('../Watson_files/P1040423.jpg', '600', '800', '');
slides[5] = new Slide('../Watson_files/P1040431.jpg', '800', '600', 'la propriété de Higgins ds Magnum...');
slides[6] = new Slide('../Watson_files/P1040432.jpg', '600', '800', 'on veut bien habiter la');
slides[7] = new Slide('../Watson_files/P1040437.jpg', '600', '800', '');
slides[8] = new Slide('../Watson_files/P1040442.jpg', '600', '800', '');
slides[9] = new Slide('../Watson_files/P1040443.jpg', '600', '800', '');
slides[10] = new Slide('../Watson_files/P1040459.jpg', '450', '800', 'Sydney skyline');
slides[11] = new Slide('../Watson_files/P1040463.jpg', '600', '800', 'le petit pier de Watson Bay');
slides[12] = new Slide('../Watson_files/P1040467.jpg', '600', '800', '');
slides[13] = new Slide('../Watson_files/P1040469.jpg', '600', '800', 'non c’est pas Quiberon');
slides[14] = new Slide('../Watson_files/P1040470.jpg', '600', '800', '');
slides[15] = new Slide('../Watson_files/P1040473.jpg', '600', '800', '');
slides[16] = new Slide('../Watson_files/P1040479.jpg', '600', '800', '');
slides[17] = new Slide('../Watson_files/P1040480.jpg', '453', '800', '');
slides[18] = new Slide('../Watson_files/P1040483.jpg', '450', '800', '');
slides[19] = new Slide('../Watson_files/P1040485.jpg', '600', '800', '');
slides[20] = new Slide('../Watson_files/P1040496.jpg', '600', '800', 'Ireland?');
slides[21] = new Slide('../Watson_files/P1040510.jpg', '600', '800', 'Arrivée a Katoomba');
slides[22] = new Slide('../Watson_files/P1040513.jpg', '600', '800', '');
slides[23] = new Slide('../Watson_files/P1040514.jpg', '600', '800', 'Ahhhhhhh');
slides[24] = new Slide('../Watson_files/P1040518.jpg', '600', '800', '');
slides[25] = new Slide('../Watson_files/P1040519.jpg', '600', '800', 'la 100eme photo du genre...');
slides[26] = new Slide('../Watson_files/P1040521.jpg', '600', '800', 'les 3 Soeurs \n(The Three Sisters)');
slides[27] = new Slide('../Watson_files/P1040523.jpg', '800', '600', '');
slides[28] = new Slide('../Watson_files/P1040524.jpg', '800', '600', '');
slides[29] = new Slide('../Watson_files/P1040526.jpg', '600', '800', 'wooo pinaise');
slides[30] = new Slide('../Watson_files/P1040528.jpg', '600', '800', '');
slides[31] = new Slide('../Watson_files/P1040529.jpg', '600', '800', '');
slides[32] = new Slide('../Watson_files/P1040531.jpg', '450', '800', '');
slides[33] = new Slide('../Watson_files/P1040532.jpg', '800', '600', '');
slides[34] = new Slide('../Watson_files/P1040534.jpg', '600', '800', '');
slides[35] = new Slide('../Watson_files/P1040539.jpg', '800', '600', '');
slides[36] = new Slide('../Watson_files/P1040541.jpg', '600', '800', '');
slides[37] = new Slide('../Watson_files/P1040542.jpg', '600', '800', '');
slides[38] = new Slide('../Watson_files/P1040543.jpg', '600', '800', '');
slides[39] = new Slide('../Watson_files/P1040544.jpg', '600', '800', '');
slides[40] = new Slide('../Watson_files/P1040545.jpg', '800', '600', '');
slides[41] = new Slide('../Watson_files/P1040547.jpg', '800', '600', '');
slides[42] = new Slide('../Watson_files/P1040548.jpg', '800', '600', '');
slides[43] = new Slide('../Watson_files/P1040549.jpg', '600', '800', 'Wo purée c’est wo');
slides[44] = new Slide('../Watson_files/P1040550.jpg', '800', '600', 'po rassurée la hein, on fait pas la maline!');
slides[45] = new Slide('../Watson_files/P1040551.jpg', '800', '600', '');
slides[46] = new Slide('../Watson_files/P1040552.jpg', '600', '800', '');
slides[47] = new Slide('../Watson_files/P1040553.jpg', '800', '600', '');
slides[48] = new Slide('../Watson_files/P1040554.jpg', '800', '600', '');
slides[49] = new Slide('../Watson_files/P1040556.jpg', '800', '600', '');
slides[50] = new Slide('../Watson_files/P1040557.jpg', '600', '800', '');
slides[51] = new Slide('../Watson_files/P1040562.jpg', '600', '800', '');
slides[52] = new Slide('../Watson_files/P1040563.jpg', '800', '600', '');
slides[53] = new Slide('../Watson_files/P1040564.jpg', '800', '600', '');
slides[54] = new Slide('../Watson_files/P1040565.jpg', '600', '800', '');
slides[55] = new Slide('../Watson_files/P1040566.jpg', '600', '800', '');
slides[56] = new Slide('../Watson_files/P1040573.jpg', '600', '800', 'Katoomba cascades');
slides[57] = new Slide('../Watson_files/P1040578.jpg', '800', '600', '');
slides[58] = new Slide('../Watson_files/P1040579.jpg', '600', '800', '');
slides[59] = new Slide('../Watson_files/P1040582.jpg', '600', '800', '');
slides[60] = new Slide('../Watson_files/P1040586.jpg', '600', '800', '');
slides[61] = new Slide('../Watson_files/P1040587.jpg', '800', '600', '');
slides[62] = new Slide('../Watson_files/P1040588.jpg', '600', '800', '');
slides[63] = new Slide('../Watson_files/P1040589.jpg', '600', '800', 'la 101eme :)');
slides[64] = new Slide('../Watson_files/P1040593.jpg', '453', '800', '');
slides[65] = new Slide('../Watson_files/P1040594.jpg', '800', '600', '');
slides[66] = new Slide('../Watson_files/P1040598.jpg', '600', '800', 'o secours!');
slides[67] = new Slide('../Watson_files/P1040599.jpg', '800', '600', '');
slides[68] = new Slide('../Watson_files/P1040600.jpg', '800', '600', '');
slides[69] = new Slide('../Watson_files/P1040601.jpg', '800', '600', '');
slides[70] = new Slide('../Watson_files/P1040602.jpg', '600', '800', '');
slides[71] = new Slide('../Watson_files/P1040603.jpg', '600', '800', '');
slides[72] = new Slide('../Watson_files/P1040607.jpg', '800', '600', '');
slides[73] = new Slide('../Watson_files/P1040608.jpg', '800', '600', '');
slides[74] = new Slide('../Watson_files/P1040609.jpg', '800', '600', 'Katoomba falls');
slides[75] = new Slide('../Watson_files/P1040610.jpg', '800', '600', '');
slides[76] = new Slide('../Watson_files/P1040611.jpg', '600', '800', '');
slides[77] = new Slide('../Watson_files/P1040614.jpg', '800', '600', '');
slides[78] = new Slide('../Watson_files/P1040618.jpg', '800', '600', '');
slides[79] = new Slide('../Watson_files/P1040622.jpg', '600', '800', 'descente dans la rainforest');
slides[80] = new Slide('../Watson_files/P1040623.jpg', '600', '800', '');
slides[81] = new Slide('../Watson_files/P1040628.jpg', '800', '600', '');
slides[82] = new Slide('../Watson_files/P1040629.jpg', '800', '600', '');
slides[83] = new Slide('../Watson_files/P1040631.jpg', '453', '800', '');
slides[84] = new Slide('../Watson_files/P1040639.jpg', '800', '600', '');
slides[85] = new Slide('../Watson_files/P1040643.jpg', '800', '600', '');
slides[86] = new Slide('../Watson_files/P1040651.jpg', '800', '600', '');
slides[87] = new Slide('../Watson_files/P1040652.jpg', '800', '600', '');
slides[88] = new Slide('../Watson_files/P1040653.jpg', '800', '600', '');
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 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");
    return true;
}

