//Deployment Toolkit - liveManager.js v2.2.20100303, Copyright 2010 Tealium.com Inc. All Rights Reserved.
/*
    Fix to verify cdc object then cdc.util then cdc.util.ensureNamespace
    if cdc.util.ensureNamespace is not defined, one is created
*/
if (typeof(cdc) == "undefined") cdc = new Object();
if (typeof(cdc.util) == "undefined") cdc.util = new Object();
if (typeof(cdc.util.ensureNamespace) == "undefined"){
    cdc.util.ensureNamespace = function(namespaceStr) {
        if (!namespaceStr) return;
        var parts = namespaceStr.split(".");
        var o = window;
        for (var i = 0; i < parts.length; i++) {
            var aPart = parts[i];
            if (typeof(o[aPart]) != "object") {
                o[aPart] = new Object();
            }
            o = o[aPart];
        }
    }
}

/* Ensure Namespace */
cdc.util.ensureNamespace("cdc.ut.liveManager");
cdc.util.ensureNamespace("cdc.ut.trackEvent");
cdc.util.ensureNamespace("cdc.ut.eventqueue");

/* Global UT config object */
cdc.util.ensureNamespace("cdc.ut.config");
cdc.ut.config.set=function(a,b){if(typeof a=="string")cdc.ut.config[a]=b;else if(typeof a=="object"){for(b in a){if(typeof a[b]=="string")cdc.ut.config[b]=a[b]}}}


/* config overrides */
//cdc.ut.config.set({
//    rs_map_src:"//cdn.tealium.com/deployment_toolkit/cisco/v3/rs_map.js",
//    trackevent_src:"//cdn.tealium.com/deployment_toolkit/cisco/v3/trackEvent.js"
//    ntpagetag_src:"//cdn.tealium.com/deployment_toolkit/cisco/v3/ntpagetag.jsx",  
//    s_code_ut_src:"//cdn.tealium.com/deployment_toolkit/cisco/v3/s_code_ut.jsx",
//    dop_src:"//cdn.tealium.com/deployment_toolkit/cisco/v3/dop.jsx",
//    visualsciences_ut_src: "//cdn.tealium.com/deployment_toolkit/cisco/v3/visualsciences_ut.jsx"
//});


/*
 Class: cdc.ut.liveManager

 - Object cdc.ut.liveManager

 * holds configuration parameters
 * collects data from page
 * loads metric vendor libraries
 * loads trackEvent
 * tries to stop vendor code duplication 

  OVERVIEW:
  
  1 At the end of this file is a try / catch block that will run the <ONLOAD> method
    - either when the jQuery ready event happens (if jQuery is loaded)
    - or after a 3 second timeout if not.

  2 The <ONLOAD> method first checks a few details of the <.config> object if specified
    - should probably add a check to not load specific libraries if not going to be used, not just not call them
    - also ime the no-load didn't work.

  3 Then calls <A> method in set synchronous order for each other file to load
    - files are loaded by adding a script tag to the head
    - then a call back can be triggered,
    +   calls dop.INIT for dop, nothing for site catalyst
    +   when trackEvent has been loaded it calls <PT()>, then <trackEvent.INIT> (earlier calls <LOAD> I think it tracks if it's been loaded, anything else???)
    +   and then sends a "view" event to <trackEvent.event> sending the params in liveManager.

  4 <PT> parses the page
    - saves all meta tag info,
    - parses hinav and/or treecrumb if present and uses that for sitearea info if so,
    - also has ability to save and pass thru arbitrary name/values in a track object if one is found in the page.
       (Cisco is currently not using this as we're trying to avoid things that require page level content changes, but the capability apparently exists.)

  5 <trackEvent.INIT> steps through the "plugins" in order and runs their _I methods if they have any commands in them (most don't)
    - then it runs any events that have been stored in a livemanager queue  (if any).

  6 plugins are an array of pl[#] object (members of trackEvent)  _I methods <trackEvent.pl[]>
    - currently only <trackEvent.pl[3]> has an _I method... it uses this to attach a mousedown listener to the window and it tracks BAM impressions if applicable. 

 see OVERVIEW section in LiveManager for what happens when initial "view" or other event is triggered.
*/
/*
 Properties: initial group declaration
    q{} -  temporary queue object for trackEvent object calls made before the trackEvent library is loaded.
    l[] -  the list of synchronous libraries to be loaded. This is built in cdc.ut.liveManager.A. The push order of this array is the order they will be initialized.
    f{} - this is used to make sure cdc.ut.liveManager.LOAD only runs once per library.
    p - counter to store the number of libraries loaded synchronously.
    o - onload flag for the individual loaded synchronous libraries.
    ol - onload flag for liveManager to ensure the onload is called only once. We attach to the window onload and also set a 3 second timeout for loading in case the window onload is never triggered.
    i - utility image object for sending immediate tracking from liveManager directly.
*/

