var gService = true;
var gTimeZone = -5;
var gDomain="statse.webtrendslive.com";
var gDcsId="dcs1lh0aif9xjyop7fqv7rnoc_8w8t";


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 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;
}

// 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 dcsIsOnsite(host){
//	var doms="thecoca-colacompany.com,virtualvender.coca-cola.com,peopleclick.com,questions.coca-cola.com,www2.coca-cola.com,mfile.akamai.com";
	var doms="thecoca-colacompany.com";
    var aDoms=doms.split(',');
    for (var i=0;i<aDoms.length;i++){
		if (host.indexOf(aDoms[i])!=-1){
		       return 1;
		}
    }
    return 0;
}

function dcsIsHttp(e){
	return (e.href&&e.protocol&&(e.protocol.indexOf("http")!=-1))?true:false;
}

var gHref="";
var gTarget="";
function dcsSaveHref(evt){
	if (evt.preventDefault&&evt.target.href){
		evt.preventDefault();
		gHref=evt.target.href;
		gTarget=evt.target.target;
	}
}
function dcsLoadHref(evt){
	if (gHref.length>0) {
		if (gTarget.length>0){
				window.open(gHref,gTarget);
				gHref="";
				gTarget="";
		}
	else {
		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","dcsFormButtonDownloads");
	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){
			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();
	}
}

// Add event handlers here
// Code section for Track clicks to links leading offsite.

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);
			if (typeof(DCSext.content_drilldown)!="undefined"){
				DCSext.content_drilldown = DCSext.content_drilldown + "_" + e.hostname+path;
			}
			dcsMultiTrack("DCS.dcssip",e.hostname,"DCS.dcsuri",path,"DCS.dcsqry",trim?"":qry,"WT.ti","Offsite:"+e.hostname+path,"WT.os","1","DCSext.eventType","Offsite Link");
			DCS.dcssip=DCS.dcsuri=DCS.dcsqry=WT.ti=WT.svl=WT.os="";
		}
	}
}

// Code section for Generate an Ad View query parameter for every Ad Click link. For examples, see Help.
function dcsAdSearch(){
	if (document.links){
		for (var i=0;i<document.links.length;i++){
			var anch=document.links[i].href+"";
			var pos=anch.toUpperCase().indexOf("WT.AC=");
			if (pos!=-1){
				var start=pos+6;
				var end=anch.indexOf("&",start);
				var value=anch.substring(start,(end!=-1)?end:anch.length);
				WT.ad=WT.ad?(WT.ad+";"+value):value;
			}
		}
	}
}

// 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,exe,mp3,jpg,gif,asx";
			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):"/";
				var ttl="";
				var text=document.all?e.innerText:e.text;
				var img=dcsEvt(evt,"IMG");
				if (img.alt){
					ttl=img.alt;
				}
				else if (text){
					ttl=text;
				}
				else if (e.innerHTML){
					ttl=e.innerHTML;
				}

				dcsSaveHref(evt);
				if (typeof(DCSext.content_drilldown)!="undefined"){
					DCSext.content_drilldown = DCSext.content_drilldown + "_" + ttl;
				}
				dcsMultiTrack("DCS.dcssip",e.hostname,"DCS.dcsuri",path,"DCS.dcsqry",e.search||"","WT.ti","Download:"+ttl,"WT.dl","1","DCSext.eventType","Download");
				DCS.dcssip=DCS.dcsuri=DCS.dcsqry=WT.ti=WT.svl=WT.dl="";
			}
		}
	}
}

// Code section for Track form button clicks that are downloads to suppliment dcsDownload().
function dcsFormButtonDownloads(evt){
	evt=evt||(window.event||"");
	if (evt){
		var e=dcsEvt(evt,"INPUT");
		var type=e.type||"";
		if (type&&((type=="submit"))){		/*dmillrod ignoring events other than submit for now */
			var types="xls,doc,pdf,txt,csv,zip,exe";
			if (types.indexOf(e.form.action.substring(e.form.action.lastIndexOf(".")+1,e.form.action.length))!=-1){
				var qry="";
				var elems=e.form.elements;
				for (var i=0;i<elems.length;i++){
					var etype=elems[i].type;
					if ((etype=="text")||(etype=="textarea")||(etype=="hidden")||(etype=="select-one")){
						qry+=((qry=="")?"":"&")+escape(elems[i].name)+"="+escape(elems[i].value);
					}
				}
				if (evt.preventDefault&&e.form.action){
					evt.preventDefault();
					gHref=e.form.action;
				}
				var title="Download:"+ e.form.action;
				dcsMultiTrack("DCS.dcsuri",e.form.action,"DCS.dcsqry",qry,"WT.ti",title,"WT.dl","1","DCSext.eventType","Download");
				DCS.dcsuri=DCS.dcsqry=WT.svl=WT.ti=WT.fb="";
			}
		}
	}
}



