/*=============================================================================================
--       SITE/SYSTEM : Brand Platform v2
--       DESCRIPTION : Global JavaScript File
--  REVISION HISTORY : Date      Version   Name             Description
--                     09/27/05  1.0.0.0   Joe Gallagher    Initial version
		       11/04/08	 1.1.0.0   Richard Yale	    Added Doctor Discussion Guide code
=============================================================================================*/

$(document).ready(createTrailObj);
$(document).ready(activateList);
/*===================================
-- Begin image rollover functions
====================================*/
//Preload specified images on the page
function MM_preloadImages() { //v3.0
    var d = document; if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++)
            if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; }
    }
}
//Restore the specified image to its original state
function MM_swapImgRestore() { //v3.0
    var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}
//Find image objects with specified IDs
function MM_findObj(n, d) { //v4.01
    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n); return x;
}
//Swap oringal image with specifed image
function MM_swapImage() { //v3.0
    var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
        if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
}
/*===================================
-- End image rollover functions
====================================*/

/*===================================
-- Begin text sizing functions
====================================*/
//Resets all the text-size images and sets the correct font
function styleSizer(whichStyle) {
    //reset all the images
    MM_swapImage('smallTextButton', '', '/images/text_small.gif', 1);
    MM_swapImage('mediumTextButton', '', '/images/text_medium.gif', 1);
    MM_swapImage('largeTextButton', '', '/images/text_large.gif', 1);
    //then set the correct font
    if (whichStyle == "smallFont") {
        setActiveStyleSheet('regularFont');
        MM_swapImage('smallTextButton', '', '/images/text_small_selected.gif', 1);
    } else if (whichStyle == "mediumFont") {
        setActiveStyleSheet('largerFont');
        MM_swapImage('mediumTextButton', '', '/images/text_medium_selected.gif', 1);
    } else if (whichStyle == "largeFont") {
        setActiveStyleSheet('largestFont');
        MM_swapImage('largeTextButton', '', '/images/text_large_selected.gif', 1);
    }
}
//writeImages writes out what image should be live on page load
function writeImages() {
    var cookie = readCookie("style");
    var title = cookie ? cookie : getPreferredStyleSheet();
    //regularFont, largerFont, largestFont
    if (title == null || title == 'regularFont') {
        return ('<a href="#" onClick="javascript:styleSizer(\'smallFont\');"><img src="/images/text_small_selected.gif" alt="Small text" name="smallTextButton" /></a><a href="#" onClick="javascript:styleSizer(\'mediumFont\');"><img src="/images/text_medium.gif" alt="Medium text" name="mediumTextButton" /></a><a href="#" onClick="javascript:styleSizer(\'largeFont\');"><img src="/images/text_large.gif" alt="Large text" name="largeTextButton" /></a>');
    } else if (title == 'largerFont') {
        return ('<a href="#" onClick="javascript:styleSizer(\'smallFont\');"><img src="/images/text_small.gif" alt="Small text" name="smallTextButton" /></a><a href="#" onClick="javascript:styleSizer(\'mediumFont\');"><img src="/images/text_medium_selected.gif" alt="Medium text" name="mediumTextButton" /></a><a href="#" onClick="javascript:styleSizer(\'largeFont\');"><img src="/images/text_large.gif" alt="Large text" name="largeTextButton" /></a>');
    } else if (title == 'largestFont') {
        return ('<a href="#" onClick="javascript:styleSizer(\'smallFont\');"><img src="/images/text_small.gif" alt="Small text" name="smallTextButton" /></a><a href="#" onClick="javascript:styleSizer(\'mediumFont\');"><img src="/images/text_medium.gif" alt="Medium text" name="mediumTextButton" /></a><a href="#" onClick="javascript:styleSizer(\'largeFont\');"><img src="/images/text_large_selected.gif" alt="Large text" name="largeTextButton" /></a>');
    } else {
        return ('<a href="#" onClick="javascript:styleSizer(\'smallFont\');"><img src="/images/text_small_selected.gif" alt="Small text" name="smallTextButton" /></a><a href="#" onClick="javascript:styleSizer(\'mediumFont\');"><img src="/images/text_medium.gif" alt="Medium text" name="mediumTextButton" /></a><a href="#" onClick="javascript:styleSizer(\'largeFont\');"><img src="/images/text_large.gif" alt="Large text" name="largeTextButton" /></a>');
    }
}
// 1. Loop through every link element in the document.
// 2. Disable all preferred and alternate style sheets that we don’t want active.
// 3. Enable all preferred and alternate style sheets that we do want active.
function setActiveStyleSheet(title) {
    var i, a, main;
    for (i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
        if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
            a.disabled = true;
            if (a.getAttribute("title") == title) a.disabled = false;
        }
    }
}
//Return the current style sheet
function getActiveStyleSheet() {
    var i, a;
    for (i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
        if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
    }
    return null;
}
//Find out which style sheet is the preferred style sheet.
function getPreferredStyleSheet() {
    var i, a;
    for (i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
        if (a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
    }
    return null;
}
//Create a cookie to store the preferred style sheet.
function createCookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";
}
//Read the cookie to return the prefered style sheet.
function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}
//On page load get the value of previous style sheeet or use preferred styles sheet.
window.onload = function(e) {
    var cookie = readCookie("style");
    var title = cookie ? cookie : getPreferredStyleSheet();
    setActiveStyleSheet(title);
    checkCookie();
}
//Save the cookie in the onunload event
window.onunload = function(e) {
    var title = getActiveStyleSheet();
    createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);