cdc.ut.liveManager = {
    q: {},
    l: [],
    f: {},
    p: 0,
    o: 0,
    ol: 0,
    i: new Image(),
    
/*
  Method: A

  Description:
    A is the dom injection routine for creating a new script element in the head of the document

 Sample Usage:
 (notice only one param passed in, it is a json object with 5 members)
>    cdc.ut.liveManager.A({a:"dop",
>          b:"//cdn.tealium.com/deployment_toolkit/cisco/v2/release/dop.js?v="+cdc.ut.liveManager.t["tag"],
>          c:1,
>          d:"cdc.ut.liveManager.dop.INIT()",
>          e:"cdc.ut.liveManager.dop.ONLOAD()"});

  Params:
  a - object type, attributes {
    a.a - namespace,
    a.b - uri location to JS file,
    a.c - synchronous flag(0-async, 1-sync),
    a.d - code to be evaluated in <LOAD> when the script element is loaded. Each synchronous file loaded should have a <LOAD> trigger calling back to cdc.ut.liveManager with the appropriate namespace value. Only called in synchronous mode.
    a.e - code to be evaluated when the script element is created. 
  }

 Additional Variables Used:
  b - alias to the document object
  c - id value for the script element created as "Lm_" concatenated with the namespace value
  d - script element object added via dom addition to the HEAD of the document

*/
    A: function(a, b, c, d) {
        if (a.c) this.l.push(a);
        b = document;
        if (b.createElement) {
            c = "Lm_" + a.a;
            if (!b.getElementById(c)) {
                try {
                    eval(a.e)
                } catch(e) {};
                d = b.createElement('script');
                d.language = 'javascript';
                d.type = 'text/javascript';
                d.src = a.b;
                d.id = c;
                b.getElementsByTagName("head")[0].appendChild(d)
            }
        }
    },

/*
 Method: LOAD
 
 Description:
    When <A()> loads a library synchronously, its parameter a.d is a callback that triggers this function.
 
 Sample Usage:
>    try{cdc.ut.liveManager.LOAD("MYLIB")}catch(e){}
 
 Params:
  a - namespace of the library to load
 
 Additional Variables Used:
  b - utility variable - load counter
  c - utility variable - length of the cdc.ut.liveManager.load array (cdc.ut.liveManager.l) 
  d - utility variable - reference to object passed in the cdc.ut.liveManager.A call
*/
    
    LOAD: function(a, b, c, d) {
        this.f[a] = 0;
        c = this.l.length;
        for (b = this.p; b < c; b++) {
            d = this.l[b];
            if (this.f[d.a] == 0) {
                this.f[d.a] = ++this.p;
                try {
                    eval(d.d);
                } catch(e) {}
            } else return;
        }
        if (this.p == c && this.o == 0) this.o = 1
    },

/*
 Method: EV
 
 Description:
 Utility addEventListener / attachEvent function.
 -   The prefix "on" for Internet Explorer attachEvent handling is explicitly added.
 
 Sample Usage:
 >   cdc.ut.liveManager.EV("window","load",myLoadFunction)

 Params:
  a - event object
  b - event name
  c - event handler
  d - flag if set to 1 will not prefix the "on" substring to the event name. This is used for any event to attach to that does not start with the prefix "on"
 
*/    
    
    EV: function(a, b, c, d) {
        if (a.addEventListener) {
            a.addEventListener(b, c, false)
        } else if (a.attachEvent) {
            a.attachEvent(((d == 1) ? "": "on") + b, c)
        }
    }
}

