/* 
 * This JavaScript file is used to retrieve Web Trends for web pages on vanguard-education.com.
 * Each web page imports this file and calls the "runWebTrends() method.
 *
 *
 *  Example of code in HTML file:
 *  <script type='text/javascript' src='/webtrends/ekitWT.js'></script>
 *  <script type='text/javascript'>runWebTrends();</script>
 *
 */
var gDomain = 'watag.vanguard.com';
var gDcsId  = 'dcsdi7p4xn0aljrry5aby3o12_7k7t';
var wtActive = true;
var domainNameArray = document.domain.split( "." );

if (domainNameArray.length > 1) {
	if (domainNameArray[1] == "vanguard-education") {
            document.write("<script type='text/javascript' src='/webtrends/webUsage.js'></scr"+"ipt>");
	}
}

function runWebTrends(){   
    if (domainNameArray.length > 1) {    
        if (domainNameArray[1] == "vanguard-education") {    
            if (wtActive) {
                dcsVar();
                dcsMeta();
                dcsFunc("dcsAdv");
                dcsTag();
            }
        }
    }
}


/*
*
* Providing all String objects with endsWith functionality.
*
*/
String.prototype.endsWith = function(str) 
{return (this.match(str+"$")==str)}




/**
 * Updates the dcsuri with the passed uri. It also sends the current meta tags
 *
 * @param {String} uri The uri value
 * 
 * @ref see jsfunction.js cbdns.jsCBDupdateDcsUri
 */
function updateDcsUri(uri)
{
    if(wtActive) {  
        dcsMeta();
        dcsMultiTrack('DCS.dcsuri', uri);
    }
}

function logEvent(event) {
    if (wtActive) {
        uri = window.location.pathname;
	
	if(uri.endsWith("/"))
	{
		uri = uri + event;
        }
	else
	{
		uri = uri + "/" +event;
	}
	
	updateDcsUri(uri);
    }
}