function dcsAdv(){
	dcsFunc("dcsET");
	dcsFunc("dcsAdSearch");
	dcsFunc("dcsTP");
}

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};
}

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){
		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");
		if (document.body.connectionType){
			WT.ct=document.body.connectionType;
		}
		document.body.addBehavior("#default#homePage");
		//WT.hp=document.body.isHomePage(location.href)?"1":"0";
	}
	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.0";
	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 (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;
		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"){
		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(){
	contentDrilldown();
	initialCG();
	if (document.cookie.indexOf("WTLOPTOUT=")!=-1){
		return;
	}
	var P="http"+(window.location.protocol.indexOf('https:')==0?'s':'')+"://"+gDomain+(gDcsId==""?'':'/'+gDcsId)+"/dcs.gif?";
	for (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 nn=((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 (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(){
   // objects copy by reference we have to copy the elements
    var DCS2 = new Object;
    for (field in DCS) {
      DCS2[field] = DCS[field];
    }
    var WT2 = new Object;
    for (field in WT) {
      WT2[field] = WT[field];
    }
    var DCSext2 = new Object;
    for (field in DCSext) {
     DCSext2[field] = DCSext[field];
    }

  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();
    WT = WT2;
    DCS = DCS2;
    DCSext = DCSext2;
  }
}

// Code section for Track clicks to dynamic links.
function dcsDynamic(evt){
	evt=evt||(window.event||"");
	if (evt){
		var e=dcsEvt(evt,"A");
		if (e.href&&e.protocol){
			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():""));
			}
		if (e.protocol=="mailto:"){
				dcsMultiTrack("DCS.dcssip","","DCS.dcsuri",e.href,"WT.ti","MailTo:"+e.text,"WT.cl","mt","DCSext.mailto",1,"DCSext.eventType","Mail");
				DCS.dcssip=DCS.dcsuri=WT.ti=WT.cl="";
			}
			WT.svl="";
		}
	}
}


//Custom function for drilldown
function contentDrilldown(){
	
	if (DCSext.content_drilldown){
		// if it has been passet explicitly we exit this function and do nothing
	}
	else if (WT.ti.match('^Coca-Cola - ')){
		// if the title matches our pattern then figure out the drilldown
		// our pattern is Coca-Cola - Content Group Name - Content Sub-Group Name - Drilldown Level N (etc)
		DCSext.content_drilldown = WT.ti.replace(/ - /g,"_").match(/^Coca\-Cola_(.*)/)[1];
	}
	else {
		// We cant figure it out from the title, so need to put it into an uncategorized bucket
		// we translate _ in title so that it doesnt create lots of levels
		DCSext.content_drilldown = 'Uncategorized_Uncategorized_' + WT.ti.replace(/_/g,"-");
	}
	
	var contentArray=new Array;
	contentArray = DCSext.content_drilldown.split("_");
	if (contentArray.length > 0) {
		WT.cg_n = contentArray[0];
	}
	if (contentArray.length > 1) {
		WT.cg_s = contentArray[1];
	}
	var currentVisitDepth=1;	// default for homepage
	if (WT.cg_n != 'Homepage'){
		currentVisitDepth = contentArray.length +1;
	}
	if (document.domain.indexOf(".thecoca-colacompany.com") > -1) {
		var priorVisitDepth = dcsGetCookie("VISITDEPTH");
		if ((priorVisitDepth == null) ||
				(priorVisitDepth < currentVisitDepth)) {
					DCSext.visitDepth = currentVisitDepth;				// Plan is to report on the max value within the
					// set the cookie
					document.cookie="VISITDEPTH=" + currentVisitDepth + ";path=/;domain=.thecoca-colacompany.com";
		}
	}
}

function initialCG(){
	// initialCG sets a persistent cookie with the users first ever content group for behavioral segmentation
	// this function must be called after the content group is set in contentDrilldown()
	if ((document.cookie.indexOf("INITIALCG=")==-1) &&			//cookie is not found - so this may be there initial group
			(WT.cg_n != 'Homepage') && (document.domain.indexOf(".thecoca-colacompany.com") > -1)) {					// home doesnt count as a group for this purpose
			// set the cookie
			var dCur=new Date();
			var dExp=new Date(dCur.getTime()+315360000000);
			var expiry="; expires="+dExp.toGMTString();
			document.cookie="INITIALCG=1;"+ expiry + ";path=/;domain=.thecoca-colacompany.com";
			WT.seg_2 = WT.cg_n;
	}
}

dcsVar();
dcsMeta();
dcsFunc("dcsAdv");
dcsTag();
<!-- End of WT Code -->