/*
 Property: config 
 
 Description:
  *main configuration variable*, sets defaults that can be overridden in page markup
 - dop_ is for visual science parameters
 - sc_ is for site catalyst parameters

*/
cdc.ut.liveManager.config = {
    domain: ".cisco.com",
    exit_domain: "cisco.com",
    dop_sensor: "//www.cisco.com/web/fw/tools/mktg_metrics/flashtag.txt?Log=1",
    ntpagetag_sensor: "//cisco-tags-dev.cisco.com/tag/ntpagetag.gif",
    ntpagetag_sensor_secure: "//cisco-tags-dev.cisco.com/tag/ntpagetag.gif",
    passthru: true,
    sc_acct: "cisco-us",
    sc_test: false,
    sc_testaccount: "cisco-dev",
    preview: false,
  	dop_src: "//www.cisco.com/web/fw/tools/mktg_metrics/dop.js",
    s_code_ut_src: "//www.cisco.com/web/fw/tools/mktg_metrics/s_code_ut.js",
    s_code_src: "//www.cisco.com/web/fw/tools/mktg_metrics/s_code.js",
    trackevent_src: "//www.cisco.com/web/fw/tools/mktg_metrics/trackEvent.js",
    visualsciences_ut_src: "//www.cisco.com/web/fw/tools/mktg_metrics/visualsciences_ut.js",
    rs_map_src: "//www.cisco.com/web/fw/tools/mktg_metrics/rs_map.js",
    // NOTE: ntpagetag is not yet active, the loading of it is commented out in this version still
    ntpagetag_src: "//www.cisco.com/web/fw/m/ntpagetag.js",
    dev_domain: ["ecmx-wip", "ecmx-staging", "ecmx-active", "wwwin-tools-stage", "cco-rtp-1", "dev-stage", "tools-stage", "wwwin-tools-dev", "preview", "cco-stage", "ecmx-wip-stage"],
    send: {
        dop: true,
        s_code: true,
        tnt: true,
        ntpagetag: false
    }
}

/*
  Property: lh - Runtime init code (not in function)
  
  Description:
  Adds some values to <config> based on location.hostname 
*/
cdc.ut.liveManager.lh = location.hostname;
for (cdc.ut.liveManager.i = 0; cdc.ut.liveManager.i < cdc.ut.liveManager.config["dev_domain"].length; cdc.ut.liveManager.i++) {
    if (cdc.ut.liveManager.lh.indexOf(cdc.ut.liveManager.config["dev_domain"][cdc.ut.liveManager.i]) == 0) {
        cdc.ut.liveManager.config.preview = true;
        cdc.ut.liveManager.config.dop_sensor = "//preview.cisco.com/web/fw/tools/mktg_metrics/flashtag.txt?Log=1";
        for(var i in cdc.ut.liveManager.config){
            var j=cdc.ut.liveManager.config[i];
            if(typeof j=="string"&&i.indexOf("_src")>0){
                cdc.ut.liveManager.config[i]=j.replace("www.","preview.");
            }
        }
        break;
    }
}

/*
   Object: cdc.ut.trackEvent

    Description:   
    Creates the trackEvent.event queue
   - for handling <trackEvent.event> calls that come before the trackEvent library is loaded
   - called any time trackEvent is called before the onLoad event
   - uses .t["tag"] which is ut code version id for result sniffing purposes
*/
if(typeof cdc.ut.eventqueue.q=="undefined")cdc.ut.eventqueue.q=[];

cdc.ut.trackEvent = {
    event: function(a, b) {
        var d="";
        for(var c in b){
            d+="&"+c+"="+b[c];
        }
        b["tag"]=cdc.ut.liveManager.t["tag"];

        cdc.ut.eventqueue.q.push({a:a,b:b});
    }
};

//FIX flash coded videos to reference cdc.ut.trackEvent instead of trackEvent. this is a timing issue that needs to be handled carefully
/* this line is used for backwards compatibility with flash tracking that tries to access the trackEvent object directly */
var trackEvent = cdc.ut.trackEvent;

/*
  Procedure: Stripping subdomains (code block not a function).

  Description:
  used to strip certain subdomains from the basepage dimension, used in setting t.basepage value

*/
cdc.ut.liveManager.t1 = location.hostname + location.pathname;
cdc.ut.liveManager.t2 = new Array('www.', 'ecmx-wip.', 'ecmx-staging.', 'ecmx-active.', 'wwwin-tools-stage.', 'cco-rtp-1.', 'dev-stage.', 'tools-stage.', 'wwwin-tools-dev.');
for (cdc.ut.liveManager.i = 0; cdc.ut.liveManager.i < cdc.ut.liveManager.t2.length; cdc.ut.liveManager.i++) cdc.ut.liveManager.t1 = cdc.ut.liveManager.t1.replace(cdc.ut.liveManager.t2[cdc.ut.liveManager.i], '');
if (cdc.ut.liveManager.t1.lastIndexOf('/') == cdc.ut.liveManager.t1.length - 1) cdc.ut.liveManager.t1 = cdc.ut.liveManager.t1.substring(0, cdc.ut.liveManager.t1.length - 1);