/*===================================
-- End text sizing functions
====================================*/

/*===================================
-- Begin Printer-Friendly Functions
====================================*/
//Change the status bar when user mouses over the Printer Friendly Version button.
function printOver() {
    window.status = "Open a printer friendly version in a new window"
}
//Restore the status bar when user mouses over the Printer Friendly Version button.
function printOut() {
    window.status = "";
}
//Get the URL of current page and append ?type=print to it. Open the new page.
function printPage() {
    var append = document.URL;
    if (append != '') {
        var finalURL = append + "?type=print";
        window.open(finalURL);
    }
}
//Get the URL of the current page. If the URL ends in type=print, attach print-friendly styles.
/*function pageType() {
    var str = document.URL
    point = str.lastIndexOf("?");
    var suffix = (str.substring(point + 1, str.length));
    if (suffix == "type=print") {
        document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"/css/pfriendly.css\">");
    }
}*/
function pageType() {
    var str = document.URL;
    point = str.lastIndexOf("?");
    var suffix = (str.substring(point + 1, str.length));
    if (suffix == "type=print") {
        document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"/css/pfriendly.css\">");
        $(document).ready(function() {
            if ($.browser.msie) {
                $("#mainContent").clone().insertAfter("#header").end().remove();
            }
            for (var j = 0; j < 7; j++) {
                $("#pageJourney" + j).css("display", "block");
            }

        });
        window.print();
    }
}
/*===================================
-- End Printer-Friendly Functions
====================================*/

/*==================================================================================================
-- Begin Drop-down menu function

-- IMPORTANT NOTICE:
-- The Drop-down menu function below is commented out by default. If you are specifying the dropdown
-- style set in the siteconfig DCR file, the comment block around the drop-down menu function should
-- be removed.

====================================================================================================*/

// Begin Comment
// 1. Apply the 'sfhover' class to li elements in the 'nav' id'd ul element when they are 'moused over'
// 2. Remove the 'sfhover' class from li elements in the 'nav' id'd ul element when 'moused out'
sfHover = function() {
    //var sfEls = document.getElementById("nav").getElementsByTagName("LI");
    //for (var i = 0; i < sfEls.length; i++) {
        //sfEls[i].onmouseover = function() {
            //this.className += " sfhover";
        //}
        //sfEls[i].onmouseout = function() {
        //    this.className = this.className.replace(new RegExp(" sfhover\\b"), "");
        //}

	$("li.topNav").hover(
		function() { $(this).addClass("sfhover"); },
		function() { $(this).removeClass("sfhover"); }
	);
    //}
}

// End Comment
/*===================================
-- End Drop-down menu function
====================================*/

/*==================================
-- Left Nav Top Button
===================================*/

