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('../rouse_files/manifold4wc.jpg', '261', '720', 'Manifold does it again!');
slides[1] = new Slide('../rouse_files/manifold4race.jpg', '477', '720', 'Back to the winner’s circle for Rouse Racing!');
slides[2] = new Slide('../rouse_files/FourNFoutunerace2.jpg', '432', '720', 'Four N Fortune digs in for the win!');
slides[3] = new Slide('../rouse_files/Manifoldrace.jpg', '432', '720', 'Manifold puts daylight on the the field!');
slides[4] = new Slide('../rouse_files/FourNFoutunewc2.jpg', '432', '720', 'Four N Fortune races for Rouse Racing!');
slides[5] = new Slide('../rouse_files/Manifoldwc.jpg', '432', '720', 'Manifold in the winne’s circle for Rouse Racing.');
slides[6] = new Slide('../rouse_files/magic0109race.jpg', '437', '720', 'Flickas Magic Breeze starts off 2009 with a win!');
slides[7] = new Slide('../rouse_files/fmagicbreezebktowc.jpg', '576', '292', 'FLICKAS MAGIC BREEZE');
slides[8] = new Slide('../rouse_files/magicwc0109.jpg', '421', '648', 'Flickas Magic Breeze in the winner’s circle.');
slides[9] = new Slide('../rouse_files/FlickasMagBrz1113r.jpg', '383', '648', 'Flickas Magic Breeze cruises to a win.');
slides[10] = new Slide('../rouse_files/FlickasMB1113wc.jpg', '566', '792', 'Flickas Magic Breeze in the winner’s circle.');
slides[11] = new Slide('../rouse_files/FourNFortunerace.jpg', '360', '720', 'Four N Fortune wins at Delta');
slides[12] = new Slide('../rouse_files/FourNFortuneWC.jpg', '379', '720', 'Four N Fortune to the winner’s circle\nfor Rouse Racing!');
slides[13] = new Slide('../rouse_files/ShineyTreyBugsRace.jpg', '272', '720', 'Shiney Trey Bugs wins at Delta');
slides[14] = new Slide('../rouse_files/ShineyTreyBugsWC.jpg', '357', '720', 'Shiney Trey Bugs in the Winner’s Circle');
slides[15] = new Slide('../rouse_files/MojitoRPDbtrlsrace.jpg', '406', '792', 'Miss Mojito sets the second fastest time to the G1 Remington Park Derby.');
slides[16] = new Slide('../rouse_files/Mojito3RPDbtrlswc.jpg', '243', '676', 'Miss Mojito won her trial to the G1 Remington Park Derby with ease.');
slides[17] = new Slide('../rouse_files/missmojito2.jpg', '504', '429', 'Miss Mojito');
slides[18] = new Slide('../rouse_files/MsMojito08race.jpg', '296', '720', 'Miss Mojito crosses in front in \nher first race in 2008');
slides[19] = new Slide('../rouse_files/MissMojito08wc.jpg', '409', '720', 'Miss Mojito in the winner’s circle');
slides[20] = new Slide('../rouse_files/Mojitoback.jpg', '504', '279', 'Miss Mojito returns to the winner’s circle');
slides[21] = new Slide('../rouse_files/missmojito1026wire.jpg', '175', '504', 'Miss Mojito dominates \nthe field');
slides[22] = new Slide('../rouse_files/missmojito1026wc.jpg', '383', '504', 'Miss Mojito \nin the winners circle');
slides[23] = new Slide('../rouse_files/flickasmagicbreezewire.jpg', '154', '432', 'Flickas Magic Breeze \nwins by daylight');
slides[24] = new Slide('../rouse_files/flickaswc.jpg', '299', '432', 'Flickas Magic Breeze\nin the winners circle');
slides[25] = new Slide('../rouse_files/Bugs3.jpg', '631', '800', 'Shiney Trey Bugs\nTwo-Year-Old in Training');
slides[26] = new Slide('../rouse_files/Bugsweb.jpg', '737', '792', 'Shiney Trey Bugs');
slides[27] = new Slide('../rouse_files/Bugs2web.jpg', '482', '792', 'Shiney Trey Bugs');
isPureISOLatin1 = true;
contentEncodingConstant = 4;
feedbackURL = "TODO";
showFeedbackButton = false;
feedbackEnabled = 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 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 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)
        {
        }
    }
}

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 onPageLoad()
{
    detectBrowser();
    fixupAllIEPNGBGs();
    fixupIEPNG("id1", "rouse_files/transparent.gif");
    fixupIEPNG("id2", "rouse_files/transparent.gif");
    fixupIEPNG("id3", "rouse_files/transparent.gif");
    fixupIEPNG("id4", "rouse_files/transparent.gif");
    fixupIEPNG("id5", "rouse_files/transparent.gif");
    return true;
}


