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('../Stanley_Cup_Highlights_files/IMG_2175.jpg', '600', '800', 'Highlights on Ice');
slides[1] = new Slide('../Stanley_Cup_Highlights_files/IMG_2176.jpg', '600', '800', 'More Highlights');
slides[2] = new Slide('../Stanley_Cup_Highlights_files/IMG_2177.jpg', '600', '800', 'More Highlights');
slides[3] = new Slide('../Stanley_Cup_Highlights_files/IMG_2183.jpg', '600', '800', 'More Highlights');
slides[4] = new Slide('../Stanley_Cup_Highlights_files/IMG_2186.jpg', '600', '800', 'More Highlights');
slides[5] = new Slide('../Stanley_Cup_Highlights_files/IMG_2193.jpg', '600', '800', 'More Highlights');
slides[6] = new Slide('../Stanley_Cup_Highlights_files/IMG_2212.jpg', '600', '800', 'Introduction');
slides[7] = new Slide('../Stanley_Cup_Highlights_files/IMG_2213.jpg', '600', '800', 'Crowd goes crazy');
slides[8] = new Slide('../Stanley_Cup_Highlights_files/IMG_2216.jpg', '600', '800', 'Team gets loose');
slides[9] = new Slide('../Stanley_Cup_Highlights_files/IMG_2218.jpg', '600', '800', 'Introductions');
slides[10] = new Slide('../Stanley_Cup_Highlights_files/IMG_2220.jpg', '600', '800', 'Introductions');
slides[11] = new Slide('../Stanley_Cup_Highlights_files/IMG_2227.jpg', '600', '800', 'National Anthem');
slides[12] = new Slide('../Stanley_Cup_Highlights_files/IMG_2231.jpg', '600', '800', 'Action');
slides[13] = new Slide('../Stanley_Cup_Highlights_files/IMG_2232.jpg', '600', '800', 'More Action');
slides[14] = new Slide('../Stanley_Cup_Highlights_files/IMG_2237.jpg', '600', '800', 'More Action');
slides[15] = new Slide('../Stanley_Cup_Highlights_files/IMG_2238.jpg', '600', '800', 'Face Off');
slides[16] = new Slide('../Stanley_Cup_Highlights_files/IMG_2240.jpg', '600', '800', 'Action');
slides[17] = new Slide('../Stanley_Cup_Highlights_files/IMG_2245.jpg', '600', '800', 'Action');
slides[18] = new Slide('../Stanley_Cup_Highlights_files/IMG_2263.jpg', '600', '800', 'Me celebrating a goal');
slides[19] = new Slide('../Stanley_Cup_Highlights_files/IMG_2265.jpg', '600', '800', 'Tom and Phil');
slides[20] = new Slide('../Stanley_Cup_Highlights_files/IMG_2279.jpg', '600', '800', 'Jumbotron');
slides[21] = new Slide('../Stanley_Cup_Highlights_files/IMG_2281.jpg', '600', '800', 'Action');
slides[22] = new Slide('../Stanley_Cup_Highlights_files/IMG_2282.jpg', '600', '800', 'Action');
slides[23] = new Slide('../Stanley_Cup_Highlights_files/IMG_2283.jpg', '600', '800', 'Action');
slides[24] = new Slide('../Stanley_Cup_Highlights_files/IMG_2284.jpg', '600', '800', 'Action');
slides[25] = new Slide('../Stanley_Cup_Highlights_files/IMG_2285.jpg', '600', '800', 'Posed to be champs!');
slides[26] = new Slide('../Stanley_Cup_Highlights_files/IMG_2287.jpg', '600', '800', 'Champions!');
slides[27] = new Slide('../Stanley_Cup_Highlights_files/IMG_2288.jpg', '600', '800', 'Fireworks');
slides[28] = new Slide('../Stanley_Cup_Highlights_files/IMG_2289.jpg', '600', '800', 'Confetti');
slides[29] = new Slide('../Stanley_Cup_Highlights_files/IMG_2290.jpg', '600', '800', 'Streamers');
slides[30] = new Slide('../Stanley_Cup_Highlights_files/IMG_2297.jpg', '600', '800', 'Group Hug');
slides[31] = new Slide('../Stanley_Cup_Highlights_files/IMG_2303.jpg', '600', '800', 'Still Group Hug');
slides[32] = new Slide('../Stanley_Cup_Highlights_files/IMG_2306.jpg', '600', '800', 'Champion Celebration!');
slides[33] = new Slide('../Stanley_Cup_Highlights_files/IMG_2308.jpg', '600', '800', 'Handshake');
slides[34] = new Slide('../Stanley_Cup_Highlights_files/IMG_2309.jpg', '600', '800', 'Handshake');
slides[35] = new Slide('../Stanley_Cup_Highlights_files/IMG_2310.jpg', '600', '800', 'Handshake');
slides[36] = new Slide('../Stanley_Cup_Highlights_files/IMG_2311.jpg', '600', '800', 'Handshake');
slides[37] = new Slide('../Stanley_Cup_Highlights_files/IMG_2312.jpg', '600', '800', 'Handshake');
slides[38] = new Slide('../Stanley_Cup_Highlights_files/IMG_2313.jpg', '600', '800', 'Handshake');
slides[39] = new Slide('../Stanley_Cup_Highlights_files/IMG_2315.jpg', '600', '800', 'Handshake');
slides[40] = new Slide('../Stanley_Cup_Highlights_files/IMG_2316.jpg', '600', '800', 'Handshake');
slides[41] = new Slide('../Stanley_Cup_Highlights_files/IMG_2317.jpg', '600', '800', 'Handshake');
slides[42] = new Slide('../Stanley_Cup_Highlights_files/IMG_2318.jpg', '600', '800', 'Handshake');
slides[43] = new Slide('../Stanley_Cup_Highlights_files/IMG_2320.jpg', '600', '800', 'Handshake');
slides[44] = new Slide('../Stanley_Cup_Highlights_files/IMG_2322.jpg', '600', '800', 'Handshake');
slides[45] = new Slide('../Stanley_Cup_Highlights_files/IMG_2323.jpg', '600', '800', 'Handshake');
slides[46] = new Slide('../Stanley_Cup_Highlights_files/IMG_2325.jpg', '600', '800', 'Handshake');
slides[47] = new Slide('../Stanley_Cup_Highlights_files/IMG_2331.jpg', '600', '800', 'Handshake');
slides[48] = new Slide('../Stanley_Cup_Highlights_files/IMG_2336.jpg', '600', '800', 'First West Coast Team!');
slides[49] = new Slide('../Stanley_Cup_Highlights_files/IMG_2346.jpg', '600', '800', 'Conn Smythe');
slides[50] = new Slide('../Stanley_Cup_Highlights_files/IMG_2349.jpg', '600', '800', 'Niedermeyer');
slides[51] = new Slide('../Stanley_Cup_Highlights_files/IMG_2352.jpg', '600', '800', 'Trophy Time!');
slides[52] = new Slide('../Stanley_Cup_Highlights_files/IMG_2355.jpg', '600', '800', 'Sharing the moment');
slides[53] = new Slide('../Stanley_Cup_Highlights_files/IMG_2357.jpg', '600', '800', 'Sharing the moment');
slides[54] = new Slide('../Stanley_Cup_Highlights_files/IMG_2364.jpg', '600', '800', 'The CUP!');
slides[55] = new Slide('../Stanley_Cup_Highlights_files/IMG_2365.jpg', '600', '800', 'Awe of the Cup!');
slides[56] = new Slide('../Stanley_Cup_Highlights_files/IMG_2367.jpg', '600', '800', 'It’s real!');
slides[57] = new Slide('../Stanley_Cup_Highlights_files/IMG_2370.jpg', '600', '800', 'Presentation');
slides[58] = new Slide('../Stanley_Cup_Highlights_files/IMG_2371.jpg', '600', '800', 'Celebration');
slides[59] = new Slide('../Stanley_Cup_Highlights_files/IMG_2372.jpg', '600', '800', 'Lord Stanley’s Cup');
slides[60] = new Slide('../Stanley_Cup_Highlights_files/IMG_2377.jpg', '600', '800', 'Lord Stanley’s Cup');
slides[61] = new Slide('../Stanley_Cup_Highlights_files/IMG_2467.jpg', '600', '800', 'Lord Stanley’s Cup');
slides[62] = new Slide('../Stanley_Cup_Highlights_files/IMG_2473.jpg', '600', '800', 'Lord Stanley’s Cup');
slides[63] = new Slide('../Stanley_Cup_Highlights_files/IMG_2474.jpg', '600', '800', 'Lord Stanley’s Cup');
slides[64] = new Slide('../Stanley_Cup_Highlights_files/IMG_2475.jpg', '600', '800', 'Lord Stanley’s Cup');
slides[65] = new Slide('../Stanley_Cup_Highlights_files/IMG_2477.jpg', '600', '800', 'Lord Stanley’s Cup');
slides[66] = new Slide('../Stanley_Cup_Highlights_files/IMG_2478.jpg', '600', '800', 'Lord Stanley’s Cup');
slides[67] = new Slide('../Stanley_Cup_Highlights_files/IMG_2481.jpg', '600', '800', 'Lord Stanley’s Cup');
slides[68] = new Slide('../Stanley_Cup_Highlights_files/IMG_2483.jpg', '600', '800', 'Lord Stanley’s Cup');
slides[69] = new Slide('../Stanley_Cup_Highlights_files/IMG_2494.jpg', '600', '800', 'Rob and Phil');
slides[70] = new Slide('../Stanley_Cup_Highlights_files/IMG_2520.jpg', '600', '800', 'Giggy!');
slides[71] = new Slide('../Stanley_Cup_Highlights_files/IMG_2536.jpg', '600', '800', 'Selanne Interview');
slides[72] = new Slide('../Stanley_Cup_Highlights_files/IMG_2539.jpg', '600', '800', 'Selanne Interview');
slides[73] = new Slide('../Stanley_Cup_Highlights_files/IMG_2542.jpg', '600', '800', 'Teemu and his wife');
slides[74] = new Slide('../Stanley_Cup_Highlights_files/IMG_2543.jpg', '600', '800', 'Teemu and his Dad');
slides[75] = new Slide('../Stanley_Cup_Highlights_files/IMG_2544.jpg', '600', '800', 'Teemu and his Dad');
slides[76] = new Slide('../Stanley_Cup_Highlights_files/IMG_2545.jpg', '600', '800', 'Teemu and his wife');
slides[77] = new Slide('../Stanley_Cup_Highlights_files/IMG_2551.jpg', '600', '800', 'CHAMPS!');
slides[78] = new Slide('../Stanley_Cup_Highlights_files/IMG_2566.jpg', '600', '800', '2007 Champions');
slides[79] = new Slide('../Stanley_Cup_Highlights_files/IMG_2583.jpg', '600', '800', 'Press');
slides[80] = new Slide('../Stanley_Cup_Highlights_files/IMG_2592.jpg', '600', '800', 'Mess');
slides[81] = new Slide('../Stanley_Cup_Highlights_files/IMG_2593.jpg', '600', '800', 'Press');
slides[82] = new Slide('../Stanley_Cup_Highlights_files/IMG_2595.jpg', '600', '800', 'Mess');
slides[83] = new Slide('../Stanley_Cup_Highlights_files/IMG_2640.jpg', '600', '800', 'Signage');
slides[84] = new Slide('../Stanley_Cup_Highlights_files/DSC00839.jpg', '600', '800', 'Phil’s Camera shots');
slides[85] = new Slide('../Stanley_Cup_Highlights_files/DSC00845.jpg', '600', '800', 'Phil’s Camera shots');
slides[86] = new Slide('../Stanley_Cup_Highlights_files/DSC00846.jpg', '600', '800', 'Phil’s Camera shots');
slides[87] = new Slide('../Stanley_Cup_Highlights_files/DSC00848.jpg', '600', '800', 'Phil’s Camera shots');
slides[88] = new Slide('../Stanley_Cup_Highlights_files/DSC00860.jpg', '600', '800', 'Phil’s Camera shots');
isPureISOLatin1 = true;
contentEncodingConstant = 4;
feedbackURL = "TODO";
showFeedbackButton = false;
feedbackEnabled = true;

