// START OF SDC Advanced Tracking Code
// Copyright (c) 1996-2008 WebTrends Inc.  All rights reserved.
// V8.0
// $DateTime: 2007/02/20 09:30:16 $

//Set a gDomain2 if you need to send the tracking to an alternate logging server as well, otherwise not.
//var gDomain2 = "70.193.143.225";
//

var gService = true;
var gTimeZone = -5;
// 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 cookies = document.cookie.split("; ");
    var cmatch = [];
    var idx = 0;
    var i = 0;
    var namelen = name.length;
    var clen = cookies.length;
    for (i = 0; i < clen; i++) {
        var c = cookies[i];
        if ((c.substring(0, namelen + 1)) == (name + "=")) {
            cmatch[idx++] = c;
        }
    }
    var cmatchCount = cmatch.length;
    if (cmatchCount > 0) {
        idx = 0;
        if ((cmatchCount > 1) && (typeof(gFpc) != "undefined") && (name == gFpc)) {
            var dLatest = new Date(0);
            for (i = 0; i < cmatchCount; i++) {
                var lv = parseInt(dcsGetCrumb(cmatch[i], "lv"));
                var dLst = new Date(lv);
                if (dLst > dLatest) {
                    dLatest.setTime(dLst.getTime());
                    idx = i;
                }
            }
        }
        return unescape(cmatch[idx].substring(namelen + 1));
    }
    else {
        return null;
    }
}