/*
  Properties: t

  Description:
  *holds main page tracking variables*
  These are set as defaults
    basepage - derived from url
    property - "Cisco"
    tag - ut version number
    title - document.title
    url - document.URL
    referrer - eval("document."+"referrer")
    linktrack - "linkpage"
    elementtype - "page"

    plus others as the page is processed
    
    Examples:
    http://cdc-site-dev.cisco.com:2012/en/US/products/sw/voicesw/index.html#~solutions	

- basepage: "cdc-site-dev.cisco.com/en/US/products/sw/voicesw/index.html",
- elementtype: "page",
- linktrack: "linkpage",
- loc: "http://cdc-site-dev.cisco.com/en/US/products/sw/voicesw/index.html",
- prevpage: "cdc-site-dev.cisco.com/en/US/products/sw/voicesw/index.html",
- property: "Cisco",
- referrer: "",
- tag: "ut2.2.20091108.1200",
- title: "Voice and Unified Communications - Products & Services - Cisco Systems",
- url: "http://cdc-site-dev.cisco.com:2012/en/US/products/sw/voicesw/index.html#~solutions"
	
	
http://cdc-site-dev:2012/web/learning/index.html

- basepage: "cdc-site-dev/web/learning/index.html",
- d_h1: "learning_and_events",
- d_h2: "learning_and_events",
- d_h3: "learning_and_events",
- d_h4: "learning_and_events",
- d_h5: "learning_and_events",
- d_lc: "-",
- elementtype: "page",
- linktrack: "linkpage",
- loc: "http://cdc-site-dev/web/learning/index.html",
- meta.accesslevel: "guest",
- meta.content-type: "text/html;charset=iso-8859-1",
- meta.doctype: "",
- meta.iapath: "learning_and_events",
- meta.title: "training & events",
- prevpage: "",
- property: "Cisco",
- referrer: "",
- repeat: "Repeat",
- sa_source: "meta.iapath",
- site: "learning_and_events",
- sitearea: "learning_and_events",
- suite: "cisco-us",
- tag: "ut2.2.20091108.12000.2943285418142628",
- title: "Training & Events - Cisco Systems",
- treecrumb: "",
- url: "http://cdc-site-dev:2012/web/learning/index.html",
- vid: ""
	
http://cdc-site-dev:2012/web/learning/le3/le2/le37/le5/learning_certification_type_home.html 

- basepage: "cdc-site-dev/web/learning/le3/le2/le37/le5/learning_certification_type_home.html",
- d_h1: "learning_and_events/career_certifications_and_paths/professional/ccdp",
- d_h2: "learning_and_events",
- d_h3: "learning_and_events/career_certifications_and_paths",
- d_h4: "learning_and_events/career_certifications_and_paths/professional",
- d_h5: "learning_and_events/career_certifications_and_paths/professional/ccdp",
- d_lc: "-",
- elementtype: "page",
- linktrack: "linkpage",
- loc: "http://cdc-site-dev/web/learning/le3/le2/le37/le5/learning_certification_type_home.html",
- meta.accesslevel: "guest",
- meta.content-type: "text/html;charset=iso-8859-1",
- meta.doctype: "",
- meta.iapath: "learning_and_events/career_certifications_and_paths/professional/ccdp",
- meta.title: "ccdp - career certifications & paths",
- prevpage: "",
- property: "Cisco",
- referrer: "http://cdc-site-dev:2012/web/learning/index.html",
- repeat: "Repeat",
- sa_source: "meta.iapath",
- site: "learning_and_events",
- sitearea: "learning_and_events#career_certifications_and_paths#professional#ccdp",
- suite: "cisco-us",
- tag: "ut2.2.20091108.12000.953805563408346",
- title: "CCDP - Career Certifications & Paths - Cisco Systems",
- treecrumb: "",
- url: "http://cdc-site-dev:2012/web/learning/le3/le2/le37/le5/learning_certification_type_home.html",
- vid: ""
	

http://cdc-site-dev:2012/en/US/products/ps6746/Products_Sub_Category_Home.html 

- basepage: "cdc-site-dev/en/US/products/ps6746/Products_Sub_Category_Home.html",
- d_h1: "products/cisco products/switches/blade switches",
- d_h2: "products",
- d_h3: "products/cisco products",
- d_h4: "products/cisco products/switches",
- d_h5: "products/cisco products/switches/blade switches",
- d_lc: "-",
- elementtype: "page",
- linktrack: "linkpage",
- loc: "http://cdc-site-dev/en/US/products/ps6746/Products_Sub_Category_Home.html",
- meta.accesslevel: "guest",
- meta.concept: 	"blade switches",
- meta.contenttype: "cisco.com#us#presales",
- meta.country: "us",
- meta.doctype: "products sub category home",
- meta.iapath: "products/cisco products/switches/blade switches",
- meta.language: "en",
- meta.locale: "us",
- meta.title: "blade switches",
- prevpage: "",
- property: "Cisco",
- referrer: "http://cdc-site-dev:2012/en/US/products/index.html",
- repeat: "Repeat",
- sa_source: "meta.iapath",
- site: "products",
- sitearea: "cisco.com#products#cisco products#switches#blade switches",
- suite: "cisco-us",
- tag: "ut2.2.20091108.12000.9875304662415347",
- title: "Blade Switches - Cisco Systems",
- treecrumb: "",
- url: "http://cdc-site-dev:2012/en/US/products/ps6746/Products_Sub_Category_Home.html",
- us: 1,
- vid: ""
	
	
+ http://cdc-site-dev:2012/cisco/web/solutions/small_business/index.html	
	
- basepage: "cdc-site-dev/cisco/web/solutions/small_business/index.html",
- elementtype: "page",
- linktrack: "linkpage",
- loc: "http://cdc-site-dev/cisco/web/solutions/small_business/index.html",
- prevpage: "",
- property: "Cisco",
- referrer: "http://cdc-site-dev:2012/en/US/hmpgs/index.html",
- tag: "ut2.2.20091108.1200",
- title: "Small Business - Cisco Systems",
- url: "http://cdc-site-dev:2012/cisco/web/solutions/small_business/index.html"
    
   
*/
cdc.ut.liveManager.t = {
    //base variables
    basepage: cdc.ut.liveManager.t1,
    property: "Cisco",
    tag: "ut2.2.2010211.0000",
    title: document.title,
    url: document.URL,
    referrer: eval("document." + "referrer"),
    linktrack: "linkpage",
    elementtype: "page"
};
cdc.ut.liveManager.t["loc"] = "http://" + cdc.ut.liveManager.t["basepage"];

