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('../Handscribed_files/Deer Jumping Fence 1.jpg', '600', '800', 'Deer Jumping Fence 1');
slides[1] = new Slide('../Handscribed_files/Deer Jumping Fence 2.jpg', '800', '600', 'Deer Jumping Fence 2');
slides[2] = new Slide('../Handscribed_files/Deer Jumping Fence 3.jpg', '600', '800', 'Deer Jumping Fence 3');
slides[3] = new Slide('../Handscribed_files/Deer Jumping Fence Butt.jpg', '600', '800', 'Deer Jumping Fence Butt');
slides[4] = new Slide('../Handscribed_files/NA Face 1.jpg', '800', '600', 'NA Face 1');
slides[5] = new Slide('../Handscribed_files/NA Face Good.jpg', '600', '800', 'NA Face Good');
slides[6] = new Slide('../Handscribed_files/Bison Wolves NA knife.jpg', '600', '800', 'Bison Wolves NA knife');
slides[7] = new Slide('../Handscribed_files/NA Face Best.jpg', '600', '800', 'NA Face Best');
slides[8] = new Slide('../Handscribed_files/NA Butt end.jpg', '600', '800', 'NA Butt end');
slides[9] = new Slide('../Handscribed_files/NA Bison close up.jpg', '800', '600', 'NA Bison close up');
slides[10] = new Slide('../Handscribed_files/DS Right Side.jpg', '800', '600', 'DS Right Side');
slides[11] = new Slide('../Handscribed_files/Deer Skn Skull Feather Left Side.jpg', '800', '600', 'Deer Skn Skull Feather Left Side');
slides[12] = new Slide('../Handscribed_files/DS Front Good.jpg', '800', '600', 'DS Front Good');
slides[13] = new Slide('../Handscribed_files/DS Butt end.jpg', '600', '800', 'DS Butt end');
slides[14] = new Slide('../Handscribed_files/Elk knife full view.jpg', '600', '800', 'Elk knife full view');
slides[15] = new Slide('../Handscribed_files/Elk right side.jpg', '600', '800', 'Elk right side');
slides[16] = new Slide('../Handscribed_files/Elk Left side.jpg', '600', '800', 'Elk Left side');
slides[17] = new Slide('../Handscribed_files/Elk Front.jpg', '800', '600', 'Elk Front');
slides[18] = new Slide('../Handscribed_files/Elk Butt.jpg', '600', '800', 'Elk Butt');
slides[19] = new Slide('../Handscribed_files/Feather Mini left side.jpg', '600', '800', 'Feather Mini left side');
slides[20] = new Slide('../Handscribed_files/Feather mini butt.jpg', '600', '800', 'Feather mini butt');
slides[21] = new Slide('../Handscribed_files/Feather mini right side.jpg', '600', '800', 'Feather mini right side');
slides[22] = new Slide('../Handscribed_files/Gut Hook right close up.jpg', '600', '800', 'Gut Hook right close up');
slides[23] = new Slide('../Handscribed_files/Gut Hook butt.jpg', '600', '800', 'Gut Hook butt');
slides[24] = new Slide('../Handscribed_files/gut hook deers nose.jpg', '600', '800', 'gut hook deers nose');
slides[25] = new Slide('../Handscribed_files/gut hook full right.jpg', '600', '800', 'gut hook full right');
slides[26] = new Slide('../Handscribed_files/Deer jumping over fence full good.jpg', '600', '800', 'Deer jumping over fence full good');
slides[27] = new Slide('../Handscribed_files/100_1903.jpg', '600', '800', '100_1903');
slides[28] = new Slide('../Handscribed_files/100_1904.jpg', '600', '800', '100_1904');
slides[29] = new Slide('../Handscribed_files/100_1905.jpg', '600', '800', '100_1905');
slides[30] = new Slide('../Handscribed_files/100_1906.jpg', '600', '800', '100_1906');
slides[31] = new Slide('../Handscribed_files/100_1907.jpg', '600', '800', '100_1907');
slides[32] = new Slide('../Handscribed_files/100_1908.jpg', '600', '800', '100_1908');
slides[33] = new Slide('../Handscribed_files/100_1909.jpg', '600', '800', '100_1909');
slides[34] = new Slide('../Handscribed_files/100_1910.jpg', '600', '800', '100_1910');
slides[35] = new Slide('../Handscribed_files/100_1911.jpg', '800', '600', '100_1911');
slides[36] = new Slide('../Handscribed_files/Mini P trout butt.jpg', '600', '800', 'Mini P trout butt');
slides[37] = new Slide('../Handscribed_files/Mini P trout good.jpg', '600', '800', 'Mini P trout good');
slides[38] = new Slide('../Handscribed_files/100_1917.jpg', '600', '800', '100_1917');
slides[39] = new Slide('../Handscribed_files/NA mini bison side good.jpg', '600', '800', 'NA mini bison side good');
slides[40] = new Slide('../Handscribed_files/NA mini NA side good.jpg', '600', '800', 'NA mini NA side good');
slides[41] = new Slide('../Handscribed_files/NA top so so.jpg', '600', '800', 'NA top so so');
slides[42] = new Slide('../Handscribed_files/NA full side bison.jpg', '600', '800', 'NA full side bison');
slides[43] = new Slide('../Handscribed_files/feathers mini butt.jpg', '600', '800', 'feathers mini butt');
slides[44] = new Slide('../Handscribed_files/feathers mini left good.jpg', '600', '800', 'feathers mini left good');
slides[45] = new Slide('../Handscribed_files/feathers mini side so so.jpg', '600', '800', 'feathers mini side so so');
slides[46] = new Slide('../Handscribed_files/feathers mini top good.jpg', '600', '800', 'feathers mini top good');
slides[47] = new Slide('../Handscribed_files/blk bear full side.jpg', '600', '800', 'blk bear full side');
slides[48] = new Slide('../Handscribed_files/blk bear butt.jpg', '600', '800', 'blk bear butt');
slides[49] = new Slide('../Handscribed_files/blk bear close up.jpg', '600', '800', 'blk bear close up');
slides[50] = new Slide('../Handscribed_files/wolf fur close up.jpg', '600', '800', 'wolf fur close up');
slides[51] = new Slide('../Handscribed_files/wolf close up snout.jpg', '600', '800', 'wolf close up snout');
slides[52] = new Slide('../Handscribed_files/wolf butt end.jpg', '600', '800', 'wolf butt end');
slides[53] = new Slide('../Handscribed_files/wolf face full good.jpg', '600', '800', 'wolf face full good');
slides[54] = new Slide('../Handscribed_files/Brn Trout tail.jpg', '600', '800', 'Brn Trout tail');
slides[55] = new Slide('../Handscribed_files/Brn Trout top.jpg', '600', '800', 'Brn Trout top');
slides[56] = new Slide('../Handscribed_files/Brn Trout face.jpg', '600', '800', 'Brn Trout face');
isPureISOLatin1 = true;
contentEncodingConstant = 4;
feedbackURL = "TODO";
showFeedbackButton = false;
feedbackEnabled = 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;
    }
}

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