function dcsGetCrumb(cval, crumb){
    var aCookie = cval.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(cval, crumb){
    var id = cval.substring(0, cval.indexOf(":lv="));
    var aCrumb = id.split("=");
    for (var i = 0; i < aCrumb.length; i++) {
        if (crumb == aCrumb[0]) {
            return aCrumb[1];
        }
    }
    return null;
}

function dcsIsFpcSet(name, id, lv, ss){
    var c = dcsGetCookie(name);
    if (c) {
        return ((id == dcsGetIdCrumb(c, "id")) && (lv == dcsGetCrumb(c, "lv")) && (ss == dcsGetCrumb(c, "ss"))) ? 0 : 3;
    }
    return 2;
}

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 c = dcsGetCookie(name);
        var id = dcsGetIdCrumb(c, "id");
        var lv = parseInt(dcsGetCrumb(c, "lv"));
        var ss = parseInt(dcsGetCrumb(c, "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();
    var cur = dCur.getTime().toString();
    var ses = dSes.getTime().toString();
    document.cookie = name + "=" + "id=" + WT.co_f + ":lv=" + cur + ":ss=" + ses + expiry + "; path=/" + (((typeof(gFpcDom) != "undefined") && (gFpcDom != "")) ? ("; domain=" + gFpcDom) : (""));
    var rc = dcsIsFpcSet(name, WT.co_f, cur, ses);
    if (rc != 0) {
        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 = rc;
    }
}

// Add dcsOther() here if using existing first-party cookie, or dcsPlugin() here if using WT Cookie Plugin

// Code section for Use the new first-party cookie generated with this tag.
var gFpc = "WT_FPC";
var gConvert = true;
//var gFpcDom=".webtrends.com";

// Code section for Enable Event Tracking
function dcsParseSvl(sv){
    sv = sv.split(" ").join("");
    sv = sv.split("\t").join("");
    sv = sv.split("\n").join("");
    var pos = sv.toUpperCase().indexOf("WT.SVL=");
    if (pos != -1) {
        var start = pos + 8;
        var end = sv.indexOf('"', start);
        if (end == -1) {
            end = sv.indexOf("'", start);
            if (end == -1) {
                end = sv.length;
            }
        }
        return sv.substring(start, end);
    }
    return "";
}

function dcsIsHttp(e){
    return (e.href && e.protocol && (e.protocol.indexOf("http") != -1)) ? true : false;
}

var gHref = "";
function dcsSaveHref(evt){
    if (evt.preventDefault && evt.target.href) {
        evt.preventDefault();
        gHref = evt.target.href;
    }
}

function dcsLoadHref(evt){
    if (gHref.length > 0) {
        window.location = gHref;
        gHref = "";
    }
}

function dcsEvt(evt, tag){
    var e = evt.target || evt.srcElement;
    while (e.tagName && (e.tagName != tag)) {
        e = e.parentElement || e.parentNode;
    }
    return e;
}

function dcsBind(event, func){
    if ((typeof(window[func]) == "function") && document.body) {
        if (document.body.addEventListener) {
            document.body.addEventListener(event, window[func], true);
        }
        else 
            if (document.body.attachEvent) {
                document.body.attachEvent("on" + event, window[func]);
            }
    }
}

function dcsET(){
    dcsBind("click", "dcsDownload");
    dcsBind("click", "dcsDynamic");
    dcsBind("click", "dcsFormButton");
    dcsBind("click", "dcsOffsite");
    dcsBind("click", "dcsAnchor");
    dcsBind("mousedown", "dcsRightClick");
}

function dcsMultiTrack(){
    if (arguments.length % 2 == 0) {
        for (var i = 0; i < arguments.length; i += 2) {
            //alert("dmt arg " + i + "=" + arguments[i] + "=" + arguments[i+1]);
            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();
        msimRebuildDcsuri();
        if ((window.document.referrer != "") && (window.document.referrer != "-")) {
            if (!(navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) < 4)) {
                //msim.com specific function called
                msimRebuildDcsref();
            }
        }
        dcsFunc("dcsCookie");
        dcsTag();
    }
}

// Add event handlers here

// Code section for Track clicks to download links.
function dcsDownload(evt){
    evt = evt || (window.event || "");
    if (evt) {
        var e = dcsEvt(evt, "A");
        if (e.hostname && dcsIsOnsite(e.hostname)) {
            var types = "xls,doc,pdf,txt,csv,zip";
            if (types.indexOf(e.pathname.substring(e.pathname.lastIndexOf(".") + 1, e.pathname.length)) != -1) {
                var qry = e.search ? e.search.substring(e.search.indexOf("?") + 1, e.search.length) : "";
                if (qry.toUpperCase().indexOf("WT.SVL=") == -1) {
                    WT.svl = dcsParseSvl(e.name ? e.name.toString() : (e.onclick ? e.onclick.toString() : ""));
                }
                var path = e.pathname ? ((e.pathname.indexOf("/") != 0) ? "/" + e.pathname : e.pathname) : "/";
                dcsSaveHref(evt);
                dcsMultiTrack("DCS.dcssip", e.hostname, "DCS.dcsuri", path, "DCS.dcsqry", e.search || "", "WT.ti", "Download:" + (e.innerHTML || ""), "WT.dl", "1");
                DCS.dcssip = DCS.dcsuri = DCS.dcsqry = WT.ti = WT.svl = WT.dl = "";
            }
        }
    }
}

function dcsAdv(){
    dcsFunc("dcsET");
    dcsFunc("dcsCookie");
    dcsFunc("dcsAdSearch");
    dcsFunc("dcsTP");
}

// END OF SDC Advanced Tracking Code

// START OF SmartSource Data Collector TAG
// Copyright (c) 1996-2008 WebTrends Inc.  All rights reserved.
// V8.0
// $DateTime: 2007/03/05 13:33:14 $
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 = gI18n ? {
        "%25": /\%/g
    } : {
        "%09": /\t/g,
        "%20": / /g,
        "%23": /\#/g,
        "%26": /\&/g,
        "%2B": /\+/g,
        "%3F": /\?/g,
        "%5C": /\\/g,
        "%22": /\"/g,
        "%7F": /\x7F/g,
        "%A0": /\xA0/g
    };
    if (gI18n) {
        var EXRE = /dcs(uri)|(ref)|(aut)|(met)|(sta)|(sip)|(pro)|(byt)|(dat)|(p3p)|(cfg)|(redirect)|(cip)/i;
    }
}

// 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 (window.RegExp) {
            var tire = new RegExp("^" + window.location.protocol + "//" + window.location.hostname + "\\s-\\s");
            WT.ti = document.title.replace(tire, "");
        }
        else {
            WT.ti = 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 (document.all) {
        WT.bs = document.body ? document.body.offsetWidth + "x" + document.body.offsetHeight : "unknown";
    }
    else {
        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) {
        if (typeof(document.defaultCharset) == "string") {
            WT.le = document.defaultCharset;
        }
        else 
            if (typeof(document.characterSet) == "string") {
                WT.le = document.characterSet;
            }
            else {
                WT.le = "unknown";
            }
    }
    WT.tv = "8.0.3";
    //	WT.sp="@@SPLITVALUE@@";
    DCS.dcsdat = dCurrent.getTime();
    DCS.dcssip = window.location.hostname;
    DCS.dcsuri = window.location.pathname;
    //msim.com specific function called
    msimRebuildDcsuri();
    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 = window.document.referrer;
            //msim.com specific function called
            msimRebuildDcsref();
        }
    }
}

