// Common script for ABCB
var $j = jQuery.noConflict();
$j(function () {
    //init tooltips
    $j(".tooltipA[title]").tooltip();

    var maxHeight = 0;
    $j('#footer div.column ul').each(function () { // Make all footer columns the same height
        maxHeight = Math.max(maxHeight, $j(this).outerHeight());
    }).height(maxHeight);

    $j('.ShowHide').click(function () {
        if ($j(this).html() == "Show description") {
            $j(this).hide();
            $j(this).siblings(".longDescription").show();
        }
        else {
            $j(this).html("Show description");
            $j(this).siblings(".longDescription").hide();
        }
    });

    $j('.ShowHideAnswer').click(function () {
        if ($j(this).html() == "Show all answers") {
            $j(this).html("Hide all answers");
            $j(".answer").show();
        }
        else {
            $j(this).html("Show all answers");
            $j(".answer").hide();
        }
    });

    $j('.ShowAnswer').click(function () {
        $j(this).parent().parent().find(".answer").toggle();
    });

    $j('.ShowHideAll').click(function () {
        if ($j(this).html() == "Show all descriptions") {
            $j(this).html("Hide all descriptions");
            $j(".ShowHide").hide();
            $j(".longDescription").show();
        }
        else {
            $j(this).html("Show all descriptions");
            $j(".ShowHide").show();
            $j(".ShowHide").html("Show description");
            $j(".longDescription").hide();
        }
    });

    var h1Text = "";
    $j('.tabs ul li a').click(function () {
        if ($j(this).attr("class") == "currentTab") {
            if (h1Text != "")
            { $j("h1.restricted").html(h1Text); }

            $j(".archivedDiv").hide();
            $j(".currentDiv").show();
        }
        else {
            if (h1Text == "")
            { h1Text = $j("h1.restricted").html(); }

            $j("h1.restricted").html(h1Text + " (Archived)");

            $j(".archivedDiv").show();
            $j(".currentDiv").hide();
        }
        $j(".tabs ul li").removeClass("selected");
        $j(this).parent().addClass("selected");
    });

//    //replace rel="_blank" with target="_blank" for W3C compliance
//    $j(document).ready(function () {
        $j('A[rel="_blank"]').each(function () {
            $j(this).attr('target', '_blank');
        });
//    });
});