function PrintNavButton() {
    var name = document.URL.split("/");
    var image;
    var link;
    var idname;
    switch (name[3]) {
        case 'humalog-diabetes-and-insulin':
            if (name[4] == "humalog-diabetes-and-insulin.jsp") {
                idname = "header_leftNav_active";
            }
            else {
                idname = "header_leftNav";
            }
            image = 'Diabetes and Insulin';
            link = 'humalog-diabetes-and-insulin/humalog-diabetes-and-insulin.jsp';
            break;
        case 'humalog-mealtime-insulin':
            if (name[4] == "humalog-mealtime-insulin-diabetes.jsp") {
                idname = "header_leftNav_active";
            }
            else {
                idname = "header_leftNav";
            }
            image = 'Humalog Mealtime Insulin';
            link = 'humalog-mealtime-insulin/humalog-mealtime-insulin-diabetes.jsp';
            break;
        case 'humalog-mixture-insulins':
            if (name[4] == "humalog-mixture-insulin-diabetes.jsp") {
                idname = "header_leftNav_active";
            }
            else {
                idname = "header_leftNav";
            }
            image = 'Other Humalog Insulins';
            link = 'humalog-mixture-insulins/humalog-mixture-insulin-diabetes.jsp';
            break;
        case 'humalog-insulin-pens':
            if (name[4] == "humalog-insulin-pens.jsp") {
                idname = "header_leftNav_active";
            }
            else {
                idname = "header_leftNav";
            }
            image = 'Insulin Pens';
            link = 'humalog-insulin-pens/humalog-insulin-pens.jsp';
            break;
        case 'common-questions':
            if (name[4] == "questions-about-diabetes-insulin.jsp") {
                idname = "header_leftNav_active";
            }
            else {
                idname = "header_leftNav";
            }
            image = 'Common Questions';
            link = 'common-questions/questions-about-diabetes-insulin.jsp';
            break;
        case 'resources-education':
            if (name[4] == "diabetes-resources-education.jsp") {
                idname = "header_leftNav_active";
            }
            else {
                idname = "header_leftNav";
            }
            image = 'Resources &amp; Education';
            link = 'resources-education/diabetes-resources-education.jsp';
            break;
	default:
	    idname = "absolutely_nothing";
	    image = '';
	    link = 'http://www.humalog.com';
	    break;
    }
    if (name[3] == "index.jsp" || name[3] == "humalog-insulin-site-map.jsp" || name[3] == "contact-lilly.jsp" || name[3] == "humalog-insulin-important-safety-information.jsp") {
        document.write("<div id='header_leftNav' style='display:none;'><a href='/" + link + "'><div class='header_Text'>" + image + "</div></a></div>");
    }
    else {
        document.write("<div id='" + idname + "'><a href='/" + link + "'><div class='header_Text'>" + image + "</div></a></div>");
    }
}

/*===================================
-- Begin emailAFriend functionality
====================================*/
function sendToFriend() {
    var currentSite = window.location.href;
    var url = "";
    if (currentSite.indexOf("-d.xh1.lilly.com") >= 0) {
        url = "https://emailafriend-d.xh1.lilly.com/index.jsp?url=" + currentSite;
    } else if (currentSite.indexOf("-d6.xh1.lilly.com") >= 0) {
        url = "https://emailafriend-d6.xh1.lilly.com/index.jsp?url=" + currentSite;
    } else if (currentSite.indexOf("-qa.xh1.lilly.com") >= 0) {
        url = "https://emailafriend-qa.xh1.lilly.com/index.jsp?url=" + currentSite;
    } else {
        url = "https://emailafriend.lilly.com/index.jsp?url=" + currentSite;
    }

    window.open(url, 'EmailAFriend', 'height=500, resizable=yes, scrollbars=yes, width=650');
}

/*===================================
-- Begin Interstitial functionality
====================================*/
function popInterstit(destURL) {
    window.open('/include/leaving.jsp?xURL=' + destURL, 'Interstit', 'width=450, height=400, status=yes, location=no, menu=no, scrollable=no, resize=no');
}
function popHCPInterstit(destURL) {
    window.open('/include/hcp.jsp?xURL=' + destURL, 'Interstit', 'width=450, height=400, status=yes, location=no, menu=no, scrollable=no, resize=no');
}
//Javascript code to read the querystring.
var qsParm = new Array();
qsParm["xURL"] = null;
readQS();
//alert(qsParm["media"]);

function readQS() {
    var query = window.location.search.substring(1);
    var parms = query.split('&');

    for (var i = 0; i < parms.length; i++) {
        var pos = parms[i].indexOf('=');
        if (pos > 0) {
            var key = parms[i].substring(0, pos);
            var val = parms[i].substring(pos + 1);
            qsParm[key] = val;
        }
    }
}



/*====================
-- Footer stuff
====================*/

