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('../Halifax_files/n502230410_931637_3225.jpg', '453', '604', 'Divas vs. Dykes\nNikki Taylore at bat');
slides[1] = new Slide('../Halifax_files/n502230410_931632_1935.jpg', '604', '453', 'Do you see me??');
slides[2] = new Slide('../Halifax_files/n502230410_931627_741.jpg', '604', '453', 'There I am!  Don’t drink the “water”!');
slides[3] = new Slide('../Halifax_files/n502230410_931601_324.jpg', '453', '604', 'Dykes won this game...');
slides[4] = new Slide('../Halifax_files/n502230410_931587_6368.jpg', '453', '604', 'Aren’t we pretty?');
slides[5] = new Slide('../Halifax_files/n502230410_931630_1458.jpg', '604', '453', 'Ms. Boom Boom!');
slides[6] = new Slide('../Halifax_files/n502230410_931573_2971.jpg', '453', '604', 'Ms. Shelby!');
slides[7] = new Slide('../Halifax_files/n502230410_931574_3277.jpg', '453', '604', 'I forget this queen’s name but she had game!');
slides[8] = new Slide('../Halifax_files/n502230410_931571_2671.jpg', '604', '453', 'Ms. Gay Halifax vs. Dyke');
slides[9] = new Slide('../Halifax_files/F1000021.jpg', '536', '800', 'View from Citadel looking down onto the downtown');
slides[10] = new Slide('../Halifax_files/F1000022.jpg', '800', '536', 'Looking up to clock house and citadel behind');
slides[11] = new Slide('../Halifax_files/F1000023.jpg', '800', '536', 'Beautiful streets');
slides[12] = new Slide('../Halifax_files/F1000024.jpg', '536', '800', 'The heart of Halifax');
slides[13] = new Slide('../Halifax_files/F1000025.jpg', '800', '536', 'Sheldon Duke (aka Ms Shelby), my little hostess!');
slides[14] = new Slide('../Halifax_files/F1000026.jpg', '536', '800', 'What’s Halifax without the sea?');
slides[15] = new Slide('../Halifax_files/F1000027.jpg', '536', '800', 'More sea');
slides[16] = new Slide('../Halifax_files/F1000020.jpg', '536', '800', 'More photos on top of citadel');
slides[17] = new Slide('../Halifax_files/F1000018.jpg', '536', '800', 'My very good friend Rob!');
slides[18] = new Slide('../Halifax_files/F1000017.jpg', '800', '536', 'New friend, Chad');
slides[19] = new Slide('../Halifax_files/F1000016.jpg', '536', '800', 'JP and Ryan (aka Moen and Natasha N)');
slides[20] = new Slide('../Halifax_files/F1000014.jpg', '536', '800', 'Halifax Pride Parade');
slides[21] = new Slide('../Halifax_files/F1000013.jpg', '536', '800', 'Halifax Pride');
slides[22] = new Slide('../Halifax_files/F1000012.jpg', '800', '536', 'Blue Moon Float');
slides[23] = new Slide('../Halifax_files/F1000011.jpg', '800', '536', 'Nikki & Clarence on Blue Moon Float');
slides[24] = new Slide('../Halifax_files/F1000003.jpg', '536', '800', 'Sheldon, Cousin Cletus, and JP');
slides[25] = new Slide('../Halifax_files/n509214157_88443_714.jpg', '452', '604', 'Tyffanie & Rouge Fatale');
slides[26] = new Slide('../Halifax_files/F1000001.jpg', '794', '800', 'Ms. Vicki & Moi!');
slides[27] = new Slide('../Halifax_files/F1000002.jpg', '800', '464', 'Isn’t she just so fun?!?!');
slides[28] = new Slide('../Halifax_files/F1000004.jpg', '800', '536', 'Ms. Shelby & Jen-u-Flect');
slides[29] = new Slide('../Halifax_files/n692430695_867247_7461.jpg', '604', '450', 'Ms. Cerina Romanoff-Blake');
slides[30] = new Slide('../Halifax_files/n692430695_867249_7949.jpg', '604', '450', 'Ms. Cerina Romanoff-Blake');
slides[31] = new Slide('../Halifax_files/n692430695_867256_9705.jpg', '604', '450', 'Damn bitch!');
slides[32] = new Slide('../Halifax_files/F1000006.jpg', '538', '800', 'Ms. Gay Halifax Elle, ME, & Empress VII Natasha N');
slides[33] = new Slide('../Halifax_files/F1000007.jpg', '800', '688', 'Myself & Ms. Gay PEI');
slides[34] = new Slide('../Halifax_files/F1000005.jpg', '536', '800', 'Part of the Blue Moon Crew!');
slides[35] = new Slide('../Halifax_files/n692430695_863999_5133.jpg', '604', '450', 'Last night in Halifax');
slides[36] = new Slide('../Halifax_files/n692430695_864000_5384.jpg', '604', '450', 'See what he has on his neck??');
slides[37] = new Slide('../Halifax_files/n692430695_864057_4713.jpg', '604', '450', 'Clarence (aka Mr. Blue Moon) & moi');
slides[38] = new Slide('../Halifax_files/n692430695_864003_6071.jpg', '604', '450', 'This is what poppers & alcohol will do to ya!');
slides[39] = new Slide('../Halifax_files/n692430695_864002_5847.jpg', '604', '450', 'Oh god...');
slides[40] = new Slide('../Halifax_files/n692430695_867233_4098.jpg', '604', '450', 'Angelic?  Hardly!');
slides[41] = new Slide('../Halifax_files/n692430695_867239_5416.jpg', '604', '450', 'Ms. Shelby & I doing a number');
slides[42] = new Slide('../Halifax_files/n692430695_867235_4581.jpg', '604', '450', 'Good photo');
slides[43] = new Slide('../Halifax_files/n692430695_867265_2092.jpg', '453', '604', 'Group shot!!!!');
slides[44] = new Slide('../Halifax_files/n692430695_867269_3147.jpg', '604', '450', 'Natasha N & Cousin Cletus giving me my title');
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", "Halifax_files/transparent.gif");
    return true;
}