/*
  Method: RCV
  
  Description:
  read prev page cookie
  
  Params:
  a - cookie name
  b,c,d - utility variables

*/
cdc.ut.liveManager.RCV = function(a, b, c, d) {
    b = document.cookie;
    c = b.indexOf(a + "=");
    d = "";
    if (c > -1) {
        d = b.indexOf(";", c + 1);
        d = (d > 0) ? d: b.length;
        d = (d > c) ? b.substring(c + a.length + 1, d) : ""
    }
    return d
};
cdc.ut.liveManager.t["prevpage"] = cdc.ut.liveManager.RCV("s_prev");

/*
  Procedure: Referring site tracking function called in line.

  Description:
  If a name-value pair for referring_site, position, campaign, keyword, creative or country is in this page's URL querystring, this lets visual sciences know.
  The check for existence of "referring_site" is case insensitive.
  
  Additional Variables Used:
  v - list of variables to check for
  s - the search string
  a,b,d - utility variables
  c - 1st life as utility variable, reincarnated as the tag sent to VS
*/
cdc.ut.liveManager.presend=function(){
    try {
        var v = ["referring_site", "position", "campaign", "keyword", "creative", "country"],
            s = location.search.toLowerCase(),
            a,
            b,
            c,
            d;
        for(a=0;a<v.length;a++){
            if(s.indexOf(v[a])>0){                
                a = s.substring(1).split('&');
                b={};
                for (d = 0; d < a.length; d++) {
                    c = a[d].split("=");
                    b[c[0]] = unescape(c[1])
                }
                c = cdc.ut.liveManager.config.dop_sensor + "&tag=" + cdc.ut.liveManager.t["tag"] + "&vs_basepage=" + escape(document.URL) + "&vs_elementtype=page&vs_event=campaign";
                for (d = 0; d < v.length; d++) {
                    if (typeof b[v[d]] != "undefined") c += "&" + v[d] + "=" + escape(b[v[d]])
                }
                cdc.ut.liveManager.i=new Image();
                cdc.ut.liveManager.i.src = c    
                break;
            }
        }
    } catch(e) {}    
}