function adjustStrokeHeight(idOfElement, leftDelta, rightDelta, bottomDelta)
{
    var oTextBoxOuterDiv = document.getElementById(idOfElement);

    if (oTextBoxOuterDiv)
    {
        var offsetHeight = oTextBoxOuterDiv.offsetHeight;

        var leftImage = getChildOfType(oTextBoxOuterDiv, "IMG", 0);
        if (leftImage)
        {
            leftImage.style.height = (offsetHeight - leftDelta) + "px";
        }
        var rightImage = getChildOfType(oTextBoxOuterDiv, "IMG", 1);
        if (rightImage)
        {
            rightImage.style.height = (offsetHeight - rightDelta) + "px";
        }
        var bottomImage = getChildOfType(oTextBoxOuterDiv, "IMG", 3);
        if (bottomImage)
        {
            bottomImage.style.top = (offsetHeight - bottomDelta) + "px";
        }
    }
}

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);
        }
    }
}

function fixupIEPNGBG(oBlock) 
{
    if (oBlock)
    {
        var currentBGImage = oBlock.currentStyle.backgroundImage;
        var currentBGRepeat = oBlock.currentStyle.backgroundRepeat;
        var urlStart = currentBGImage.indexOf('url(');
        var urlEnd = currentBGImage.indexOf(')', urlStart);
        var imageURL = currentBGImage.substring(urlStart + 4, urlEnd);

        if (imageURL.charAt(0) == '"')
        {
            imageURL = imageURL.substring(1);
        }
        
        if (imageURL.charAt(imageURL.length - 1) == '"')
        {
            imageURL = imageURL.substring(0, imageURL.length - 1);
        }

        var overrideRepeat = false;

        var filterStyle =
            "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" +
            imageURL +
            "', sizingMethod='crop');";

        if (RegExp("/C[0-9A-F]{8}.png$").exec(imageURL) != null)
        {
            filterStyle =
                "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" +
                imageURL +
                "', sizingMethod='scale');";

            overrideRepeat = true;
        }

        var backgroundImage = new Image();
        backgroundImage.src = imageURL;
        var tileWidth = backgroundImage.width;
        var tileHeight = backgroundImage.height; 
        
        var blockWidth = 0;
        var blockHeight = 0;
        if (oBlock.style.width)
        {
            blockWidth = parseInt(oBlock.style.width);
        }
        else
        {
            blockWidth = oBlock.offsetWidth;
        }
        if (oBlock.style.height)
        {
            blockHeight = parseInt(oBlock.style.height);
        }
        else
        {
            blockHeight = oBlock.offsetHeight;
        }

        if ((blockWidth == 0) || (blockHeight == 0))
        {
            return;
        }
        
        var wholeRows = 1;
        var wholeCols = 1;
        var extraHeight = 0;
        var extraWidth = 0;
        
        if ((currentBGRepeat.indexOf("no-repeat") != -1) ||
              ((tileWidth == 0) && (tileHeight == 0)) ||
              overrideRepeat)
        {
            tileWidth = blockWidth;
            tileHeight = blockHeight;

        }
        else if ((currentBGRepeat.indexOf("repeat-x") != -1) ||
              (tileHeight == 0))
        {
            wholeCols = Math.floor(blockWidth / tileWidth);
            extraWidth = blockWidth - (tileWidth * wholeCols);
            tileHeight = blockHeight;

        }
        else if (currentBGRepeat.indexOf("repeat-y") != -1)
        {
            wholeRows = Math.floor(blockHeight / tileHeight);
            extraHeight = blockHeight - (tileHeight * wholeRows);
            tileWidth = blockWidth;

        }
        else
        {
            wholeCols = Math.floor(blockWidth / tileWidth);
            wholeRows = Math.floor(blockHeight / tileHeight);
            extraWidth = blockWidth - (tileWidth * wholeCols);
            extraHeight = blockHeight - (tileHeight * wholeRows);
        }
        
        var wrappedContent = document.createElement("div");
        wrappedContent.style.position = "relative";
        wrappedContent.style.zIndex = "1";
        wrappedContent.style.left = "0px";
        wrappedContent.style.top = "0px";
        if (!isNaN(parseInt(oBlock.style.width)))
        {
            wrappedContent.style.width = "" + blockWidth + "px";
        }
        if (!isNaN(parseInt(oBlock.style.height)))
        {
            wrappedContent.style.height = "" + blockHeight + "px";
        }
        var pngBGFixIsWrappedContentEmpty = true;
        while (oBlock.hasChildNodes())
        {
            if (oBlock.firstChild.nodeType == 3)
            {
                if (RegExp("^ *$").exec(oBlock.firstChild.data) == null)
                {
                    pngBGFixIsWrappedContentEmpty = false;
                }
            }
            else
            {
                pngBGFixIsWrappedContentEmpty = false;
            }
            wrappedContent.appendChild(oBlock.firstChild);
        }
        if (pngBGFixIsWrappedContentEmpty)
        {
            wrappedContent.style.lineHeight = "0px";
        }
        
        var newMarkup = "";
        for (var currentRow = 0; 
             currentRow < wholeRows; 
             currentRow++)
        {
            for (currentCol = 0; 
                 currentCol < wholeCols; 
                 currentCol++)
            {
                newMarkup += "<div style=" +
                        "\"position: absolute; line-height: 0px; " +
                        "width: " + tileWidth + "px; " +
                        "height: " + tileHeight + "px; " +
                        "left:" + currentCol *  tileWidth + "px; " +
                        "top:" + currentRow *  tileHeight + "px; " +
                        "filter:" + filterStyle + 
                        "\" > </div>";
            }
            
            if (extraWidth != 0)
            {
                newMarkup += "<div style=" +
                        "\"position: absolute; line-height: 0px; " +
                        "width: " + extraWidth + "px; " +
                        "height: " + tileHeight + "px; " +
                        "left:" + currentCol *  tileWidth + "px; " +
                        "top:" + currentRow *  tileHeight + "px; " +
                        "filter:" + filterStyle + 
                        "\" > </div>";
            }
        }
        
        if (extraHeight != 0)
        {
            for (currentCol = 0; 
                 currentCol < wholeCols; 
                 currentCol++)
            {
                newMarkup += "<div style=" +
                        "\"position: absolute; line-height: 0px; " +
                        "width: " + tileWidth + "px; " +
                        "height: " + extraHeight + "px; " +
                        "left:" + currentCol *  tileWidth + "px; " +
                        "top:" + currentRow *  tileHeight + "px; " +
                        "filter:" + filterStyle + 
                        "\" > </div>";
            }
            
            if (extraWidth != 0)
            {
                newMarkup += "<div style=" +
                        "\"position: absolute; line-height: 0px; " +
                        "width: " + extraWidth + "px; " +
                        "height: " + extraHeight + "px; " +
                        "left:" + currentCol *  tileWidth + "px; " +
                        "top:" + currentRow *  tileHeight + "px; " +
                        "filter:" + filterStyle + 
                        "\" > </div>";
            }
        }
        oBlock.innerHTML = newMarkup;

        oBlock.appendChild(wrappedContent);
        oBlock.style.background= "";
    }
}

