﻿//-----------------------------------------------------------------------
// <copyright file="web_analytics.js" company="McKesson Corporation">
//     Copyright (c) McKesson Corporation. All rights reserved.
// </copyright>
//---

//NOTE: Change between QA & PROD
var gDomain = "webanalytics.mckesson.com";
//var gDomain = "ddcz3254.mckesson.com";
//McKesson.com DCSID
var gDcsId = "dcspred3v10000470c05sy451_3s3e";

// parseUri 1.2.1
// (c) 2007 Steven Levithan <stevenlevithan.com>
// MIT License
function parseUri(str) {
    var o = parseUri.options,
		m = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
		uri = {},
		i = 14;

    while (i--) uri[o.key[i]] = m[i] || "";

    uri[o.q.name] = {};
    uri[o.key[12]].replace(o.q.parser, function($0, $1, $2) {
        if ($1) uri[o.q.name][$1] = $2;
    });

    return uri;
};

parseUri.options = {
    strictMode: false,
    key: ["source", "protocol", "authority", "userInfo", "user", "password", "host", "port", "relative", "path", "directory", "file", "query", "anchor"],
    q: {
        name: "queryKey",
        parser: /(?:^|&)([^&=]*)=?([^&]*)/g
    },
    parser: {
        strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
        loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
    }
};

// Change the parseUri into strictMode
parseUri.options.strictMode = true;

// Mck: Helper function for parseUri
function repairUri(uri) {
    if (!uri.host) {
        uri.host = window.location.hostname;
        if (!uri.path) {
            uri.path = '/';
        }
        else if (uri.path.indexOf("/") != 0) {
            uri.path = parseUri(window.location).directory + uri.path;
        }
    }
    return uri;
}

function getUri(url) {
    return repairUri(parseUri(url));
}
// END: parseUri