function dcsA(N, V){
    if (gI18n && !EXRE.test(N)) {
        if (N == "dcsqry") {
            var newV = "";
            var params = V.substring(1).split("&");
            for (var i = 0; i < params.length; i++) {
                var pair = params[i];
                var pos = pair.indexOf("=");
                if (pos != -1) {
                    var key = pair.substring(0, pos);
                    var val = pair.substring(pos + 1);
                    if (i != 0) {
                        newV += "&";
                    }
                    newV += key + "=" + dcsEncode(val);
                }
            }
            V = V.substring(0, 1) + newV;
        }
        else {
            V = dcsEncode(V);
        }
    }
    return "&" + N + "=" + dcsEscape(V, RE);
}

function dcsEscape(S, REL){
    if (typeof(REL) != "undefined") {
        S = S.toString();
        for (var R in REL) {
            S = S.replace(REL[R], R);
        }
        return S;
    }
    else {
        return escape(S);
    }
}

function dcsEncode(S){
    return (typeof(encodeURIComponent) == "function") ? encodeURIComponent(S) : escape(S);
}

function dcsCreateImage(dcsSrc){
    //if (WT.dl != 1) {
    //	document.write('<div id="debug_dcs" style="position: absolute; left: 0; top: 0; width: 10; height: 10; z-index: 1; visibility: visible;"></div>');
    //	document.getElementById("debug_dcs").innerHTML='<a href="javascript:dcsPrintVariables()"><img border="0" width="10" height="10" src="/msamg/msimintl/docs/en_US/images/clear.gif"/></a>';
    //}
    if (document.images) {
        gImages[gIndex] = new Image;
        if ((typeof(gHref) != "undefined") && (gHref.length > 0)) {
            gImages[gIndex].onload = gImages[gIndex].onerror = dcsLoadHref;
        }
        gImages[gIndex].src = dcsSrc;
        gIndex++;
    }
    else {
        document.write('<IMG ALT="" BORDER="0" NAME="DCSIMG" WIDTH="1" HEIGHT="1" SRC="' + dcsSrc + '">');
    }
}

function dcsMeta(){
    var elems;
    if (document.all) {
        elems = document.all.tags("meta");
    }
    else 
        if (document.documentElement) {
            elems = document.getElementsByTagName("meta");
        }
    if (typeof(elems) != "undefined") {
        var length = elems.length;
        for (var i = 0; i < length; i++) {
            var name = elems.item(i).name;
            var content = elems.item(i).content;
            var equiv = elems.item(i).httpEquiv;
            if (name.length > 0) {
                if (name.indexOf("WT.") == 0) {
                    WT[name.substring(3)] = content;
                }
                else 
                    if (name.indexOf("DCSext.") == 0) {
                        DCSext[name.substring(7)] = content;
                    }
                    else 
                        if (name.indexOf("DCS.") == 0) {
                            DCS[name.substring(4)] = content;
                        }
            }
        }
    }
}

function dcsTag(){
    // customized functions here
    msNormalizeHostNames();
    msNormalizeDefaultPageNames(); // should precede msContentDrilldown
    msimContentDrilldown();
    //msSetChildIdentifiers();
    // end of customized functions
    
    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]);
        }
    }
    var keys = ["co_f", "vt_sid", "vt_f_tlv"];
    for (var i = 0; i < keys.length; i++) {
        var key = keys[i];
        if (WT[key]) {
            P += dcsA("WT." + key, WT[key]);
            delete WT[key];
        }
    }
    for (N in WT) {
        if (WT[N]) {
            P += dcsA("WT." + N, WT[N]);
        }
    }
    for (N in DCSext) {
        if (DCSext[N]) {
            if (gI18n) {
                WT.dep = (typeof(WT.dep) == "undefined") ? N : (WT.dep + ";" + N);
            }
            P += dcsA(N, DCSext[N]);
        }
    }
    if (gI18n && (typeof(WT.dep) != "undefined")) {
        P += dcsA("WT.dep", WT.dep);
    }
    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]();
    }
}