if (typeof lm_libloadedflag == "undefined") {
    cdc.ut.liveManager.presend();
}

/*
 Method: ONLOAD
 
 Description:
 *Main ONLOAD handler of liveManager.*
 - *This queues the cdc.ut.liveManager.A calls*
 - Ensures we load the libraries after the document body is loaded,
 - The supporting libraries are loaded when this handler is invoked.

 Notes:
 - Avoids repeat loading of Site Catalyst code
 - If there is already the instance of an s_account variable (SiteCatalyst) the s_code_ut.js is not loaded and the s_code send flag is set to false to allow the existing implementation to handle the SiteCatalyst tracking.

 Sample Usage:
 > cdc.ut.liveManager.ONLOAD()
 
 Params: None
 
 Additional Variables Used:
 - a,b,c - utility variables.
 - cdc.ut.liveManager.ol - onload flag used to ensure the cdc.ut.liveManager.ONLOAD handler is loaded only once
 */
cdc.ut.liveManager.ONLOAD = function() {
    /* cdc.ut.config overrides */
    if(typeof cdc.ut.config!="undefined"){
        for(a in cdc.ut.config){
            if(typeof cdc.ut.config[a]=="string"&&typeof cdc.ut.liveManager.config[a]!="undefined"){
                cdc.ut.liveManager.config[a]=cdc.ut.config[a];                
            }
        }
        
        if(typeof cdc.ut.config["tag"]!="undefined")cdc.ut.liveManager.t["tag"]=cdc.ut.config["tag"];
        if(typeof cdc.ut.config["noload"]!="undefined"&&(cdc.ut.config["noload"]=="true"||cdc.ut.config["noload"]==true))cdc.ut.liveManager.ol=1;        
    }
    
    /* ensure liveManager only loads the onload directives only once */
    if (cdc.ut.liveManager.ol == 1) return;
    cdc.ut.liveManager.ol = 1;

    /* load rs_map support */
    cdc.ut.liveManager.A({
        a: "rs_map",
        b: cdc.ut.liveManager.config["rs_map_src"]+"?v=" + cdc.ut.liveManager.t["tag"],
        c: 0
    });

    /* load legacy visualsciences support */
    cdc.ut.liveManager.A({
        a: "vs",
        b: cdc.ut.liveManager.config["visualsciences_ut_src"]+"?v="+cdc.ut.liveManager.t["tag"],
        c: 1
    });
    
    /* load new visualsciences support */
    cdc.ut.liveManager.A({
        a: "dop",
        b: cdc.ut.liveManager.config["dop_src"]+"?v=" + cdc.ut.liveManager.t["tag"],
        c: 1,
        d: "cdc.ut.liveManager.dop.INIT()"
    });
    
    /* load sitecatalyst support - if s_code.js is already loaded on the page, do not load again */
    if (typeof s_account == "undefined"){
        var src=cdc.ut.liveManager.config["s_code_ut_src"];
    /* use s_code_ut_src as default, but if from one of below theaters use s_code_src instead */
        var lp=(""+location.pathname).toLowerCase();
        var m=(new RegExp(/\/web\/\w{2}\//)).exec(lp);
        if((m!=null&&m.indexOf("/web/us/")==-1)
//           ||lp.indexOf("/jp/")==0
//           ||lp.indexOf("/japanese/warp")==0
//           ||lp.indexOf("/web/europe")==0
//           ||lp.indexOf("/web/apac")==0
//           ||lp.indexOf("/web/emerging")==0
           )src=cdc.ut.liveManager.config["s_code_src"];
        
        cdc.ut.liveManager.A({
            a: "s_code",
            b: src+"?v=" + cdc.ut.liveManager.t["tag"],
            c: 1
        });
    }else{
        /* set the following flag to false when testing with no data to be sent to sitecatalyst */
        cdc.ut.liveManager.config.send["s_code"] = false;        
    }

    /* load ntpagetag support */
    /*
    cdc.ut.liveManager.A({
        a: "ntpagetag",
        b: cdc.ut.liveManager.config["ntpagetag_src"]+"?v=" + cdc.ut.liveManager.t["tag"],
        c: 1,
        d: "",
        e: "NTPT_NOINITIALTAG='true'"
    });
    */
    
    /* load trackEvent support */
    cdc.ut.liveManager.A({
        a: "trackEvent",
        b: cdc.ut.liveManager.config["trackevent_src"]+"?v=" + cdc.ut.liveManager.t["tag"],
        c: 1,
        d: "cdc.ut.liveManager.PT();cdc.ut.trackEvent.INIT();cdc.ut.trackEvent.event('view',cdc.ut.liveManager.t)"
    });

    /* BazaarVoice Integration Functionality - ratingsDisplayed callback */
    ratingsDisplayed = function(totalReviewCount, avgRating, totalRatingOnlyCount, buyAgainPercentage) {
        if (totalReviewCount > 0 || totalRatingOnlyCount > 0) {
            cdc.ut.trackEvent.event("custom", {
                bv_event: "bv_ratingdisplayed",
                bv_reviewcount: totalReviewCount,
                bv_avgrating: avgRating,
                bv_rating_only: totalRatingOnlyCount,
                bv_buyagain: buyAgainPercentage
            });
        }
    }

    /* BazaarVoice Integration Functionality - pageChanged callback */
    pageChanged = function(pageName, pageStatus) {
        cdc.ut.trackEvent.event("custom", {
            bv_event: "bv_pagechanged",
            bv_page: pageName,
            bv_status: pageStatus
        });
    }

}

/*
 Method: ONERROR

 Description:
 custom error handler
    - adds value of error message to cdc.ut.liveManager.error,
    - sets cdc.ut.liveManager.erf flag to guarantee only first error processed
    - this function is then attachaed to the window.error handler
    -  not sure why needed???
    
 Sample Usage:
    This is triggered if there is an error. Does nothing if it's been called already.

 Params:
  a - error string object
  b - url of the invoking error
  c - error line number
 
 Additional Variables Used:
  cdc.ut.liveManager.erf - error flag
  cdc.ut.liveManager.error - error message
*/
cdc.ut.liveManager.ONERROR = function(a, b, c) {
    if (cdc.ut.liveManager.erf != 1) {
        cdc.ut.liveManager.error = (typeof a == "string") ? (a + "-" + c) : "Unknown";
        cdc.ut.liveManager.erf = 1
    }
}

/* Attach cdc.ut.liveManager.ONERROR to the window.error event */
cdc.ut.liveManager.EV(window, "error", cdc.ut.liveManager.ONERROR);

/*
  Method: PT

  Description:
  Analyzes page data to find site area and more and stores them in <t>
  
  Details:
  - collects data from meta tags that aren't in the ignore list (ignores description, keywords, date, pubdate, pushdate, docRequest, synonym)
  - looks for site area in hinav
  - looks for site area in treecrumb
  - if an object called track is in page the info is caputred here
  - uses site area from meta.iapath if present, then hinav or treecrumb if no iapath and these exist, records which was used.
  
  Sample Usage:
    This is called by the <A> call that loads trackEvent.js 

  Params:
  None

  Additional Variables Used:
  a,b,c,d,e,f,g  - are all local utility variables
*/
cdc.ut.liveManager.PT = function(a, b, c, d, e, f, g) {
    /* Meta data variables to be read and loaded into the cdc.ut.liveManager.t object. Meta data keys that exist in the ex object are ignored */    
    var ex = {
        description: 1,
        keywords: 1,
        date: 1,
        pubdate: 1,
        pushdate: 1,
        docRequest: 1,
        synonym: 1
    }
    a = document.getElementsByTagName("meta");
    for (b = 0; b < a.length; b++) {
        if (a[b].name && a[b].name != "" && typeof ex[a[b].name] == "undefined") {
            cdc.ut.liveManager.t["meta." + a[b].name.toLowerCase()] = a[b].content.toLowerCase()
        }
    }

    /* Dom parsing for the hinav value. The parsed value is added to the cdc.ut.liveManager.t["hinav"] attribute */
    a = document.getElementsByTagName("div");
    b = [];
    for (c = 0; c < a.length; c++) {
        if (a[c].className == "hinav") {
            d = a[c].innerHTML;
            e = d.split("<a");
            for (f = 0; f < e.length; f++) {
                if (e[f].indexOf('class="parent"') > -1) b.push(e[f]);
                else if (e[f].indexOf('class="selected"') > -1) b.push(e[f])
            }
            d = [];
            for (e = 0; e < b.length; e++) {
                b[e] = (b[e].split("&amp;")).join("&");
                b[e] = b[e].toLowerCase();
                f = b[e].indexOf(">");
                g = b[e].indexOf("<", f);
                d.push(b[e].substring(f + 1, g))
            }
            cdc.ut.liveManager.t["hinav"] = d.join("/");
            break
        }
    }

    /* Dom parsing for the nav-treecrumb value. The parsed value is added to the cdc.ut.liveManager.t["treecrumb"] attribute */
    if (typeof document.getElementById("nav-treecrumb") != "undefined") {
        a = document.getElementsByTagName("li");
        b = [];
        for (c = 0; c < a.length; c++) {
            d = a[c].className;
            e = a[c].parentNode.id;
            if (e == "nav-treecrumb") {
                e = a[c].innerHTML;
                f = e.indexOf('>');
                g = e.indexOf('<', f);
                e = e.substring(f + 1, g);
                b.push((e.split("&amp;")).join("&"))
            }
            if (d == "crumb-selected") break
        }
        cdc.ut.liveManager.t["treecrumb"] = b.join("/")
    }

    /* Page level variables (not currently used). If an object named track exists on the page, its attributes will be read and added to the cdc.ut.liveManager.t object */
    if (typeof track != "undefined") {
        for (a in track) {
            if (typeof a != "function") cdc.ut.liveManager.t[a] = track[a]
        }
    }

    /* Sets the sitearea and sa_source values off either the meta.iapath, hinav or treecrumb values. This is used for measurement to determine which pages have an iapath. For those that don't they will be categorized by either the hinav or treecrumb value in that order. */
    e = ["meta.iapath", "hinav", "treecrumb"];
    for (f = 0; f < e.length; e++) {
        if (typeof cdc.ut.liveManager.t[e[f]] != "undefined") {
            cdc.ut.liveManager.t["sitearea"] = cdc.ut.liveManager.t[e[f]];
            cdc.ut.liveManager.t["sa_source"] = e[f];
            break
        }
    }

    //livePerson keycode reader    
    if(typeof lpMTagConfig!="undefined"&&typeof lpMTagConfig.sessionVar!="undefined"){
	lpMTagConfig.sessionVarBackup=new Array();
        lpMTagConfig.sessionVarBackup=lpMTagConfig.sessionVar;
    }
}

/*
  Method: RS_MAP

  Description:
  Analyzes the content in the rs_map.js file to determine SiteCatalyst Report Suite Values <t>
  
  Details:
  - reads data from the ut_rs_map variable declared in the rs_map.js
  - looks for filter match in the url which matches to a SiteCatalyst report suites or an "exclude" directive
  
  Sample Usage:
    This is called by trackEvent.js during the plugin that determines SiteCatalyst report suite 

  Params:
  None

  Additional Variables Used:
  a,b - are all local utility variables
*/
cdc.ut.liveManager.RS_MAP = function(a, b) {
    if (typeof ut_rs_map != "undefined") {
        a = document.URL;
        for (b in ut_rs_map) {
            if (typeof ut_rs_map[b] == "string") {
                if (a.indexOf(b) > -1) return ut_rs_map[b];
            }
        }
    }
    return "";
}

/*
 Code Block: Calling cdc.ut.liveManager.ONLOAD 
 - Try to call the cdc.ut.liveManager.ONLOAD handler when the jQuery document.ready is invoked.
 - If the handler fails, catch the error and attach to the window.load event, and also set a 3 second timeout to call cdc.ut.liveManager.ONLOAD.
 - These two are used to guarantee the cdc.ut.liveManager.ONLOAD function is invoked. 
*/
try {
    jQuery(document).ready(function() {
        cdc.ut.liveManager.ONLOAD();
    })
} catch(e) {
    cdc.ut.liveManager.EV(window, "load", cdc.ut.liveManager.ONLOAD);
    setTimeout("cdc.ut.liveManager.ONLOAD", 3000);
}
var lm_libloadedflag = 1;

/*
  Method: DB
  
 Description:
    debug script that creates a pixel request containing a debug message

 Sample Usage:
> cdc.ut.liveManager.DB("my debug message");

 Params:
  a - incoming debug message

 Variables:
  i - local utility image object
*/
cdc.ut.liveManager.DB = function(a, i) {
    i = new Image();
    i.src = "//cdn.tealium.com/track.gif?tag=ut2.0&msg=" + a
}