﻿$(document).ready(function() {
    InitializeHeaderNavigation();
    InitializeSearch();
    InitializeLeftNavigation();
    InitializeFooter();
});

function InitializeHeaderNavigation()
{
    //set min-width on dropdowns
    $("#header-navigation ul li div.header_navigation_menu").each(function() {
        var width = $(this).parent().outerWidth();
        $(this).css("min-width", width + "px");              
    });
    
    $("#header-navigation ul li").hover(
        function() {
            $(this).addClass("hover");
         }, 
        function() {
            $(this).removeClass("hover");
         }
    );
    
}

function InitializeSearch()
{
    $(".search_box").focus(function() {
        $(this).val('');
    });

    $(".search_box").blur(function() {
        if ($(this).val() == '') {
            $(this).val('Search')
        };
    });
}

function InitializeLeftNavigation()
{
    //check to see if left navigation is rendered on page
    if($("ul#left-navigation").length > 0)
    {
        $("ul#left-navigation li").hover(
            function() {
                $(this).addClass("hover");
            },
            function() {
                $(this).removeClass("hover");
            }
        );
    }
    else // no left nav, need to add classes to modules
    {
        $("div#left-modules-container").addClass("no_left_nav");
        $("div#left-modules-container div.module:first").addClass("top_module_no_left_nav");
    }    
}

function InitializeFooter()
{
    var minHeight = 0;

    $("ul.brand_category").each(function() {
        if($(this).height() > minHeight) {
            minHeight = $(this).height();
        }
    });

    $("ul.brand_category").each(function() {
        $(this).css("height", minHeight + "px");
    }); 
}

// WARN ON LEAVE CODE
function warn_on_leave(site) {
    var msg = "\nLinks which take you out of Abbott Laboratories worldwide \n" +
             "web site are not under the control of Abbott Laboratories, \n" +
             "and Abbott Laboratories is not responsible for the contents \n" +
             "of any such site or any further links from such site. Abbott \n" +
             "Laboratories is providing these links to you only as a \n" +
             "convenience, and the inclusion of any link does not imply \n" +
             "endorsement of the linked site by Abbott Laboratories.\n\n" +
             "Do you wish to leave this site?";

    if (confirm(msg)) {
        window.open(site);
    }
    else {
        return;
    }
}


$("#btnSurvivalGuide").click(function() {
    var pdfTitle = $(this).attr("title");
    
    Pdf_Dowload_Click(pdfTitle);

});


function Pdf_Dowload_Click(pdfTitle) {
    //GA tracking
    _gaq.push(['_trackEvent', 'PDF', 'Click', ' PDF download for the Survival Guide']);
    //Omniture tracking
    s.tl(this, 'o', ' PDF download for the Survival Guide');

}