function popPrivacy() {
    popupWin = window.open("https://www.lillyhub.com/legal/consumer/lillyusa/privacy.html", "ViewPop", "status=0,height=590,width=600,scrollbars=1,resizable=yes,toolbar=0")
return false;
}
function popTerms() {
    popupWin = window.open("https://www.lillyhub.com/legal/consumer/lillyusa/termsofuse.html", "ViewPop", "status=0,height=590,width=600,scrollbars=1,resizable=yes,toolbar=0")
return false;
}
function popCopy() {
    popupWin = window.open("https://www.lillyhub.com/legal/consumer/lillyusa/copyright.html", "ViewPop", "status=0,height=590,width=600,scrollbars=1,resizable=yes,toolbar=0")
return false;
}


/*====================
-- Parse query string
====================*/
function parseQuery(query) {
    var Params = {};

    if (!query) { return Params; } // return empty object

    query = query.substring(query.indexOf('?') + 1);
    var Pairs = query.split(/[;&]/);
    for (var i = 0; i < Pairs.length; i++) {
        //var KeyVal = Pairs[i].split('=');
        var KeyVal = new Array();
        KeyVal[0] = Pairs[i].substring(0, Pairs[i].indexOf('='));
        KeyVal[1] = Pairs[i].substring(Pairs[i].indexOf('=') + 1);
        if (!KeyVal || KeyVal.length != 2) { continue; }
        var key = unescape(KeyVal[0]);
        var val = unescape(KeyVal[1]);
        val = val.replace(/\+/g, ' ');
        Params[key] = val;
    }
    return Params;
}

/*====================
-- Play popup video
====================*/


function playVideo(path) {
    var url = '/video-player.jsp?video=' + escape(path) + '&KeepThis=true&width=428&height=367';
}

function closeMe() {
    //alert('being called');
    self.parent.Shadowbox.close();
}


//Pop Tracking Window 0) Domain 1) Path 2) window name 3) Tracking name

function launchTrackWindow() {

    var windowArgs = launchTrackWindow.arguments;

    var finalURL = '';
    if (windowArgs[0].length > 0) {
        dcsMultiTrack('DCS.dcssip', windowArgs[0], 'DCS.dcsuri', windowArgs[1], 'WT.ti', windowArgs[3]);
        //alert('I got to the if statement');
        finalURL = 'http://' + windowArgs[0] + '/' + windowArgs[1];
        //alert('I got to the if statement with finalURL=' + finalURL);
        window.open(finalURL, windowArgs[2]);
        return false;
    }
    else {
        dcsMultiTrack('DCS.dcsuri', windowArgs[1], 'WT.ti', windowArgs[3]);
        //alert('I got to the else statement with .dcsuri=' + windowArgs[1] + 'and WT.ti=' + windowArgs[3]);
        //alert('test');
        return true;
    }
}



/*====================
-- Popup video Free Pens
====================*/
function launchTrackWindow2() {

    var windowArgs2 = launchTrackWindow2.arguments;

    var finalURL2 = '';
    //alert(windowArgs2[0].length);
    if (windowArgs2[0].length > 0) {
        finalURL2 = 'http://' + windowArgs2[0] + '/' + windowArgs2[1];
        //alert('I got to the if statement with finalURL2=' + finalURL2);
        window.open(finalURL2, 'voucher', 'width=640, height=520, status=yes, location=no, menu=no, scrollbars=yes, toolbar=no');
        return false;
    }
}


///////////////////////////////////////////////
///////////////////////////////////////////////
/*==============================
This is the Doctor Discussion Guide Code

-The first function that is called is the checkCookie() from $(document).ready at the top of this code.
-On the press of an "Add this topic to my discussion guide" button the function AddDiscussion() is called.

===============================*/

/*============================
Checking for an existing cookie
=============================*/
function checkCookie() {
    var checklist = readCookie("Checklist");
    if (checklist != null) {
        var list = checklist.split("/");

        for (var i = 0; i < list.length; i++) {
            if (list[i] != "") {
                addElement(list[i]);
                HideDisGuideBtn(list[i]);
            }
        }
    }
}


/*======================
-- Adding and Removing Discussions
========================*/

function AddDiscussion() {
    var Sname = GetTitle();

    createEntry(Sname);
    HideDisGuideBtn(Sname);
}

function RemoveDiscussion(name) {
    removeCookie(name);

    var Sname = GetTitle();

    if(Sname == name){
          ShowDisGuideBtn();
    }
}


/*======================
-- Hide Discussion Guide Button
========================*/

function HideDisGuideBtn(name) {
    var Sname = GetTitle();

    if(Sname == name){
        $('#discussionGuide').css('visibility', 'hidden');
    }
}

function ShowDisGuideBtn() {
     $('#discussionGuide').css('visibility', 'visible');
}



/*======================
-- Get Title
========================*/

