﻿//warn on leave code
var warn_on_leave_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?";

function warn_on_leave(site) {
    if (confirm(warn_on_leave_msg)) {
        window.open(site);
    }
    else {
        return;
    }
}
function warn_on_leave_to_itunes(site, floodlightIframe) {
    if (confirm(warn_on_leave_msg)) {
        var axel = Math.random() + "";
        var a = axel * 10000000000000;
        floodlightIframe.attr('src', 'http://fls.doubleclick.net/activityi;src=2644366;type=simil552;cat=babyj990;ord=' + a + '?');

        window.open(site);
    } else {
        return;
    }
}
/*function: BuildAnchorList*/
/*iterates through page to find a unordered list with a class of 'anchor-links'*/
/*if it does finds that class then dynamically builds the links inside the list items for the id of each .article-template class*/
/*allows us to just add a class inside cms, without knowledge other markup or even knowledge of other content.*/
/*assumption is that every article-template section outside of the one where the list is, should be an anchor*/
/*skips h2 sections with article-callout class in article-template node, and h2 sections with the class anchor-skip anywhere inside the article-template node*/
function BuildAnchorList() {
    if ($(".anchor-links").length > 0) {
        var anchorContainerArticleId = $(".anchor-links").closest(".article-template").attr("id");
        var articleIds = new Array();
        var i = 0;

        $(".article-template").each(function() {
        if (this.id != anchorContainerArticleId && this.id != "article-section-0" && !$(this).is(".article-callout") && $(this).find(".anchor-skip").length==0) {
                articleIds[i] = this.id;
                i++;
            }
        });
        i = 0;
        $(".anchor-links li").each(function() {
            var thisText = $(this).text();
            var anchorText = '<a href="#' + articleIds[i] + '">' + thisText + '</a>';
            $(this).replaceWith("<li>" + anchorText + "</li>");
            i++;
        });
    }
}

// parse querystrings out of url
function getQueryParameter(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);
    if (results == null) {
        return "";
    }
    else {
        return results[1];
    }
}