//START: String Routines
String.prototype.mckQuoteTrim = function() {
    return this.replace(/^[\s\"\'\`]+/, '').replace(/[\s|\"\'`]+$/, '');
}

String.prototype.mckTrim = function() {
    return this.replace(/^\s+/, '').replace(/\s+$/, '');
}
//END: String Routines

//START: WebTrends Routines
//NOTE: Contains some McKesson Modifications
var gService = false;
var gTimeZone = -8;
// Code section for Enable First-Party Cookie Tracking
function dcsCookie() {
    if (typeof (dcsOther) == "function") {
        dcsOther();
    }
    else if (typeof (dcsPlugin) == "function") {
        dcsPlugin();
    }
    else if (typeof (dcsFPC) == "function") {
        dcsFPC(gTimeZone);
    }
}

function dcsGetCookie(name) {
    var pos = document.cookie.indexOf(name + "=");
    if (pos != -1) {
        var start = pos + name.length + 1;
        var end = document.cookie.indexOf(";", start);
        if (end == -1) {
            end = document.cookie.length; etsitefromuri
        }
        return unescape(document.cookie.substring(start, end));
    }
    return null;
}

function dcsGetCrumb(name, crumb) {
    var aCookie = dcsGetCookie(name).split(":");
    for (var i = 0; i < aCookie.length; i++) {
        var aCrumb = aCookie[i].split("=");
        if (crumb == aCrumb[0]) {
            return aCrumb[1];
        }
    }
    return null;
}

function dcsGetIdCrumb(name, crumb) {
    var cookie = dcsGetCookie(name);
    var id = cookie.substring(0, cookie.indexOf(":lv="));
    var aCrumb = id.split("=");
    for (var i = 0; i < aCrumb.length; i++) {
        if (crumb == aCrumb[0]) {
            return aCrumb[1];
        }
    }
    return null;
}

function dcsFPC(offset) {
    if (typeof (offset) == "undefined") {
        return;
    }
    if (document.cookie.indexOf("WTLOPTOUT=") != -1) {
        return;
    }
    var name = gFpc;
    var dCur = new Date();
    var adj = (dCur.getTimezoneOffset() * 60000) + (offset * 3600000);
    dCur.setTime(dCur.getTime() + adj);
    var dExp = new Date(dCur.getTime() + 315360000000);
    var dSes = new Date(dCur.getTime());
    WT.co_f = WT.vt_sid = WT.vt_f = WT.vt_f_a = WT.vt_f_s = WT.vt_f_d = WT.vt_f_tlh = WT.vt_f_tlv = "";
    if (document.cookie.indexOf(name + "=") == -1) {
        if ((typeof (gWtId) != "undefined") && (gWtId != "")) {
            WT.co_f = gWtId;
        }
        else if ((typeof (gTempWtId) != "undefined") && (gTempWtId != "")) {
            WT.co_f = gTempWtId;
            WT.vt_f = "1";
        }
        else {
            WT.co_f = "2";
            var cur = dCur.getTime().toString();
            for (var i = 2; i <= (32 - cur.length); i++) {
                WT.co_f += Math.floor(Math.random() * 16.0).toString(16);
            }
            WT.co_f += cur;
            WT.vt_f = "1";
        }
        if (typeof (gWtAccountRollup) == "undefined") {
            WT.vt_f_a = "1";
        }
        WT.vt_f_s = WT.vt_f_d = "1";
        WT.vt_f_tlh = WT.vt_f_tlv = "0";
    }
    else {
        var id = dcsGetIdCrumb(name, "id");
        var lv = parseInt(dcsGetCrumb(name, "lv"));
        var ss = parseInt(dcsGetCrumb(name, "ss"));
        if ((id == null) || (id == "null") || isNaN(lv) || isNaN(ss)) {
            return;
        }
        WT.co_f = id;
        var dLst = new Date(lv);
        WT.vt_f_tlh = Math.floor((dLst.getTime() - adj) / 1000);
        dSes.setTime(ss);
        if ((dCur.getTime() > (dLst.getTime() + 1800000)) || (dCur.getTime() > (dSes.getTime() + 28800000))) {
            WT.vt_f_tlv = Math.floor((dSes.getTime() - adj) / 1000);
            dSes.setTime(dCur.getTime());
            WT.vt_f_s = "1";
        }
        if ((dCur.getDay() != dLst.getDay()) || (dCur.getMonth() != dLst.getMonth()) || (dCur.getYear() != dLst.getYear())) {
            WT.vt_f_d = "1";
        }
    }
    WT.co_f = escape(WT.co_f);
    WT.vt_sid = WT.co_f + "." + (dSes.getTime() - adj);
    var expiry = "; expires=" + dExp.toGMTString();
    document.cookie = name + "=" + "id=" + WT.co_f + ":lv=" + dCur.getTime().toString() + ":ss=" + dSes.getTime().toString() + expiry + "; path=/" + (((typeof (gFpcDom) != "undefined") && (gFpcDom != "")) ? ("; domain=" + gFpcDom) : (""));
    if (document.cookie.indexOf(name + "=") == -1) {
        WT.co_f = WT.vt_sid = WT.vt_f_s = WT.vt_f_d = WT.vt_f_tlh = WT.vt_f_tlv = "";
        WT.vt_f = WT.vt_f_a = "2";
    }
}

// Code section for Use the WebTrends Cookie Plug-in cookie. Your web server(s) require the WebTrends Cookie Plug-in.
function dcsPlugin() {
    if (typeof (gFpc) != "undefined") {
        if (dcsGetCookie("WEBTRENDS_ID")) {
            gTempWtId = dcsGetCookie("WEBTRENDS_ID");
            dcsFPC(gTimeZone);
        }
        else if (dcsGetCookie(gFpc)) {
            document.cookie = gFpc + "=; expires=Thu, 01-Jan-1970 00:00:01 GMT";
        }
    }
    else if (dcsGetCookie("WEBTRENDS_ID")) {
        WT.co_f = escape(dcsGetCookie("WEBTRENDS_ID"));
    }
}

// Code section for Enable SmartView Transition Page tracking
function dcsTP() {
    if (document.cookie.indexOf("WTLOPTOUT=") != -1) {
        return;
    }
    var name = "WT_DC";
    var expiry = "; expires=Thu, 31-Dec-2020 08:00:00 GMT";
    var path = "; path=/";
    var domain = "";
    if ((document.cookie.indexOf(name + "=") != -1) && (dcsGetCrumb(name, "tsp") == "1")) {
        WT.ttp = "1";
    }
    if (dcsGetMeta("SmartView_Page") == "1") {
        WT.tsp = "1";
        document.cookie = name + "=tsp=1" + expiry + path + domain;
    }
    else {
        document.cookie = name + "=; expires=Sun, 1-Jan-1995 00:00:00 GMT;" + path + domain;
    }
}

function dcsGetMeta(name) {
    var elems;
    if (document.all) {
        elems = document.all.tags("meta");
    }
    else if (document.documentElement) {
        elems = document.getElementsByTagName("meta");
    }
    if (typeof (elems) != "undefined") {
        for (var i = 1; i <= elems.length; i++) {
            var meta = elems.item(i - 1);
            if (meta.name && (meta.name.indexOf(name) == 0)) {
                return meta.content;
                break;
            }
        }
    }
    return null;
}

// The functions dcsGetCookie and dcsGetCrumb can be removed
// if already using First-Party Cookie Tracking.
function dcsGetCookie(name) {
    var pos = document.cookie.indexOf(name + "=");
    if (pos != -1) {
        var start = pos + name.length + 1;
        var end = document.cookie.indexOf(";", start);
        if (end == -1) {
            end = document.cookie.length;
        }
        return unescape(document.cookie.substring(start, end));
    }
    return null;
}

function dcsGetCrumb(name, crumb) {
    var aCookie = dcsGetCookie(name).split(":");
    for (var i = 0; i < aCookie.length; i++) {
        var aCrumb = aCookie[i].split("=");
        if (crumb == aCrumb[0]) {
            return aCrumb[1];
        }
    }
    return null;
}

function dcsAdv() {
    dcsFunc("dcsET");
    dcsFunc("dcsCookie");
    dcsFunc("dcsAdSearch");
    dcsFunc("dcsTP");
}

if ((typeof (gConvert) != "undefined") && gConvert && (document.cookie.indexOf(gFpc + "=") == -1) && (document.cookie.indexOf("WTLOPTOUT=") == -1)) {
    document.write("<SCR" + "IPT TYPE='text/javascript' SRC='" + "http" + (window.location.protocol.indexOf('https:') == 0 ? 's' : '') + "://" + gDomain + "/" + gDcsId + "/wtid.js" + "'><\/SCR" + "IPT>");
}

var gImages = new Array;
var gIndex = 0;
var DCS = new Object();
var WT = new Object();
var DCSext = new Object();
var gQP = new Array();
var gI18n = false;
if (window.RegExp) {
    var RE = { "%09": /\t/g, "%20": / /g, "%23": /\#/g, "%26": /\&/g, "%2B": /\+/g, "%3F": /\?/g, "%5C": /\\/g, "%22": /\"/g, "%7F": /\x7F/g, "%A0": /\xA0/g };
    var I18NRE = { "%25": /\%/g };
}

// Add customizations here
function dcsVar() {
    var dCurrent = new Date();
    WT.tz = dCurrent.getTimezoneOffset() / 60 * -1;
    if (WT.tz == 0) {
        WT.tz = "0";
    }
    WT.bh = dCurrent.getHours();
    WT.ul = navigator.appName == "Netscape" ? navigator.language : navigator.userLanguage;
    if (typeof (screen) == "object") {
        WT.cd = navigator.appName == "Netscape" ? screen.pixelDepth : screen.colorDepth;
        WT.sr = screen.width + "x" + screen.height;
    }
    if (typeof (navigator.javaEnabled()) == "boolean") {
        WT.jo = navigator.javaEnabled() ? "Yes" : "No";
    }
    if (document.title) {
        if (document.getElementById('webtrendstitle')) {
            var wttitle = document.getElementById('webtrendstitle').innerHTML;
            WT.ti = gI18n ? dcsEscape(dcsEncode(wttitle), I18NRE) : wttitle;
            WT.alt_title = gI18n ? dcsEscape(dcsEncode(document.title), I18NRE) : document.title;
        }
        else {
            WT.ti = gI18n ? dcsEscape(dcsEncode(document.title), I18NRE) : document.title;
        }
    }
    WT.js = "Yes";
    WT.jv = dcsJV();
    if (document.body && document.body.addBehavior) {
        document.body.addBehavior("#default#clientCaps");
        WT.ct = document.body.connectionType || "unknown";
        document.body.addBehavior("#default#homePage");
        WT.hp = document.body.isHomePage(location.href) ? "1" : "0";
    }
    else {
        WT.ct = "unknown";
    }
    if (parseInt(navigator.appVersion) > 3) {
        if ((navigator.appName == "Microsoft Internet Explorer") && document.body) {
            WT.bs = document.body.offsetWidth + "x" + document.body.offsetHeight;
        }
        else if (navigator.appName == "Netscape") {
            WT.bs = window.innerWidth + "x" + window.innerHeight;
        }
    }
    WT.fi = "No";
    if (window.ActiveXObject) {
        for (var i = 10; i > 0; i--) {
            try {
                var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
                WT.fi = "Yes";
                WT.fv = i + ".0";
                break;
            }
            catch (e) {
            }
        }
    }
    else if (navigator.plugins && navigator.plugins.length) {
        for (var i = 0; i < navigator.plugins.length; i++) {
            if (navigator.plugins[i].name.indexOf('Shockwave Flash') != -1) {
                WT.fi = "Yes";
                WT.fv = navigator.plugins[i].description.split(" ")[2];
                break;
            }
        }
    }
    if (gI18n) {
        WT.em = (typeof (encodeURIComponent) == "function") ? "uri" : "esc";
        if (typeof (document.defaultCharset) == "string") {
            WT.le = document.defaultCharset;
        }
        else if (typeof (document.characterSet) == "string") {
            WT.le = document.characterSet;
        }
    }
    WT.tv = "8.0.2";
    WT.sp = "@@SPLITVALUE@@";
    DCS.dcsdat = dCurrent.getTime();
    DCS.dcssip = window.location.hostname;
    DCS.dcsuri = window.location.pathname;
    if (window.location.search) {
        DCS.dcsqry = window.location.search;
        if (gQP.length > 0) {
            for (var i = 0; i < gQP.length; i++) {
                var pos = DCS.dcsqry.indexOf(gQP[i]);
                if (pos != -1) {
                    var front = DCS.dcsqry.substring(0, pos);
                    var end = DCS.dcsqry.substring(pos + gQP[i].length, DCS.dcsqry.length);
                    DCS.dcsqry = front + end;
                }
            }
        }
    }
    if ((window.document.referrer != "") && (window.document.referrer != "-")) {
        if (!(navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) < 4)) {
            DCS.dcsref = gI18n ? dcsEscape(window.document.referrer, I18NRE) : window.document.referrer;
        }
    }
}

function dcsA(N, V) {
    return "&" + N + "=" + dcsEscape(V, RE);
}

function dcsEscape(S, REL) {
    if (typeof (REL) != "undefined") {
        var retStr = new String(S);
        for (var R in REL) {
            retStr = retStr.replace(REL[R], R);
        }
        return retStr;
    }
    else {
        return escape(S);
    }
}

function dcsEncode(S) {
    return (typeof (encodeURIComponent) == "function") ? encodeURIComponent(S) : escape(S);
}

function dcsCreateImage(dcsSrc) {
    if (document.images) {
        gImages[gIndex] = new Image;
        gImages[gIndex].src = dcsSrc;
        gIndex++;
    }
    else {
        document.write('<IMG ALT="" BORDER="0" NAME="DCSIMG" WIDTH="1" HEIGHT="1" SRC="' + dcsSrc + '">');
    }
    //RLR - This was added to always reset after - mainly needed to to calls to dcsMultiTrack
    resetWebtrendsArray();
}

function dcsMeta() {
    var elems;
    if (document.all) {
        elems = document.all.tags("meta");
    }
    else if (document.documentElement) {
        elems = document.getElementsByTagName("meta");
    }
    if (typeof (elems) != "undefined") {
        for (var i = 1; i <= elems.length; i++) {
            var meta = elems.item(i - 1);
            if (meta.name) {
                if (meta.name.indexOf('WT.') == 0) {
                    WT[meta.name.substring(3)] = (gI18n && (meta.name.indexOf('WT.ti') == 0)) ? dcsEscape(dcsEncode(meta.content), I18NRE) : meta.content;
                }
                else if (meta.name.indexOf('DCSext.') == 0) {
                    DCSext[meta.name.substring(7)] = meta.content;
                }
                else if (meta.name.indexOf('DCS.') == 0) {
                    DCS[meta.name.substring(4)] = (gI18n && (meta.name.indexOf('DCS.dcsref') == 0)) ? dcsEscape(meta.content, I18NRE) : meta.content;
                }
            }
        }
    }
}

function dcsTag() {
    if (arguments.length == 0) {
        processStaticFiles();
    }
    if (document.cookie.indexOf("WTLOPTOUT=") != -1) {
        return;
    }
    var P = "http" + (window.location.protocol.indexOf('https:') == 0 ? 's' : '') + "://" + gDomain + (gDcsId == "" ? '' : '/' + gDcsId) + "/dcs.gif?";
    for (var N in DCS) {
        if (DCS[N]) {
            P += dcsA(N, DCS[N]);
        }
    }
    for (N in WT) {
        if (WT[N]) {
            P += dcsA("WT." + N, WT[N]);
        }
    }
    for (N in DCSext) {
        if (DCSext[N]) {
            P += dcsA(N, DCSext[N]);
        }
    }
    if (P.length > 2048 && navigator.userAgent.indexOf('MSIE') >= 0) {
        P = P.substring(0, 2040) + "&WT.tu=1";
    }
    dcsCreateImage(P);
}

function dcsJV() {
    var agt = navigator.userAgent.toLowerCase();
    var major = parseInt(navigator.appVersion);
    var mac = (agt.indexOf("mac") != -1);
    var ff = (agt.indexOf("firefox") != -1);
    var ff0 = (agt.indexOf("firefox/0.") != -1);
    var ff10 = (agt.indexOf("firefox/1.0") != -1);
    var ff15 = (agt.indexOf("firefox/1.5") != -1);
    var ff2up = (ff && !ff0 && !ff10 & !ff15);
    var nn = (!ff && (agt.indexOf("mozilla") != -1) && (agt.indexOf("compatible") == -1));
    var nn4 = (nn && (major == 4));
    var nn6up = (nn && (major >= 5));
    var ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    var ie4 = (ie && (major == 4) && (agt.indexOf("msie 4") != -1));
    var ie5up = (ie && !ie4);
    var op = (agt.indexOf("opera") != -1);
    var op5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
    var op6 = (agt.indexOf("opera 6") != -1 || agt.indexOf("opera/6") != -1);
    var op7up = (op && !op5 && !op6);
    var jv = "1.1";
    if (ff2up) {
        jv = "1.7";
    }
    else if (ff15) {
        jv = "1.6";
    }
    else if (ff0 || ff10 || nn6up || op7up) {
        jv = "1.5";
    }
    else if ((mac && ie5up) || op6) {
        jv = "1.4";
    }
    else if (ie5up || nn4 || op5) {
        jv = "1.3";
    }
    else if (ie4) {
        jv = "1.2";
    }
    return jv;
}

function dcsFunc(func) {
    if (typeof (window[func]) == "function") {
        window[func]();
    }
}

function dcsMultiTrack() {
    if (arguments.length % 2 == 0) {
        for (var i = 0; i < arguments.length; i += 2) {
            if (arguments[i].indexOf('WT.') == 0) {
                WT[arguments[i].substring(3)] = arguments[i + 1];
            }
            else if (arguments[i].indexOf('DCS.') == 0) {
                DCS[arguments[i].substring(4)] = arguments[i + 1];
            }
            else if (arguments[i].indexOf('DCSext.') == 0) {
                DCSext[arguments[i].substring(7)] = arguments[i + 1];
            }
        }
        var dCurrent = new Date();
        DCS.dcsdat = dCurrent.getTime();
        dcsFunc("dcsCookie");
        dcsTag(true);
    }
}
//START: WebTrends Routines

// START: McKesson.com Specific Routines
function calldcsMultiTrack() {
    var argv = calldcsMultiTrack.arguments;
    var strWTti = new String(argv[0]);

    if (strWTti == "/en_us/McKesson.com/For%2BPharmacies/Mail%2BOrder/Mail%2BOrder%2BPharmacies.html") {
        strWTti = "Mail Order";
    }
    else if (strWTti == "/en_us/McKesson.com/For%2BPharmacies/Independent%2BRetail/Independent%2BRetail%2BPharmacies.html") {
        strWTti = "Independent Retail";
    }
    else if (strWTti == "/en_us/McKesson.com/For%2BPharmacies/Retail%2BRegional%2BChains/Retail%2BRegional%2BChain%2BPharmacies.html") {
        strWTti = "Retail Regional Chain";
    }
    else if (strWTti == "/en_us/McKesson.com/For%2BPharmacies/Retail%2BNational%2BChains/Retail%2BNational%2BChain%2BPharmacies.html") {
        strWTti = "Retail National Chain";
    }
    else if (strWTti == "/en_us/McKesson.com/For%2BPharmacies/Inpatient/Inpatient%2BPharmacies.html") {
        strWTti = "Inpatient Pharmacies";
    }
    else if (strWTti == "/en_us/McKesson.com/For%2BPharmacies/Outpatient/Outpatient%2BPharmacies.html") {
        strWTti = "Outpatient Pharmacies";
    }
    else if (strWTti == "/en_us/McKesson.com/For%2BPharmacies/Long-Term%2BCare/Long-Term%2BCare%2BPharmacies.html") {
        strWTti = "Long-Term Care";
    }
    else if (strWTti == "/en_us/McKesson.com/For%2BPharmacies/Specialty/Specialty%2BPharmacy.html") {
        strWTti = "Speciality";
    }
    else if (strWTti == "/en_us/McKesson.com/For%2BPharmacies/Institutional%2Band%2BGovernment/Institutional%2Band%2BGovernment%2BPharmacies.html") {
        strWTti = "Institutiional and Government";
    }
    else if (strWTti == "/en_us/McKesson.com/For%2BHealthcare%2BProviders/Long-Term%2BCare/Long-Term%2BCare.html") {
        strWTti = "HC Long Term Care";
    }
    else if (strWTti == "/en_us/McKesson.com/For%2BHealthcare%2BProviders/Home%2BCare/Home%2BCare.html") {
        strWTti = "Home Care";
    }
    else if (strWTti == "/en_us/McKesson.com/For%2BHealthcare%2BProviders/Surgery%2BCenters/Surgery%2BCenters.html") {
        strWTti = "Surgery Centers";
    }

    var destUrl;
    if (argv[2] == null || argv[2] == undefined) {
        destUrl = window.location.hostname;
    }
    else {
        destUrl = argv[2];
    }

    var uri = getUri(destUrl);
    dcsMultiTrack(
		'DCS.dcssip', uri.host,
		'DCS.dcsuri', uri.path,
		'DCS.dcsqry', uri.query,
		'WT.dl', '1',
		'WT.ti', strWTti,
		'WT.EvtSrc', window.location,
		'WT.NavArea', argv[1]
	);
    DCS.dcssip = DCS.dcsuri = DCS.dcsqry = WT.dl = WT.ti = WT.EvtSrc = WT.NavArea = "";
}

function getMcKessonDownloadsDirectory(url) {
    var staticPrefix1 = '/static_files';
    var staticPrefix2 = '/static_files/mckesson.com/';
    var index;
    var downloadFullPath = null;
    var downloadDirectory = '';
    var uri = getUri(url);
    var path = uri.path;
    index = path.toLowerCase().search(staticPrefix1)
    // this is the test for '/static_files';
    if (index == 0) {
        downloadFullPath = path.substring(staticPrefix2.length);
        if (downloadFullPath != null) {
            index = downloadFullPath.indexOf('/');
            if (index >= 0) {
                downloadDirectory = downloadFullPath.substring(0, index)
            }
        }
    }
    return downloadDirectory;
}

function calladvdcsMultiTrack() {
    var argv = calladvdcsMultiTrack.arguments;
    var title = gI18n ? dcsEscape(dcsEncode(argv[1]), I18NRE) : argv[1];
    var uri = getUri(argv[0]);
    if (arguments.length >= 7) {
        dcsMultiTrack(
			'DCS.dcssip', uri.host,
 			'DCS.dcsuri', uri.path,
 			'DCS.dcsqry', uri.query,
 			'WT.dl', '1',
 			'WT.ti', title,
 			'WT.EvtSrc', window.location,
 			'WT.NavArea', argv[2],
 			'DCS.wt_Ads', argv[3],
			'WT.Navlvl1', argv[6],
			'WT.AdLinkType', argv[4]
		);
        DCS.dcssip = DCS.dcsuri = DCS.dcsqry = WT.dl = WT.ti = WT.EvtSrc = WT.NavArea = DCS.wt_Ads = WT.Nav1vl1 = WT.AdLinkType = "";
    }
    else {
        dcsMultiTrack(
			'DCS.dcssip', uri.host,
 			'DCS.dcsuri', uri.path,
 			'DCS.dcsqry', uri.query,
 			'WT.dl', '1',
 			'WT.ti', title,
 			'WT.EvtSrc', window.location,
 			'WT.NavArea', argv[2],
 			'DCS.wt_Ads', argv[3],
 			'WT.AdLinkType', argv[4]
		);
        DCS.dcssip = DCS.dcsuri = DCS.dcsqry = WT.dl = WT.ti = WT.EvtSrc = WT.NavArea = DCS.wt_Ads = WT.AdLinkType = "";
    }
}

function calldcsevtfMultiTrack() {
    var argv = calldcsevtfMultiTrack.arguments;
    dcsMultiTrack(
		'DCS.dcssip', window.location.hostname,
 		'DCS.dcsuri', window.location.pathname,
 		'DCS.dcsqry', '',
 		'WT.dl', '1',
 		'WT.ti', argv[0],
 		'WT.EvtSrc', window.location,
 		'WT.NavArea', argv[1],
 		'WT.EvtFilter', argv[2]
	);
    DCS.dcssip = DCS.dcsuri = DCS.dcsqry = WT.dl = WT.ti = WT.EvtSrc = WT.NavArea = WT.EvtFilter = "";
}

function calldcsevtSearchMultiTrack() {
    var argv = calldcsevtSearchMultiTrack.arguments;
    dcsMultiTrack(
		'DCS.dcssip', window.location.hostname,
 		'DCS.dcsuri', window.location.pathname,
 		'DCS.dcsqry', '',
 		'WT.dl', '1',
 		'WT.ti', argv[0],
 		'WT.EvtSrc', window.location,
 		'WT.NavArea', argv[1],
 		'WT.EvtSearch', argv[2]
	);
    DCS.dcssip = DCS.dcsuri = DCS.dcsqry = WT.dl = WT.ti = WT.EvtSrc = WT.NavArea = WT.EvtSearch = "";
}

function calldcseventTrack() {
    var argv = calldcseventTrack.arguments;
    var uri = getUri(argv[0]);
    dcsMultiTrack(
		'DCS.dcssip', uri.host,
 		'DCS.dcsuri', uri.path,
 		'DCS.dcsqry', uri.query,
 		'WT.dl', '1',
 		'WT.ti', argv[2],
 		'WT.EvtSrc', window.location,
 		'WT.NavArea', argv[3]
	);
    DCS.dcssip = DCS.dcsuri = DCS.dcsqry = WT.dl = WT.ti = WT.EvtSrc = WT.NavArea = "";
}

//START: Customer Login
function calldcsCustomerLoginTrack(anchor) {
    var argv = calldcsCustomerLoginTrack.arguments;
    var uri = getUri(anchor.href);
    var title = document.all ? anchor.innerText : anchor.text;
    if (argv.length > 1) {
        title = argv[1];
    }
    dcsMultiTrack(
		'DCS.dcssip', uri.host,
 		'DCS.dcsuri', uri.path,
 		'DCS.dcsqry', uri.query,
 		'WT.dl', '1',
 		'WT.ti', gI18n ? dcsEscape(dcsEncode(title), I18NRE) : title,
 		'WT.EvtSrc', window.location
	);
    DCS.dcssip = DCS.dcsuri = DCS.dcsqry = WT.dl = WT.ti = WT.EvtSrc = "";
}
//END: Customer Login

function insertOnClick(url, title, needspopup) {
    var uri = getUri(url);
    dcsMultiTrack(
		'DCS.dcssip', uri.host,
        'DCS.dcsuri', uri.path,
        'DCS.dcsqry', uri.query,
        'WT.dl', '1',
        'WT.ti', gI18n ? dcsEscape(dcsEncode(title), I18NRE) : title,
        'WT.Navlvl1', getMcKessonDownloadsDirectory(url)
	);
    DCS.dcssip = DCS.dcsuri = DCS.dcsqry = WT.dl = WT.ti = WT.Nav1vl1 = "";

    if (needspopup == 'true') {
        //window.open(url,'popup');
        return false;
    }
}

function processStaticFiles() {
    var anchorElement = new Array();
    if (document.getElementsByTagName) {
        anchorElement = document.getElementsByTagName("a");
    }
    else if (document.all) {
        anchorElement = document.all.tags("a");
    }
    
    if (typeof (anchorElement) != "undefined") {
        for (var i = 0; i < anchorElement.length; i++) {
            var url = anchorElement[i].href.toLowerCase();
            var isAd = false;
            var isStatic = false;
            if (url.search('/static_files/mckesson.com/') >= 0) {
                isStatic = true;
            }

            var params = null;
            if (anchorElement[i].id) {
                var id = anchorElement[i].id;

                if (id.match("HREF(Image|Title)Set")) {
                    isAd = true;
                    var onClickFunction = anchorElement[i].onclick;
                    params = onClickFunction.toString().split('(')[2].split(')')[0].split(',');
                    var tmpParam = '';
                    var finalParams = new Array();
                    for (var n = 0; n < params.length; n++) {
                        var param = params[n].mckTrim();
                        if (param.indexOf("'") == 0) {
                            if (param.lastIndexOf("'") != param.length - 1) {
                                n++;
                                while (params[n].mckTrim().lastIndexOf("'") != params[n].mckTrim().length - 1 && n < params.length) {
                                    param += ' ' + params[n++];
                                }
                                param += ' ' + params[n];
                            }
                            finalParams[finalParams.length] = param.mckQuoteTrim();
                        }
                        else if (param.indexOf('"') == 0) {
                            if (param.lastIndexOf('"') != param.length - 1) {
                                n++;
                                while (params[n].mckTrim().lastIndexOf('"') != params[n].mckTrim().length - 1 && n < params.length) {
                                    param += ' ' + params[n++];
                                }
                                param += ' ' + params[n];
                            }
                            finalParams[finalParams.length] = param.mckQuoteTrim();
                        }
                        else {
                            finalParams[finalParams.length] = param.mckQuoteTrim();
                        }
                    }
                    
                    finalParams[finalParams.length] = id.match("HREFImageSet") ? "Graphic" : "Text";

                    anchorElement[i].uri = anchorElement[i].href;
                    anchorElement[i].title = finalParams[1];
                    anchorElement[i].NavArea = finalParams[2];
                    anchorElement[i].wt_Ads = finalParams[3];
                    anchorElement[i].AdLinkType = finalParams[finalParams.length - 1];

                    if (!isStatic) {
                        anchorElement[i].onclick =
	                function(e) {
	                    calladvdcsMultiTrack(this.uri, this.title, this.NavArea, this.wt_Ads, this.AdLinkType, 'true');
	                };
                    }
                    else {
                        anchorElement[i].Navlvl1 = getMcKessonDownloadsDirectory(params[0])
                        anchorElement[i].onclick =
	                function(e) {
	                    calladvdcsMultiTrack(this.uri, this.title, this.NavArea, this.wt_Ads, this.AdLinkType, 'true', this.Navlvl1);
	                };
                    }
                }
            }

            if (!isAd && isStatic) {
                if (anchorElement[i].onclick == null) {
                    anchorElement[i].onclick =
                    function() {
                        insertOnClick(this.href, this.innerHTML, 'false')
                    };
                }
                else {
                    anchorElement[i].target = '_blank';
                    anchorElement[i].onclick =
                    function() {
                        insertOnClick(this.href, this.innerHTML, 'true')
                    };
                }
            }
        }
    }
}
//END: McKesson.com Specific Routines

//START: Mck WebTrends Enhancements
function resetWebtrendsArray() {
    gImages = new Array;
    gIndex = 0;
    DCS = new Object();
    WT = new Object();
    DCSext = new Object();
    gQP = new Array();
    gI18n = false;
}
//END: MckWebTrends Enhancements

//START: Print This routine
function calldcsPrintTrack() {
    var uri = getUri('http://www.mckesson.com/print+page.html');

    dcsMultiTrack(
		'DCS.dcssip', uri.host,
 		'DCS.dcsuri', uri.path,
 		'DCS.dcsqry', uri.query,
 		'WT.dl', '1',
 		'WT.ti', 'Print This',
 		'WT.EvtSrc', window.location
	);
    DCS.dcssip = DCS.dcsuri = DCS.dcsqry = WT.dl = WT.ti = WT.EvtSrc = "";

    window.print();
}
//END: Print This routine

//START: AddThis routines
//This function finds the addthis options in the popup and modifies the onclick event
function webTrendsAddThis() {
    var elems;
    if (document.all) {
        elems = document.all.tags("div");
    }
    else if (document.documentElement) {
        elems = document.getElementsByTagName("div");
    }
    
    if (typeof (elems) != "undefined") {
        for (var i = 0; i <= elems.length - 1; i++) {
            if (elems[i].className == "at_item") {
                if (elems[i].onclick) {
                    var params = elems[i].onclick.toString().split('(')[2].split(')')[0].split(',');
                    elems[i].clickTarget = params[0];
                    elems[i].onclick =
					function(e) {
					    mckAddThisClick(this.clickTarget);
					};
                }

                var footer = document.getElementById("at15s_foot");
                if (footer != undefined) {
                    footer.innerHTML = '<A style="color:gray;text-decoration:none" href="http://www.mckesson.com/addthis">What are these?</a><span title="AddThis.com" onclick="window.open(\'http://www.addthis.com/\',\'mckwindow\',\'height=600,width=800,status=1,toolbar=1,scrollbars=auto,resizable=1,location=1	\')"/>';
                    footer.style.display = "block";
                }

                addThisModified = true;
            }
        }
    }
}

// This function replaces the addthis_open function
function mckAddThis_Open(a, b, c, d) {
    if (addThisModified == false) {
        webTrendsAddThis();
    }

    addthis_open(a, b, c, d);
}

// This function is the replacement for the AddThis onclick event
function mckAddThisClick() {
    var argv = mckAddThisClick.arguments;
    var addThis = '';
    if (argv.length > 0) {
        addThis = argv[0].mckQuoteTrim();
    }
    var title = "Share This: ";
    var target = "http://www.mckesson.com/sharethispage/";
    if (addThis) {
        target += addThis + "/";
        title += addThis;
    }
    else {
        title += "Unspecified";
    }
    var uri = getUri(target);
    if (argv.length > 1) {
        title = argv[1];
    }
    dcsMultiTrack(
		'DCS.dcssip', uri.host,
 		'DCS.dcsuri', uri.path,
 		'DCS.dcsqry', uri.query,
 		'WT.dl', '1',
 		'WT.ti', title,
 		'WT.EvtSrc', window.location,
 		'WT.ShareThis', addThis
	);
    DCS.dcssip = DCS.dcsuri = DCS.dcsqry = WT.dl = WT.ti = WT.EvtSrc = WT.ShareThis = "";

    //Call the orginal AddThis routine
    return addthis_sendto(addThis);
}

var addThisModified = false;
webTrendsAddThis();
//END: AddThis routines