function runTest() {
    hCarousel = new UI.Carousel("horizontal_carousel")
}
Event.observe(window, "load", runTest);
var links = $("market-sector-icons").getElementsByTagName("a"),
    timeout = null,
    currentIndex = 300,
    effect = null,
    mainEffect = null,
    hidden = true,
    ß;
currentOverlayDiv = 1;
for (var i = 0; i < links.length; i++) {
    links[i].onmouseover = function () {
        if (effect != null) {
            effect.cancel()
        }
        var b = this;
        var c = (currentOverlayDiv == 1) ? 2 : 1,
            a = "tt-background" + currentOverlayDiv;
        if (hidden) {
            $(a).style.backgroundImage = 'url("' + sectortooltips[b.id].background + '")';
            $(a).style.zIndex = currentIndex++;
            Element.addClassName($("horizontal_carousel").parentNode, "hide-buttons");
            $("tt-container").style.display = "block";
            if (mainEffect != null) {
                mainEffect.cancel()
            }
            mainEffect = Effect.Fade("tt-container", {
                duration: 0.4,
                from: 0,
                to: 0.9999
            });
            hidden = false
        } else {
            $("tt-background" + c).style.opacity = 1;
            $("tt-background" + c).style.filter = "alpha(opacity=100)";
            $(a).style.opacity = 0;
            $(a).style.filter = "alpha(opacity=0)";
            $(a).style.backgroundImage = 'url("' + sectortooltips[b.id].background + '")';
            $(a).style.zIndex = currentIndex++;
            effect = Effect.Fade(a, {
                duration: 0.5,
                from: 0.0001,
                to: 0.99999
            })
        }
        currentOverlayDiv = c;
        $("carousel-tooltip").innerHTML = "<b>" + sectortooltips[this.id].name + "</b>" + sectortooltips[this.id].teaser;
        $("tt-container").select(".tt-arrow")[0].style.marginLeft = (Element.positionedOffset(this).left + 24) + "px";
        clearTimeout(timeout)
    };
    links[i].onmouseout = function () {
        timeout = setTimeout(function () {
            Element.removeClassName($("horizontal_carousel").parentNode, "hide-buttons");
            if (mainEffect != null) {
                mainEffect.cancel()
            }
            mainEffect = Effect.Fade("tt-container", {
                duration: 0.4,
                from: 1,
                to: 0.001,
                afterFinish: function () {
                    $("tt-container").style.display = "none"
                }
            });
            hidden = true
        }, 250)
    }
};
