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('../sgmgharmonyhonors_files/DSC_7421.jpg', '536', '800', '');
slides[1] = new Slide('../sgmgharmonyhonors_files/DSC_7320.jpg', '536', '800', '');
slides[2] = new Slide('../sgmgharmonyhonors_files/DSC_7317.jpg', '536', '800', '');
slides[3] = new Slide('../sgmgharmonyhonors_files/DSC_7341.jpg', '536', '800', '');
slides[4] = new Slide('../sgmgharmonyhonors_files/DSC_7395.jpg', '536', '800', '');
slides[5] = new Slide('../sgmgharmonyhonors_files/DSC_7405.jpg', '536', '800', '');
slides[6] = new Slide('../sgmgharmonyhonors_files/DSC_7499.jpg', '536', '800', '');
slides[7] = new Slide('../sgmgharmonyhonors_files/DSC_7439.jpg', '536', '800', '');
slides[8] = new Slide('../sgmgharmonyhonors_files/DSC_7430.jpg', '536', '800', '');
slides[9] = new Slide('../sgmgharmonyhonors_files/DSC_7567.jpg', '536', '800', '');
slides[10] = new Slide('../sgmgharmonyhonors_files/DSC_7587.jpg', '536', '800', '');
slides[11] = new Slide('../sgmgharmonyhonors_files/DSC_7581.jpg', '536', '800', '');
slides[12] = new Slide('../sgmgharmonyhonors_files/DSC_7607.jpg', '536', '800', '');
slides[13] = new Slide('../sgmgharmonyhonors_files/DSC_7765.jpg', '536', '800', '');
slides[14] = new Slide('../sgmgharmonyhonors_files/DSC_7738.jpg', '536', '800', '');
slides[15] = new Slide('../sgmgharmonyhonors_files/DSC_7735.jpg', '536', '800', '');
slides[16] = new Slide('../sgmgharmonyhonors_files/DSC_7542.jpg', '536', '800', '');
slides[17] = new Slide('../sgmgharmonyhonors_files/DSC_7535.jpg', '536', '800', '');
slides[18] = new Slide('../sgmgharmonyhonors_files/DSC_7687.jpg', '536', '800', '');
slides[19] = new Slide('../sgmgharmonyhonors_files/DSC_7372.jpg', '536', '800', '');
slides[20] = new Slide('../sgmgharmonyhonors_files/DSC_7813.jpg', '536', '800', '');
slides[21] = new Slide('../sgmgharmonyhonors_files/DSC_7795.jpg', '536', '800', '');
slides[22] = new Slide('../sgmgharmonyhonors_files/DSC_7786.jpg', '536', '800', '');
slides[23] = new Slide('../sgmgharmonyhonors_files/DSC_7401.jpg', '536', '800', '');
slides[24] = new Slide('../sgmgharmonyhonors_files/DSC_7776.jpg', '536', '800', '');
slides[25] = new Slide('../sgmgharmonyhonors_files/DSC_7727.jpg', '536', '800', '');
slides[26] = new Slide('../sgmgharmonyhonors_files/DSC_7709.jpg', '536', '800', '');
slides[27] = new Slide('../sgmgharmonyhonors_files/DSC_7713.jpg', '536', '800', '');
slides[28] = new Slide('../sgmgharmonyhonors_files/DSC_7640.jpg', '536', '800', '');
slides[29] = new Slide('../sgmgharmonyhonors_files/DSC_7638.jpg', '536', '800', '');
slides[30] = new Slide('../sgmgharmonyhonors_files/DSC_7691.jpg', '536', '800', '');
slides[31] = new Slide('../sgmgharmonyhonors_files/DSC_7721.jpg', '536', '800', '');
slides[32] = new Slide('../sgmgharmonyhonors_files/DSC_7724.jpg', '536', '800', '');
slides[33] = new Slide('../sgmgharmonyhonors_files/DSC_7718.jpg', '536', '800', '');
slides[34] = new Slide('../sgmgharmonyhonors_files/DSC_7815.jpg', '536', '800', '');
slides[35] = new Slide('../sgmgharmonyhonors_files/DSC_7808.jpg', '536', '800', '');
slides[36] = new Slide('../sgmgharmonyhonors_files/DSC_7827.jpg', '536', '800', '');
slides[37] = new Slide('../sgmgharmonyhonors_files/DSC_7909.jpg', '536', '800', '');
slides[38] = new Slide('../sgmgharmonyhonors_files/DSC_7888.jpg', '536', '800', '');
slides[39] = new Slide('../sgmgharmonyhonors_files/DSC_7886.jpg', '536', '800', '');
slides[40] = new Slide('../sgmgharmonyhonors_files/DSC_7878.jpg', '536', '800', '');
slides[41] = new Slide('../sgmgharmonyhonors_files/DSC_7863.jpg', '536', '800', '');
slides[42] = new Slide('../sgmgharmonyhonors_files/DSC_7858.jpg', '536', '800', '');
slides[43] = new Slide('../sgmgharmonyhonors_files/DSC_7851.jpg', '536', '800', '');
slides[44] = new Slide('../sgmgharmonyhonors_files/DSC_7902.jpg', '536', '800', '');
slides[45] = new Slide('../sgmgharmonyhonors_files/DSC_7920.jpg', '536', '800', '');
slides[46] = new Slide('../sgmgharmonyhonors_files/DSC_7929.jpg', '536', '800', '');
slides[47] = new Slide('../sgmgharmonyhonors_files/DSC_7770.jpg', '536', '800', '');
slides[48] = new Slide('../sgmgharmonyhonors_files/DSC_7916.jpg', '536', '800', '');
slides[49] = new Slide('../sgmgharmonyhonors_files/DSC_7935.jpg', '536', '800', '');
slides[50] = new Slide('../sgmgharmonyhonors_files/DSC_7923.jpg', '536', '800', '');
slides[51] = new Slide('../sgmgharmonyhonors_files/DSC_7933.jpg', '536', '800', '');
slides[52] = new Slide('../sgmgharmonyhonors_files/DSC_7774.jpg', '536', '800', '');
slides[53] = new Slide('../sgmgharmonyhonors_files/DSC_7756.jpg', '536', '800', '');
slides[54] = new Slide('../sgmgharmonyhonors_files/DSC_7732.jpg', '536', '800', '');
slides[55] = new Slide('../sgmgharmonyhonors_files/2910_74575606924_504896924_1800514_3687507_n.jpg', '453', '604', '');
slides[56] = new Slide('../sgmgharmonyhonors_files/DSC_7729.jpg', '536', '800', '');
slides[57] = new Slide('../sgmgharmonyhonors_files/DSC_7523.jpg', '536', '800', '');
slides[58] = new Slide('../sgmgharmonyhonors_files/DSC_7633.jpg', '536', '800', '');
slides[59] = new Slide('../sgmgharmonyhonors_files/DSC_7672.jpg', '536', '800', '');
slides[60] = new Slide('../sgmgharmonyhonors_files/DSC_7314.jpg', '536', '800', '');
slides[61] = new Slide('../sgmgharmonyhonors_files/DSC_7302.jpg', '536', '800', '');
slides[62] = new Slide('../sgmgharmonyhonors_files/DSC_7287.jpg', '536', '800', '');
slides[63] = new Slide('../sgmgharmonyhonors_files/DSC_7281.jpg', '536', '800', '');
slides[64] = new Slide('../sgmgharmonyhonors_files/DSC_7278.jpg', '536', '800', '');
slides[65] = new Slide('../sgmgharmonyhonors_files/DSC_7761.jpg', '536', '800', '');
slides[66] = new Slide('../sgmgharmonyhonors_files/DSC_7748.jpg', '536', '800', '');
slides[67] = new Slide('../sgmgharmonyhonors_files/DSC_7659.jpg', '536', '800', '');
slides[68] = new Slide('../sgmgharmonyhonors_files/DSC_7631B.jpg', '549', '800', '');
slides[69] = new Slide('../sgmgharmonyhonors_files/DSC_7628.jpg', '536', '800', '');
slides[70] = new Slide('../sgmgharmonyhonors_files/DSC_7626.jpg', '536', '800', '');
slides[71] = new Slide('../sgmgharmonyhonors_files/DSC_7667.jpg', '536', '800', '');
slides[72] = new Slide('../sgmgharmonyhonors_files/DSC_7700.jpg', '536', '800', '');
slides[73] = new Slide('../sgmgharmonyhonors_files/DSC_7677.jpg', '536', '800', '');
slides[74] = new Slide('../sgmgharmonyhonors_files/DSC_7698.jpg', '536', '800', '');
slides[75] = new Slide('../sgmgharmonyhonors_files/SGMG_PRESHONOR_BarbaraMandrell.jpg', '536', '800', '');
slides[76] = new Slide('../sgmgharmonyhonors_files/DSC_7682.jpg', '536', '800', '');
slides[77] = new Slide('../sgmgharmonyhonors_files/DSC_7665.jpg', '536', '800', '');
slides[78] = new Slide('../sgmgharmonyhonors_files/DSC_7669.jpg', '536', '800', '');
slides[79] = new Slide('../sgmgharmonyhonors_files/DSC_7653.jpg', '536', '800', '');
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", "sgmgharmonyhonors_files/transparent.gif");
    return true;
}

