﻿
function newsHover(e, n) {
    if (e.target.nodeName == "A" && $("div#newsBarWrap ul").attr("id") == "tabBar") {
        $("div#newsBarWrap ul li").attr("id", "");
        $(n).parent("li").attr("id", "cur");
        $(".ImgCaptDesc").text($(n).siblings("p").text());
        $(".ImgCaptMain img").attr("src", $(n).attr("rel"));
    };
}

$(document).ready(function() {
    $("#noscript").attr("id", "newsBarWrap");
    $("div#newsBarWrap ul").attr("id", "tabBar").css("margin-top", "-12px").children("li:first").attr("id", "cur");

    var maxHeight = 30;
    $("#tabBar li a").each(function() {
        if (this.offsetHeight > maxHeight) maxHeight = this.offsetHeight;
    });

    var offset = 12;
    // Hack for IE 6 - no surprises there
    if (jQuery.browser.msie && parseFloat(jQuery.browser.version) < 7)
        offset = 0;
    $("#tabBar li a").css("height", (maxHeight - offset) + "px");
    $("#newsBarWrap").css("height", (maxHeight + 12) + "px").css("min-height", (maxHeight + 12) + "px");

    $(".ImgCaptMain").removeClass("hide");
    $(".ImgCaptMain img").attr("src", $("ul#tabBar li:first a").attr("rel"));
    $(".ImgCaptDesc").text($("ul#tabBar li:first p").text());

    $("div#newsBarWrap ul li a").mouseover(function(e) {
        newsHover(e, this);
    });
    $("div#newsBarWrap ul li a").focus(function(e) {
        newsHover(e, this);
    });

    $("div#newsBarWrap").css("position", "relative") /* Fix for IE 7 */;
});


