$(document).ready(function () {

    $.each($(".innerMenuContainer"), function () {
        $(this).animate({ "opacity": "0" }, 1);
    });

    $(".linkContainer").click(function () {

        var subMenuId = $(this).next('div').attr('id');

        $.each($(".innerMenuContainer"), function () {
            if ($(this).attr('id') != subMenuId && $(this).css('display') != 'none') {
                HideInnerMenuContainer($(this));
            }
        });

        ShowInnerMenuContainer($(this).next('div'));
    });

    $("#lnkSendToFirend").click(function () {
        $("#spnDirectLink").css("display", "none");
        var control = $("#spnSendToFirend");
        ChangeControlVisible(control);
    });

    $("#lnkDirectLink").click(function () {
        $("#spnSendToFirend").css("display", "none");
        var control = $("#spnDirectLink");
        ChangeControlVisible(control);
    });

    if ($("#scroll_news_block") != null) {

        $().newsTicker({
            newsList: "#scroll_news_block",
            startDelay: 40,
            loopDelay: 2000,
            placeHolder1: " |",
            stopOnHover: false
        });
    }

    $.featureList(
		  $("#tabs li a"),
		  $("#news_output li"), {
		      start_item: 1
		  }
    );


    var obj = $("#random_output_block > .news_body");
    obj.html(obj.text());

});

function HideInnerMenuContainer(control) {
    control.animate({ "opacity": "0", "height": "0" }, 500, null, function () {
        $(this).css("height", "0");
        $(this).css("display", "none");
    });
}

function ShowInnerMenuContainer(control) {
    if (control.attr('id') != 'noneAction') {
        control.css("height", "auto");
        control.css("display", "block");
        control.animate({ "opacity": "1" }, 1000);
    }
}

function ChangeControlVisible(control) {
    var cv = control.css("display");

    if (cv == "none") {
        control.css("display", "inline");
    } else {
        control.css("display", "none");
    }

}

function PrintArticle() {
    var gAutoPrint = true; // Tells whether to automatically call the print function

    if (document.getElementById != null) {
        var html = '<HTML>\n<HEAD>\n';

        if (document.getElementsByTagName != null) {
            var headTags = document.getElementsByTagName("head");
            if (headTags.length > 0)
                html += headTags[0].innerHTML;
        }

        html += '\n</HE>\n<BODY>\n';

        var printReadyElem = document.getElementById(printAreaElemntName);

        if (printReadyElem != null) {
            html += printReadyElem.innerHTML;
        }
        else {
            alert("Could not find the printReady function");
            return;
        }

        html += '\n</BO>\n</HT>';

        var printWin = window.open("", "printSpecial");
        printWin.document.open();
        printWin.document.write(html);
        printWin.document.close();
        if (gAutoPrint)
            printWin.print();
    }
    else {
        alert("The print ready feature is only available if you are using an browser. Please update your browswer.");
    }
}