function GetTitle() {
    var Sname = "";
    //alert(document.getElementsByName('dc.title')[0].content);
	var titleTag = document.getElementsByName('dc.title')[0].content;
    
    //if (!!titleTag.childNodes.length) {
    //    var Sname = titleTag.firstChild.data;
    //} else if (titleTag.innerHTML) {
    //    var Sname = titleTag.innerHTML;
    //}

	if(titleTag.indexOf("|") > 0)
	{
		Sname = titleTag.split("|");
		Sname = Sname[1];
	}
	else
		Sname = titleTag;


	return Sname;
}


/*===========================
Creating a new cookie
=============================*/

function createEntry(name, day) {
    if (day != -1) {
        var expires = "";
    }



    var checklist = readCookie("Checklist");

    var found = 0;
    if (checklist != null) {
        for (items in list = checklist.split("/")) {
            if (name == list[items]) {
                found = 1;
            }
        }
    }
    else {
        checklist = "";
    }
    if (found == 0) {

        checklist += name + "/";
        document.cookie = "Checklist=" + checklist + "; ; path=/";
        addElement(name);
    }
}


/*===============================
Adding a new div to the checklist
================================*/

function addElement(name) {
    var elem1 = document.getElementById('CheckListWrapper');
    var elem2 = document.getElementById('printGuide');
    var newdiv = document.createElement('div');
    var divIdName = name;
    newdiv.setAttribute('id', divIdName);
    newdiv.className = "checkListRow";
    newdiv.innerHTML = "<div style='border-top:1px solid #000000;'><div style='width:106px;float:left;'>" + name + "</div><div class='RemoveBtn'><a href='javascript: RemoveDiscussion(\"" + name + "\");'><img src='/images/checklist-remove-btn.gif' border='0'/></a></div></div>";
    elem1.insertBefore(newdiv, elem2);
}

/*===============================
Removing a div and the corresponding 
string in the cookie from the checklist
================================*/

function removeCookie(name) {
    var checklist = readCookie("Checklist");
    findName = name + "/";
    checklist = checklist.replace(findName, "");
    document.cookie = "Checklist=" + checklist + "; ; path=/";
    removeElement(name);
}

function removeElement(divName) {
    var div = document.getElementById('CheckListWrapper');
    var olddiv = document.getElementById(divName);
    div.removeChild(olddiv);
}


///////////////////////////////////////////////
///////////////////////////////////////////////

/* ===============================
CAUSE LILLY WON'T FIX THEIR CMS
================================== */

//Fix the drop-down nested NavContainer that is ruining CSS
$(document).ready(function() {
    var strNavContainer = $("#navContainer #navContainer").html();
    //alert("2nd NavContaienr HTML is: " + strNavContainer);

    $("#navContainer").html(strNavContainer);
    $("#navContainer #navContainer").remove();

	//Add mouseover events for the nav to fix IE6
	sfHover();
})

/* ===========================
SETTING LIST OF PAGES
=============================*/

function activateList1() {

    createCookie("pageList", "1", 1);

    var elem0, elem1, elem2, vis0, vis1, vis2;
    if (document.getElementById) {
        elem0 = document.getElementById("pages_to_visit_0");
        elem1 = document.getElementById("pages_to_visit_1");
        elem2 = document.getElementById("pages_to_visit_2");
    }
    else if (document.all) {
        elem0 = document.all["pages_to_visit_0"];
        elem1 = document.all["pages_to_visit_1"];
        elem2 = document.all["pages_to_visit_2"];
    }
    else if (document.layers) {
        elem0 = document.layers["pages_to_visit_0"];
        elem1 = document.layers["pages_to_visit_1"];
        elem2 = document.layers["pages_to_visit_2"];
    }
    vis0 = elem0.style;
    vis1 = elem1.style;
    vis2 = elem2.style;


    vis0.display = "none";
    vis1.display = "block";
    vis2.display = "none";

}

function activateList2() {

    createCookie("pageList", "2", 1);

    var elem0, elem1, elem2, vis0, vis1, vis2;
    if (document.getElementById) {
        elem0 = document.getElementById("pages_to_visit_0");
        elem1 = document.getElementById("pages_to_visit_1");
        elem2 = document.getElementById("pages_to_visit_2");
    }
    else if (document.all) {
        elem0 = document.all["pages_to_visit_0"];
        elem1 = document.all["pages_to_visit_1"];
        elem2 = document.all["pages_to_visit_2"];
    }
    else if (document.layers) {
        elem0 = document.layers["pages_to_visit_0"];
        elem1 = document.layers["pages_to_visit_1"];
        elem2 = document.layers["pages_to_visit_2"];
    }
    vis0 = elem0.style;
    vis1 = elem1.style;
    vis2 = elem2.style;


    vis0.display = "none";
    vis1.display = "none";
    vis2.display = "block";
}

