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('../Castle Gallery_files/Andy.jpg', '407', '576', 'Winter League 2011');
slides[1] = new Slide('../Castle Gallery_files/Shooter.jpg', '475', '717', 'Airgun Shooter.');
slides[2] = new Slide('../Castle Gallery_files/Jay.jpg', '390', '576', 'Winter League 2011');
slides[3] = new Slide('../Castle Gallery_files/Carl.jpg', '425', '576', 'Winter League 2011');
slides[4] = new Slide('../Castle Gallery_files/Jim.jpg', '396', '576', 'Winter League 2011');
slides[5] = new Slide('../Castle Gallery_files/Pete.jpg', '576', '371', 'Winter League 2011');
slides[6] = new Slide('../Castle Gallery_files/Colin.jpg', '491', '497', 'Winter League 2011');
slides[7] = new Slide('../Castle Gallery_files/Jono.jpg', '543', '523', 'Winter League 2011');
slides[8] = new Slide('../Castle Gallery_files/Dave-Bull.jpg', '508', '576', 'Winter League 2011');
slides[9] = new Slide('../Castle Gallery_files/Mark.jpg', '525', '573', 'Winter League 2011');
slides[10] = new Slide('../Castle Gallery_files/dave.jpg', '404', '562', 'Winter League 2011');
slides[11] = new Slide('../Castle Gallery_files/pete_1.jpg', '384', '576', 'Growler Pete. ');
slides[12] = new Slide('../Castle Gallery_files/gp20winner.jpg', '576', '411', 'Neil GP Winner 2011.');
slides[13] = new Slide('../Castle Gallery_files/fish2.jpg', '384', '576', 'Mark Fisher.');
slides[14] = new Slide('../Castle Gallery_files/2011FtWorldITALY052copy.jpg', '539', '576', 'Andy @ The Worlds.');
slides[15] = new Slide('../Castle Gallery_files/2011Gp7Redfearns034.jpg', '381', '576', 'Neil @ GP7.');
slides[16] = new Slide('../Castle Gallery_files/JimNee.jpg', '384', '576', 'Jim Nee.');
slides[17] = new Slide('../Castle Gallery_files/martyn-pitt.jpg', '300', '450', 'Martyn Pitt.');
slides[18] = new Slide('../Castle Gallery_files/mark_1.jpg', '384', '576', 'Mark Brewitt.');
slides[19] = new Slide('../Castle Gallery_files/Andy-Gough.jpg', '336', '504', 'Andy Gough.');
slides[20] = new Slide('../Castle Gallery_files/Mark-Fisher.jpg', '336', '504', 'Marc & Dave.');
slides[21] = new Slide('../Castle Gallery_files/Jim-knee.jpg', '432', '288', 'Jim knee.');
slides[22] = new Slide('../Castle Gallery_files/Carl-Meads.jpg', '336', '504', 'Carl Meads.');
slides[23] = new Slide('../Castle Gallery_files/Mark-Wharton.jpg', '336', '504', 'Mark Wharton.');
slides[24] = new Slide('../Castle Gallery_files/Tony-johnson.jpg', '432', '288', 'Tony Johnson.');
slides[25] = new Slide('../Castle Gallery_files/Colin-Jones.jpg', '339', '504', 'Colin Jones.');
slides[26] = new Slide('../Castle Gallery_files/Rob-Bowden.jpg', '504', '336', 'Rob Bowden.');
slides[27] = new Slide('../Castle Gallery_files/Pistol-Pete.jpg', '504', '361', 'Pistol Pete.');
slides[28] = new Slide('../Castle Gallery_files/Dave-Lindley.jpg', '336', '504', 'Dave Lindley.');
slides[29] = new Slide('../Castle Gallery_files/Paul-Flinders.jpg', '321', '504', 'Paul Flinders.');
slides[30] = new Slide('../Castle Gallery_files/Ripper-Ron.jpg', '329', '504', 'Ron With his Zenith .');
slides[31] = new Slide('../Castle Gallery_files/g4EsNX-large-0.jpg', '333', '500', 'Steve page.');
slides[32] = new Slide('../Castle Gallery_files/Marc-Fisher.jpg', '336', '504', 'Marc Fisher.');
slides[33] = new Slide('../Castle Gallery_files/Jeff-Walker.jpg', '504', '401', 'Jeff Walker.');
slides[34] = new Slide('../Castle Gallery_files/on-the-kill.jpg', '336', '504', 'On The Range.');
slides[35] = new Slide('../Castle Gallery_files/John-c.jpg', '350', '504', 'John Callaghan.');
slides[36] = new Slide('../Castle Gallery_files/Steph-Cope.jpg', '336', '504', 'Steph Cope.');
slides[37] = new Slide('../Castle Gallery_files/John.jpg', '504', '336', 'John on target.');
slides[38] = new Slide('../Castle Gallery_files/Ron-fisher.jpg', '504', '361', 'Ron fisher.');
isPureISOLatin1 = true;
contentEncodingConstant = 4;
feedbackURL = "TODO";
showFeedbackButton = false;
feedbackEnabled = 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 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", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id2", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id3", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id4", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id5", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id6", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id7", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id8", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id9", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id10", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id11", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id12", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id13", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id14", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id15", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id16", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id17", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id18", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id19", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id20", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id21", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id22", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id23", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id24", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id25", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id26", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id27", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id28", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id29", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id30", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id31", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id32", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id33", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id34", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id35", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id36", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id37", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id38", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id39", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id40", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id41", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id42", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id43", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id44", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id45", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id46", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id47", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id48", "Castle Gallery_files/transparent.gif");
    fixupIEPNG("id49", "Castle Gallery_files/transparent.gif");
    return true;
}


