//make sure jquery lib is loaded before this.

//set up external links and hook in the interstital to non-csl sites
//$(document).ready(function () {
//    externalLinks();

//    $('a.interstital').click(function () {
//        $("#interstitialYes").attr("href", $(this).attr("href"));
//        $("#interstitial").dialog({ modal: true, width: 500 });
//        return false;
//    });

//    $(".references").colorTip({ color: 'corifact' });
//});

//set up external links and hook in the interstital to non-csl sites
$(document).ready(function () {
    externalLinks();

    $('a.interstital').click(function () {
        $("#interstitialMessage").html("The site you are accessing is maintained by a third party over whom CSL Behring has no control. CSL Behring does not review, approve, or necessarily endorse viewpoints, inferences, or conclusions stated in or implied by the content of this site. CSL Behring is not responsible for third-party content or the consequences of your use thereof.");
        $("#interstitialYes").attr("href", $(this).attr("href"));
        $("#interstitial").dialog({ modal: true, width: 500 });

        return false;
    });
    $('a.intrastital').click(function () {
        $("#interstitialMessage").html("You are accessing a CSL Behring site containing information about products marketed by the company.");
        $("#interstitialYes").attr("href", $(this).attr("href"));
        $("#interstitial").dialog({ modal: true, width: 500 });
        return false;
    });

    $(".references").colorTip({ color: 'zemaira' });

    $("tr:odd").addClass('alt');
    $("tr:last").addClass('lastrow');


});


//attach the target=_blank to new window links
//attach the interstital class to the non-csl links (.interstital)
//function externalLinks() {
//    if (!document.getElementsByTagName) return;
//    var anchors = document.getElementsByTagName("a");
//    for (var i = 0; i < anchors.length; i++) {
//        var anchor = anchors[i];
//        if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
//            anchor.target = "_blank";
//           if(anchor.getAttribute("onclick") ==  "return OffRamp();")
//               anchor.className = "interstital";
//        }

//    }
//}

function externalLinks() {

    if (!document.getElementsByTagName) return;
    var anchors = document.getElementsByTagName("a");
    for (var i = 0; i < anchors.length; i++) {
        var anchor = anchors[i];
        if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
            anchor.target = "_blank";

            if (anchor.getAttribute("onclick")) {
                var oc = anchor.getAttribute("onclick").toString();
                if (oc.search("OffRamp") > -1)
                    anchor.className = "interstital";
            }
        }

    }

    /* Adding a colortip to any tag with a glossary class: */
    //$(".glossary").colorTip({ color: 'corifact' });

}

function OffRamp()
{
    return false; //handled by interstital
}



function confirmation() {
    return confirm("You are accessing a Web site maintained by a third party over whom CSL Behring has no control.\nCSL Behring is not responsible for, and accepts no liability for, information contained in any third-party Web site.\n\nDo you wish to continue?")
}

//menu and aesthetic fixes
$(document).ready(function () {
    //make the li of the active link hot
    $("#topNav .nav1on").parent().addClass("nav1on");
    $("#leftnav .nav1on").parent().addClass("nav1on");

    //kill the border on the active item
    $("#topNav .nav1on").parent().next("li").css("border-left", "solid 1px #264B9A");



    //top nav menu
    $("#topMenu li.nav1").mouseenter(function (e) {
        $(this).addClass("nav1on");
        $(this).find(".ulNav2").show();

    });
    $("#topMenu li.nav1").mouseleave(function (e) {
        $("#topMenu a.nav1").parent().removeClass("nav1on");
        $(this).find(".ulNav2").hide();
        //worst code ever. don't lose the highlighted top item when child page is active.
        $("#topMenu .nav2on").parent().parent().parent().addClass("nav1on");
    });

    //fake centering the last item
    $("#topMenu li.nav1:last").css("line-height", "38px");



    //remove the border from the last left nav item
    $("#leftnav .ulNav2 a:last").css("border", "none");

    //hide left nav if theres no subpages
    if ($("#leftnav ul.ulNav2").size() == 0)
        $("#leftnav ul").hide();

    //fix the parent element so 2 items arent hot
    if ($(".ulNav2 .nav2on").size() > 0)
        $("a.nav1on").removeClass("nav1on").addClass("nav1");

    //remove subnav3's parent bottom border
    $("#leftnav  ul.ulNav3").parent().children("a").css("border", "none");


    $(".references").colorTip({ color: 'zemaira' });
});



  
