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('../2007_03_cuoricino_files/IMG_0770.jpg', '800', '600', 'Elena filling LN');
slides[1] = new Slide('../2007_03_cuoricino_files/IMG_0776.jpg', '600', '800', 'wiring and front-end electronics inside faraday cage, next to cryostat for cuoricino');
slides[2] = new Slide('../2007_03_cuoricino_files/IMG_0777.jpg', '600', '800', 'close-up of cuoricino electronics');
slides[3] = new Slide('../2007_03_cuoricino_files/IMG_0778.jpg', '600', '800', 'top of cyostat.  The line going up is the LHe fill line.');
slides[4] = new Slide('../2007_03_cuoricino_files/IMG_0779.jpg', '600', '800', 'Cuoricino calibration goes into the green garden hose.  There are two inserts.');
slides[5] = new Slide('../2007_03_cuoricino_files/IMG_0780.jpg', '600', '800', 'Cuoricino calibration goes into the green garden hose.  There are two inserts.');
slides[6] = new Slide('../2007_03_cuoricino_files/IMG_0782.jpg', '600', '800', 'calibration source input.');
slides[7] = new Slide('../2007_03_cuoricino_files/IMG_0783.jpg', '600', '800', 'IMG_0783.JPG');
slides[8] = new Slide('../2007_03_cuoricino_files/IMG_0785.jpg', '600', '800', 'IMG_0785.JPG');
slides[9] = new Slide('../2007_03_cuoricino_files/IMG_0786.jpg', '600', '800', 'IMG_0786.JPG');
slides[10] = new Slide('../2007_03_cuoricino_files/IMG_0787.jpg', '600', '800', 'IMG_0787.JPG');
slides[11] = new Slide('../2007_03_cuoricino_files/IMG_0788.jpg', '600', '800', 'IMG_0788.JPG');
slides[12] = new Slide('../2007_03_cuoricino_files/IMG_0789.jpg', '800', '600', 'Radon meter sitting at bottom of Faraday cage for cuoricino.');
slides[13] = new Slide('../2007_03_cuoricino_files/IMG_0790.jpg', '800', '600', 'Ladder that leads to top of cuoricino cryostat inside faraday cage.');
slides[14] = new Slide('../2007_03_cuoricino_files/IMG_0772.jpg', '600', '800', 'Calibration source for cuoricino');
slides[15] = new Slide('../2007_03_cuoricino_files/IMG_0775.jpg', '600', '800', 'IMG_0775.JPG');
slides[16] = new Slide('../2007_03_cuoricino_files/IMG_0791.jpg', '800', '600', 'IMG_0791.JPG');
slides[17] = new Slide('../2007_03_cuoricino_files/IMG_0792.jpg', '600', '800', 'IMG_0792.JPG');
slides[18] = new Slide('../2007_03_cuoricino_files/IMG_0793.jpg', '600', '800', 'close up of end of teflon sleeve');
slides[19] = new Slide('../2007_03_cuoricino_files/IMG_0794.jpg', '600', '800', 'top of faraday cage.  LHe line goes into the left port');
slides[20] = new Slide('../2007_03_cuoricino_files/IMG_0795.jpg', '800', '600', 'Cuoricino LHe line, cryostat end.');
slides[21] = new Slide('../2007_03_cuoricino_files/IMG_0796.jpg', '800', '600', 'Looking down from top of Qino Faraday cage toward the pump/fridge control set-up.');
slides[22] = new Slide('../2007_03_cuoricino_files/IMG_0800.jpg', '600', '800', 'Elena is pulling out the LHe line from the dewar. ');
slides[23] = new Slide('../2007_03_cuoricino_files/IMG_0801.jpg', '800', '600', 'IMG_0801.JPG');
slides[24] = new Slide('../2007_03_cuoricino_files/IMG_0802.jpg', '600', '800', 'Qino He liquefier (not in use)');
slides[25] = new Slide('../2007_03_cuoricino_files/IMG_0803.jpg', '800', '600', 'Qino fridge control and pumps.');
slides[26] = new Slide('../2007_03_cuoricino_files/IMG_0804.jpg', '800', '600', 'Qino pumps');
slides[27] = new Slide('../2007_03_cuoricino_files/IMG_0805.jpg', '600', '800', 'Arrival of ICARUS tank (?) at LNGS');
slides[28] = new Slide('../2007_03_cuoricino_files/IMG_0806.jpg', '600', '800', 'IMG_0806.JPG');
slides[29] = new Slide('../2007_03_cuoricino_files/IMG_0807.jpg', '600', '800', 'IMG_0807.JPG');
slides[30] = new Slide('../2007_03_cuoricino_files/IMG_0808.jpg', '600', '800', 'IMG_0808.JPG');
slides[31] = new Slide('../2007_03_cuoricino_files/IMG_0811.jpg', '800', '600', 'IMG_0811.JPG');
slides[32] = new Slide('../2007_03_cuoricino_files/IMG_0815.jpg', '800', '600', 'IMG_0815.JPG');
slides[33] = new Slide('../2007_03_cuoricino_files/IMG_0816.jpg', '600', '800', 'IMG_0816.JPG');
slides[34] = new Slide('../2007_03_cuoricino_files/IMG_0769.jpg', '600', '800', 'Assergi and surrounding valley seen from lab.');
slides[35] = new Slide('../2007_03_cuoricino_files/IMG_0832.jpg', '600', '800', 'Funivia to Campo Imperatore.');
slides[36] = new Slide('../2007_03_cuoricino_files/IMG_0833.jpg', '600', '800', 'The walkway up behind Funivia.');
slides[37] = new Slide('../2007_03_cuoricino_files/IMG_0835.jpg', '600', '800', 'The walkway up behind Funivia.');
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", "2007_03_cuoricino_files/transparent.gif");
    fixupIEPNG("id3", "2007_03_cuoricino_files/transparent.gif");
    fixupIEPNG("id4", "2007_03_cuoricino_files/transparent.gif");
    fixupIEPNG("id5", "2007_03_cuoricino_files/transparent.gif");
    fixupIEPNG("id6", "2007_03_cuoricino_files/transparent.gif");
    fixupIEPNG("id7", "2007_03_cuoricino_files/transparent.gif");
    fixupIEPNG("id8", "2007_03_cuoricino_files/transparent.gif");
    fixupIEPNG("id9", "2007_03_cuoricino_files/transparent.gif");
    fixupIEPNG("id10", "2007_03_cuoricino_files/transparent.gif");
    return true;
}