function fixupAllIEPNGBGs()
{
    if (windowsInternetExplorer && (browserVersion < 7))
    {
        try
        {
            var oDivNodes = document.getElementsByTagName('DIV');
            for (var iIndex=0; iIndex<oDivNodes.length; iIndex++)
            {
                var oNode = oDivNodes.item(iIndex);
                if (oNode.currentStyle &&
                    oNode.currentStyle.backgroundImage &&
                    (oNode.currentStyle.backgroundImage.indexOf('url(') != -1) &&
                    (oNode.currentStyle.backgroundImage.indexOf('.png")') != -1))
                {
                    fixupIEPNGBG(oNode);
                }
            }
        }
        catch (e)
        {
        }
    }
}

function getChildOfType(oParent, sNodeName, requestedIndex)
{
    var childrenOfType = oParent.getElementsByTagName(sNodeName);
    return (requestedIndex < childrenOfType.length) ?
           childrenOfType.item(requestedIndex) : null;
}

function onPageLoad()
{
    detectBrowser();
    fixupIEPNG("id1", "Stanley_Cup_Highlights_files/transparent.gif");
    fixupIEPNG("id2", "Stanley_Cup_Highlights_files/transparent.gif");
    fixupIEPNG("id3", "Stanley_Cup_Highlights_files/transparent.gif");
    fixupIEPNG("id4", "Stanley_Cup_Highlights_files/transparent.gif");
    fixupAllIEPNGBGs();
    fixupIEPNG("id5", "Stanley_Cup_Highlights_files/transparent.gif");
    fixupIEPNG("id6", "Stanley_Cup_Highlights_files/transparent.gif");
    fixupIEPNG("id7", "Stanley_Cup_Highlights_files/transparent.gif");
    fixupIEPNG("id8", "Stanley_Cup_Highlights_files/transparent.gif");
    adjustStrokeHeight("id9", 6, 6, 4);
    fixupIEPNG("id10", "Stanley_Cup_Highlights_files/transparent.gif");
    fixupIEPNG("id11", "Stanley_Cup_Highlights_files/transparent.gif");
    fixupIEPNG("id12", "Stanley_Cup_Highlights_files/transparent.gif");
    fixupIEPNG("id13", "Stanley_Cup_Highlights_files/transparent.gif");
    fixupIEPNG("id14", "Stanley_Cup_Highlights_files/transparent.gif");
    return true;
}

function NBmouseover(index)
{
    var normal = document.getElementById("navbar_"+index+"_normal");
    var rollover = document.getElementById("navbar_"+index+"_rollover");
    if (normal && rollover)
    {
        normal.style.visibility = "hidden";
        rollover.style.visibility = "visible";
    }
    return true;
}

function NBmouseout(index)
{
    var normal = document.getElementById("navbar_"+index+"_normal");
    var rollover = document.getElementById("navbar_"+index+"_rollover");
    if (normal && rollover)
    {
        normal.style.visibility = "visible";
        rollover.style.visibility = "hidden";
    }
    return true;
}

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 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;
    }
}