//Morgan Stanley custom functions defined here

//site-specific custom functions below

function msNormalizeHostNames(){ //eliminate meaningless variations in host names in reports
    if (dcsIsOnsite(DCS.dcssip)) {
        DCSext.orig_dcssip = DCS.dcssip;
        if (!(DCS.dcssip == "secure-im.morganstanley.com")) {
            DCS.dcssip = "www.morganstanley.com";
        }
    }
}

function msSetChildIdentifiers(){
    if (DCS.dcsuri.indexOf('/im/uk') > -1) {
        WT.sp = 'www.morganstanley.com_im_uk';
    }
}

// msim.com specific functions
function msimRebuildDcsuri(){
    // truncate the jsessionid from the url
    if (DCS.dcsuri.indexOf(';jsessionid=') != -1) {
        var strToReplace = DCS.dcsuri.substring(DCS.dcsuri.indexOf(';jsessionid='));
        DCS.dcsuri = DCS.dcsuri.replace(strToReplace, "");
    }
    // truncate the menuitem from the url
    if (DCS.dcsuri.indexOf('/menuitem.378c428a482525fedb4598863207e009/') != -1) {
        DCS.dcsuri = DCS.dcsuri.replace(/\/menuitem.378c428a482525fedb4598863207e009\//g, "/");
    }
    // truncate the "/template.PAGE/" or "/template.SOLO/" from the url
    if (DCS.dcsuri.indexOf('/template.PAGE/') != -1 || DCS.dcsuri.indexOf('/template.SOLO/') != -1) {
        DCS.dcsuri = DCS.dcsuri.replace(/(\/template.PAGE\/|\/template.SOLO\/)/g, "/");
    }
}

function msimRebuildDcsref(){
    // truncate the jsessionid from the url
    if (DCS.dcsref.indexOf(';jsessionid=') != -1) {
        var strToReplace = DCS.dcsref.substring(DCS.dcsref.indexOf(';jsessionid='), DCS.dcsref.indexOf('?'));
        DCS.dcsref = DCS.dcsref.replace(strToReplace, "");
    }
    // truncate the menuitem from the url
    if (DCS.dcsref.indexOf('/menuitem.378c428a482525fedb4598863207e009/') != -1) {
        DCS.dcsref = DCS.dcsref.replace(/\/menuitem.378c428a482525fedb4598863207e009\//g, "/");
    }
    // truncate the "/template.PAGE/" or "/template.SOLO/" from the url
    if (DCS.dcsref.indexOf('/template.PAGE/') != -1 || DCS.dcsref.indexOf('/template.SOLO/') != -1) {
        DCS.dcsref = DCS.dcsref.replace(/(\/template.PAGE\/|\/template.SOLO\/)/g, "/");
    }
}

// End of custom site-specific functions

// site-generic custom or customized functions below:

function dcsOffsite(evt){
    evt = evt || (window.event || "");
    if (evt) {
        var e = dcsEvt(evt, "A");
        if (e.hostname && !dcsIsOnsite(e.hostname) && (e.hostname.indexOf('(') == -1)) { //exclude function calls dmillrod 081406
            var qry = e.search ? e.search.substring(e.search.indexOf("?") + 1, e.search.length) : "";
            if (qry.toUpperCase().indexOf("WT.SVL=") == -1) {
                WT.svl = dcsParseSvl(e.name ? e.name.toString() : (e.onclick ? e.onclick.toString() : ""));
            }
            var path = e.pathname ? ((e.pathname.indexOf("/") != 0) ? "/" + e.pathname : e.pathname) : "/";
            var trim = true;
            dcsSaveHref(evt);
            dcsMultiTrack("DCS.dcssip", e.hostname, "DCS.dcsuri", path, "DCS.dcsqry", trim ? "" : qry, "WT.ti", "Offsite:" + e.hostname + path + qry, "WT.os", "1");
            DCS.dcssip = DCS.dcsuri = DCS.dcsqry = WT.ti = WT.svl = WT.os = "";
        }
    }
}

function msNormalizeDefaultPageNames(){
    if (DCS.dcsuri.indexOf('index.html') != -1) {
        DCS.dcsuri = DCS.dcsuri.substring(0, DCS.dcsuri.indexOf('index.html'));
    }
}

function dcsIsOnsite(host){
    if (host == window.location.hostname) {
        return 1;
    }
    //alert("offsite: host="+host+" addr bar="+window.location.hostname);
    return 0;
}

function msContentDrilldown(){
    if ((DCS.dcsuri == '/') && (WT.os != "1")) { // home page of current site, not offsite link
        WT.cg_n = 'Home';
        DCSext.contentDrilldown = 'Home';
        DCSext.rollupContentDrilldown = DCS.dcssip + ';' + 'Home';
    }
    else {
        if (DCS.dcsuri == '/') {
            contentDrilldown = 'Home';
        }
        else {
            var contentDrilldown = DCS.dcsuri.substring(1).replace(/\//g, ';');
            // if we wound up with a trailing semi-colon remove it
            if (contentDrilldown.substring(contentDrilldown.length - 1, contentDrilldown.length) == ';') {
                contentDrilldown = contentDrilldown.substring(0, contentDrilldown.length - 1);
            }
        }
        DCSext.contentDrilldown = contentDrilldown;
        DCSext.rollupContentDrilldown = DCS.dcssip + ';' + contentDrilldown;
        WT.cg_n = DCS.dcsuri.split('/')[1];
        if (DCS.dcsuri.split('/')[2] != 'undefined') {
            WT.cg_s = DCS.dcsuri.split('/')[2];
        }
        if (WT.os == "1") { // offsite links
            WT.cg_n = "Offsite link";
            WT.cg_s = DCS.dcssip;
            DCSext.contentDrilldown = DCSext.rollupContentDrilldown;
        }
    }
}

function msimContentDrilldown(){
    if ((DCS.dcsuri == '/msim/portal/site/') && (WT.os != "1")) { // home page of current site, not offsite link
        WT.cg_n = 'Home';
        DCSext.contentDrilldown = 'Home';
        DCSext.rollupContentDrilldown = DCS.dcssip + ';' + 'Home';
    }
    else {
        if (DCS.dcsuri == '/msim/portal/site/') {
            contentDrilldown = 'Home';
        }
        else {
            var contentDrilldown = DCS.dcsuri.substring(1).replace(/\//g, ';');
            // if we wound up with a trailing semi-colon remove it
            if (contentDrilldown.substring(contentDrilldown.length - 1, contentDrilldown.length) == ';') {
                contentDrilldown = contentDrilldown.substring(0, contentDrilldown.length - 1);
            }
        }
        DCSext.contentDrilldown = contentDrilldown;
        DCSext.rollupContentDrilldown = DCS.dcssip + ';' + contentDrilldown;
        WT.cg_n = DCS.dcsuri.split('/')[4];
        if (DCS.dcsuri.split('/')[2] != 'undefined') {
            WT.cg_s = DCS.dcsuri.split('/')[5];
        }
        if (WT.os == "1") { // offsite links
            WT.cg_n = "Offsite link";
            WT.cg_s = DCS.dcssip;
            DCSext.contentDrilldown = DCSext.rollupContentDrilldown;
        }
    }
}

function dcsPrintVariables(){
    var tagVariables = "\nDomain = " + gDomain;
    tagVariables += "\nDCSId = " + gDcsId;
    for (N in DCS) {
        tagVariables += "\nDCS." + N + " = " + DCS[N];
    }
    for (N in WT) {
        tagVariables += "\nWT." + N + " = " + WT[N];
    }
    for (N in DCSext) {
        tagVariables += "\nDCSext." + N + " = " + DCSext[N];
    }
    window.alert(tagVariables);
}

//End of Morgan Stanley defined custom functions
dcsVar();
dcsMeta();
dcsFunc("dcsAdv");
dcsTag();
//dcsPrintVariables();
// END OF SmartSource Data Collector  TAG