function activateList() {

    var listCookie = readCookie("pageList")
    if (listCookie == "1") {
        activateList1();
    } else if (listCookie == "2") {
        activateList2();
    }
}

$(document).ready(function() {
    var strCurURL = window.location.href;

    //First sub-subnav of /all_about_insulin/low_blood_sugar.jsp
    //if (strCurURL.indexOf("/low-blood-sugar-prevention-treatment.jsp") > 0) {
        //$("#navLevel2 li a").removeClass("active");
        //$("#navLevel3 li:nth-child(1) a").addClass("active");
    //}
    // Second Sub-subnav of /all_about_insulin/low_blood_sugar.jsp
    //if (strCurURL.indexOf("/treat-hypoglycemia-with-glucagon.jsp") > 0) {
        //$("#navLevel2 li a").removeClass("active");
        //$("#navLevel3 li:nth-child(2) a").addClass("active");
    //}
    // Second Sub-subnav of /all_about_insulin/low_blood_sugar.jsp
    if (strCurURL.indexOf("/glucagon-tutorial.jsp") > 0) {
        $("#navLevel2 li a").removeClass("active");
        $("#navLevel3 li:nth-child(2) a").addClass("active");
    }

    if (strCurURL.indexOf("/how-to-use-humalog-kwikpen-insulin-pen.jsp") > 0) {
        $("#navLevel2 li a").removeClass("active");
        $("#navLevel3 li:nth-child(1) a").addClass("active");
    }
    if (strCurURL.indexOf("/how-to-use-humalog-prefilled-insulin-pen.jsp") > 0) {
        $("#navLevel2 li a").removeClass("active");
        $("#navLevel3 li:nth-child(1) a").addClass("active");
    }
    if (strCurURL.indexOf("/how-to-use-humapen-memoir-insulin-pen.jsp") > 0) {
        $("#navLevel2 li a").removeClass("active");
        $("#navLevel3 li:nth-child(1) a").addClass("active");
    }
    if (strCurURL.indexOf("/how-to-use-humapen-luxura-insulin-pen.jsp") > 0) {
        $("#navLevel2 li a").removeClass("active");
        $("#navLevel3 li:nth-child(1) a").addClass("active");
    }            
});


/* ========================
==========================*/

function dlPDF(objTar) {
    var tarObj = document.getElementById(objTar);
    //alert( tarObj.selectedIndex );
    if (tarObj.selectedIndex != 0) {
        if (tarObj.value != '') {
            //alert( tarObj.value );
            window.open(tarObj.value, '_blank');
        }
        else
            alert('No PDF to download yet.');
    }

}

/* ========================
===========================*/

function activateTopNav() {
    var pageName = document.location.href;
    if (pageName.indexOf("humalog-diabetes-and-insulin") != -1) {
	document.getElementById("top1").src = "/images/TopNav/humalog-diabetes-and-insulin-on.gif";
        document.getElementById("top1").mouseout = "";
    }
    if (pageName.indexOf("humalog-mealtime-insulin") != -1) {
        document.getElementById("top2").src = "/images/TopNav/humalog-mealtime-insulin-on.gif";
        document.getElementById("top2").mouseout = "";
    }
    if (pageName.indexOf("humalog-mixture-insulins") != -1) {
        document.getElementById("top3").src = "/images/TopNav/other-humalog-insulins-on.gif";
        document.getElementById("top3").mouseout = "";
    }
    if (pageName.indexOf("humalog-insulin-pens") != -1) {
        document.getElementById("top4").src = "/images/TopNav/insulin-pens-on.gif";
        document.getElementById("top4").mouseout = "";
    }
    if (pageName.indexOf("common-questions") != -1) {
        document.getElementById("top5").src = "/images/TopNav/common-questions-on.gif";
        document.getElementById("top5").mouseout = "";
    }
    if (pageName.indexOf("resources-education") != -1) {
        document.getElementById("top6").src = "/images/TopNav/resources-education-on.gif";
        document.getElementById("top6").mouseout = "";
    }
}

/* ========================
===========================*/

function submitForm()
{
	$("#searchBox")[0].submit();
	return false;
}