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('../Bad_brands_files/1613.jpg', '660', '600', 'Some were just OK.\n\nJ.B. Fralich Fact. 394, 9th (Manheim) PA  1911.\u000d[1613]');
slides[1] = new Slide('../Bad_brands_files/9183.jpg', '457', '661', 'Actually more than one. The price is a clue\nto just how OK they were.\n\n[9183]');
slides[2] = new Slide('../Bad_brands_files/bad9.jpg', '400', '661', 'Some cigars were downright peculiar. \nWould you ask for one of these?\n\nBatchelder Bros., 1876.\n[1609]');
slides[3] = new Slide('../Bad_brands_files/bad11.jpg', '377', '661', 'Better yet...three of them for only a nickle.\n\n[1611]');
slides[4] = new Slide('../Bad_brands_files/1612.jpg', '600', '636', 'Would you buy a rotten one?\nWhat’s in a name? A lot!\n\nFact. 1728, 14th Dist. NY  c1912\u000d[1612]');
slides[5] = new Slide('../Bad_brands_files/1614.jpg', '661', '566', 'This brand looks fine, until you say it out loud.\n“Give me a sorry cigar.”\n\nFred Kolbe, Fact. 997, Lester Prairie, Minn. 1930.\u000d[1614]');
slides[6] = new Slide('../Bad_brands_files/1602.jpg', '557', '661', 'A cigar with no appeal, but it has \nan eye-catching label.\n\nFact. 495, 1st Dist. Ohio  c1913\n[1602]');
slides[7] = new Slide('../Bad_brands_files/bad42.jpg', '800', '762', 'A fraudulent product at the biggest price. \nNow there’s marketing for you.\n\nR.J. Reynolds, 1937.\n[1642]');
slides[8] = new Slide('../Bad_brands_files/1615.jpg', '546', '661', 'Puppies and babies are great, but how would\nyou feel asking for a sucker’s cigar?\n\nOscar Jaehrig, Fact. 274, 1st (San Diego) Calif. \u000d[1615]');
slides[9] = new Slide('../Bad_brands_files/1616.jpg', '551', '661', 'Is a chump better than a sucker?\n\nBarlow, Rogers & Simpson, Fact. 641, 21st NY.\u000d(Binghamton)  c1890.    \n[1616]');
slides[10] = new Slide('../Bad_brands_files/1628.jpg', '636', '600', 'Would you feel any better asking for this one?\u000d“Gimme a misfit’s cigar.”\n\nM. Brilles & Co., Fact. 231, 23rd (Allegheny) PA  c1900.  Possibly a brand of seconds.  \n [1628]');
slides[11] = new Slide('../Bad_brands_files/thirties8595.jpg', '656', '800', 'Is an Old Nut worse than a misfit?\n\nAmerican Cigar Co., Westfield, Mass, c1902\n[8595]');
slides[12] = new Slide('../Bad_brands_files/bad26.jpg', '572', '661', 'Try asking for a Cyco cigar aloud. I comes out\u000dpsycho’s cigar. How’s that for niche marketing?\n\nJ.H. Roberts, Fact. 6 South Dakota, 1927.\n[1626]');
slides[13] = new Slide('../Bad_brands_files/bad36.jpg', '600', '660', 'A cigar for con-men?  Politicians?\n\nE.W. Washburn  Fact. 484, Ist Wisconsin, c1905.\n[1636]');
slides[14] = new Slide('../Bad_brands_files/2618.jpg', '369', '570', '“Gimme a tramp’s cigar” lacks \na sophisticated ring.\n\nUncataloged, c1905.\n[2618]');
slides[15] = new Slide('../Bad_brands_files/2609cu.jpg', '413', '570', 'Is it self-incrimination to ask for a Peeping Tom’s cigar?  The ultimate in niche marketing.\n\nBarnes Smith & Co. Fact. 1239, 21st NY\nBinghamton, c1890.   \n[2609cu]');
slides[16] = new Slide('../Bad_brands_files/12515.jpg', '503', '600', '“Would you like a beer with that?”\n\n[12515]');
slides[17] = new Slide('../Bad_brands_files/bad17.jpg', '434', '661', 'And this appeals to...?\n\nJ.C. Koester  Fact. 718 1st (Lomira) Wisc, 1910.\n[1617]');
slides[18] = new Slide('../Bad_brands_files/bad30.jpg', '661', '445', 'A cigar named after a bug poison. Packed like it too. Would you smoke one, with that slogan.\n\nGeorge Knight Fact. 579, 1st Ill. (Chicago) 1912.\u000dA 12/up can that’s very rare, with good reason.\n[1630]');
slides[19] = new Slide('../Bad_brands_files/bad37.jpg', '523', '661', 'What pleasant make-you-want-to-smoke-one image does this name conjure up? “Made of tobacco.”   As opposed to what?\n\nDaniel Spotts  Fact. 3810, 9th (Red Lion) PA  1917 [1637]');
slides[20] = new Slide('../Bad_brands_files/bad18.jpg', '498', '661', 'Brand looks and sounds too much like “cruddy” to appeal to me. Begs to be called that.\n\nFact 803 (state missing),  1917-1918\n[1618]');
slides[21] = new Slide('../Bad_brands_files/9171.jpg', '600', '653', 'If fads appeal, this is a hit. I can’t see a \nserious smoker asking for “a fad cigar.”\n\nH.A. Lundquist, Fact. 1  Minnesota  1929.\n[9171]');
slides[22] = new Slide('../Bad_brands_files/9508.jpg', '600', '637', 'Fact. 1902, 1st Dist PA  1898\n[9508]');
slides[23] = new Slide('../Bad_brands_files/bad19.jpg', '538', '661', 'A giant rat with a negro baby riding on its tail.\n\nL. & E. Kaufman, Fact. 4, 3rd NYC, c1886\u000dRat tails are long skinny cigars pointed both ends. [1619]');
slides[24] = new Slide('../Bad_brands_files/bad20.jpg', '600', '618', 'Does making them out of velvet make\u000dthem more smokable?\n\nWetzel County Cigar, New Martinsville, West VA. [1620]');
slides[25] = new Slide('../Bad_brands_files/bad34.jpg', '549', '661', 'Illustrate a river, call your cigar PURE GRIT and you have an image of sand in your food or butt crack. I’d rather have tobacco in my cigar.\n\nFact. 331, 1st PA  1941.\n[1634]');
slides[26] = new Slide('../Bad_brands_files/bad31.jpg', '396', '661', 'If you don’t like grit, screen out the big chunks.\u000dWhat siftings do you want your cigar made of?\n\nLewyn & Martin, Fact. 34, 3rd NYC for a Texas retailer. The brand name is stolen from a magazine of the 1880’s.   [1631]');
slides[27] = new Slide('../Bad_brands_files/bad25.jpg', '551', '661', 'The brand conjures images of  licking a lead ingot, or cold grey lead shavings in your cigar.\n\nGeorge Biesmann Fact. 63, 1st (Galena) Illinois.\u000dLocal appeal brand.  1917-1918. \n[1625]');
slides[28] = new Slide('../Bad_brands_files/bad33.jpg', '600', '625', 'Custom brand for a Louisville paint company\u000dperhaps because of the lead in the paint !?\n\nUncatalogued. c1910.\n[1633]');
slides[29] = new Slide('../Bad_brands_files/MVC-055S.jpg', '319', '501', 'Straight to the point says the surgeon general.\n\nNot in the NCM collection. [w0000]');
slides[30] = new Slide('../Bad_brands_files/things36.jpg', '516', '800', 'Images of a cool, refreshing smoke.\n\nJohn G. Spatz, Fact. 12, 1st PA in Reading created and manufactured this less that great idea.\n[2336]');
slides[31] = new Slide('../Bad_brands_files/78womenBj98.jpg', '600', '651', 'Smoke quickly?  The meaning of this is lost,\u000dperhaps a local in-joke, but not appealing.\n\nW.G. Suelke, Fact 1350, 1st PA (Quakertown).\nReminds me of a cheapskate prop girl who worked on Gene Hackman’s bad Western.  Ask.  [7898]');
slides[32] = new Slide('../Bad_brands_files/bad38.jpg', '600', '648', 'Not a red mark on your neck, but a chain of\u000dcigar stores in the 1920’s.\n\nFact. 203 Iowa, 1928.\n[1638]');
slides[33] = new Slide('../Bad_brands_files/bad22.jpg', '661', '567', 'Black sheep are misbehaving outcasts.\u000dJust the image you want for your product.\n\n1917-1918.  Catalog card missing.\n[1622]');
slides[34] = new Slide('../Bad_brands_files/bad35b.jpg', '520', '800', 'ALL WOOL 2 1/2 YARDS WIDE. A wool cigar? Not if you have ever smelled burning wool.\n\nFact. 6 Vermont. Very early 1870’s style label \u000dbut this box was sold in 1896.\n[1635b]');
slides[35] = new Slide('../Bad_brands_files/bad23.jpg', '600', '655', 'Speaking of great smells...\n\nH.Fendrich, Fact. 202, 7th (Evansville) Indiana.\n[1623]');
slides[36] = new Slide('../Bad_brands_files/barnyard5685.jpg', '396', '661', 'Speaking of great smells II...\n\nRuhe Bros. Fact. 956, 1st PA (Allentown) 1900±.\n[5685]');
slides[37] = new Slide('../Bad_brands_files/10008.jpg', '576', '661', 'Smoking a mohair teddy bear is not a smell to look forward to either.\n\nTony Bennauer, Fact. 935, 1st (Mendota) Ill.,c1912\n[10008]');
slides[38] = new Slide('../Bad_brands_files/9102.jpg', '577', '661', 'Burning feathers are no improvement.\nWeirdest name for a cigar I’ve seen yet.\n\nO’brien Bros, Fact. 4 IRD 34, Chatham, Ontario\nCanada,  c1886   \n[9102]');
slides[39] = new Slide('../Bad_brands_files/bad5.jpg', '634', '600', 'Want a spider in your mouth? With most Americans afraid of spiders this seems chancy.\n\nC.N. Hurd  Fact. 35, Somersworth, NH,  c1920.\n[1605]');
slides[40] = new Slide('../Bad_brands_files/92907spider.jpg', '205', '413', 'If you think the brand name is bad, how about\nthe slogan: Smoke a Spider. \n\nNot in the NCM collection. Photo courtesy of Steenburgh Auctions, NH.\n[w92907]');
slides[41] = new Slide('../Bad_brands_files/bad4.jpg', '592', '661', 'How about a spider AND his web?\u000dThat’s a mouthful.\n\nHolzman & Deutschberger  Fact. 315, \u000d3rd NYC.  c1890\n[1604]');
slides[42] = new Slide('../Bad_brands_files/6944.jpg', '353', '570', 'Putting a bee in your mouth can be fatal.\n\nDelaware Cigar Co.  Fact. 1429, 1st (Chester) PA\nc1905  \n[6944]');
slides[43] = new Slide('../Bad_brands_files/pagc101.jpg', '456', '555', 'The same for a hornet.\n\nNot in the NCM collection\n[w101]');
slides[44] = new Slide('../Bad_brands_files/bad6.jpg', '583', '661', 'Whatever you call it.\n\nFact. 3459, 1st PA  c1890.\n[1606]');
slides[45] = new Slide('../Bad_brands_files/9120.jpg', '478', '569', 'It may not kill you, but no fun to suck on.\n\nP. Lorillard, Fact. 17, 2nd VA  c1912\n[9120]');
slides[46] = new Slide('../Bad_brands_files/bad8.jpg', '436', '661', 'Squirmy in your hand; worse in your mouth.\n\nPrivate label of KC, MO, grocery wholesaler. c1920\n[1608]');
slides[47] = new Slide('../Bad_brands_files/blackbat2.jpg', '469', '632', 'Another flying critter you don’t want \nin your mouth.\n\nNot in the NCM collection.\n[w 0000]');
slides[48] = new Slide('../Bad_brands_files/11955.jpg', '388', '600', 'This one’s no better...\n\n[11955]');
slides[49] = new Slide('../Bad_brands_files/themeAj5794.jpg', '343', '569', 'Which end do you put in your mouth?\n\nCatalog card missing.\n[5794]');
slides[50] = new Slide('../Bad_brands_files/bad21.jpg', '661', '576', 'Which end do you put in your mouth?\n\nCatalog card missing.\n[1621]');
slides[51] = new Slide('../Bad_brands_files/bad40.jpg', '466', '661', 'Do you want your cigar mashed or French fried?\n\nW.P. Lozier,  Fact. 387, 1st (Mt. Pleasant) PA.\n1936  [1640]');
slides[52] = new Slide('../Bad_brands_files/11756.jpg', '765', '800', 'M-m good?  This borders on preposterous.\n\nFact. 2099, 1st PA for GH Guppy, Portland, ME 1898.  [11756]');
slides[53] = new Slide('../Bad_brands_files/cubaearlyjpg8664.jpg', '458', '661', 'Scrambled or hard boiled?\n\nG. Fuchs, Fact. 681, 1st PA, Philadelphia 1893\n[8664]');
slides[54] = new Slide('../Bad_brands_files/bad41.jpg', '497', '661', 'An invitation to steal?\nIn reality, a successful European brand.\n\nJose Tinchant y Gonzales\n[1641]');
slides[55] = new Slide('../Bad_brands_files/9722.jpg', '348', '570', 'In This Wheat By and By, one of the great pun brands, features cute locusts. But did it sell?\n\nS.F. Hess, Fact. 369, 21st  Rochester, NY, c1890 \n[9722] Not in the NCM collection. Xerox copy\ncourtesy of Chris Crocoll.');
slides[56] = new Slide('../Bad_brands_files/d64.jpg', '411', '762', 'BFD. A brand with different meaning today, though a recent TV ad campaign is attempting to change the meaning to something less crude.\n[wd64] Not in the NCM collection.');
slides[57] = new Slide('../Bad_brands_files/bad79.jpg', '545', '800', 'Bad brand name, for sure.\nPerhaps the ultimate in bad slogans.\n\n[1679]');
slides[58] = new Slide('../Bad_brands_files/5fce_1.jpg', '369', '264', 'This chewing tobacco company might want to reconsider the layout and placement of “Scrap.”\n[wd64] Not in the NCM collection.');
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 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 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");
    adjustLineHeightIfTooBig("id2");
    adjustFontSizeIfTooBig("id2");
    fixupAllIEPNGBGs();
    fixupIEPNG("id3", "Bad_brands_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;
    }
}


