
/*  scripts */
// Begin scripts


var head=document.getElementsByTagName('head');
if (head) head=head[0];

/* private function only called in this context to add a <meta> tag to <head> */
function addMeta(name, content) {
	if (head) {
		var meta=document.createElement('meta');
		meta.setAttribute('name',name);
		meta.setAttribute('content',content);
		head.appendChild(meta);
	}
}

/* public function called from WebTrends code to scan the page for custom <span> tags and add the info to <head> as <meta> tags.*/
function ib_WTCustomTags() {
	var spans=document.getElementsByTagName('span');
	if (spans && spans.length > 0) {
		for (var i=0; i<spans.length;i++) {
			var span=spans[i];
			if (span) {
				var tag=span.getAttribute('WT_tag');
				if (tag) {
					var val=span.getAttribute(tag);
					if (val) {
						addMeta(tag,val);
					}
				}
			}
		}
	}
}

/* public function called from WebTrends code to prepend call letters to content group if branded national page.
   (must be called AFTER the WT variables are initialized)
*/
function ib_WTCheckBranding() {
	if (window.WT && WT.cg_n && window.ozone && (ozone.length>0) && (pageProps.sectionsite == 'oly')) {
		// poll results comes through as oly, don't brand if already ozoned
		if (WT.cg_n.indexOf('.')==-1) {
			WT.cg_n = '_' + ozone.toUpperCase() + ";" + WT.cg_n;
			if (window.DCSext) DCSext.ib_brd=ozone.toUpperCase();
		}
	} else if ((window.pageProps) && (pageProps.sectionsite == 'oly') && IBCookies.get('call')) {
		// poll results comes through as oly, don't brand if already ozoned
		if (WT.cg_n.indexOf('.')==-1) {
			WT.cg_n = '_' + IBCookies.get('call').toUpperCase() + ";" + WT.cg_n;
			if (window.DCSext) DCSext.ib_brd=IBCookies.get('call').toUpperCase();
		}
	}

	// check localization status
	if (window.DCSext) {
		DCSext.ib_locs='no'; //default
		if (window.ozone && (ozone.length>0)) {
			DCSext.ib_locs='yes';
		} else if (IBCookies.get("call")) { // user has a cookie
			DCSext.ib_locs='yes';
		}
	}

	// check for localization event
	if (IBCookies.get('wtlocm')) {
		// report the event and remove the cookies to prevent double-reporting
		DCSext.ib_locm=IBCookies.get('wtlocm');
		DCSext.ib_loco=IBCookies.get('wtloco');
		DCSext.ib_locsta=IBCookies.get('call');
		IBCookies.nuke('wtlocm');
		IBCookies.nuke('wtloco');
		// track scenario step 3 if not localized through affiliate string
		if (DCSext.ib_locm != 'affiliate') {
			dcsMultiTrackScenario(3);
		}
	}
}

/* this function is for rex to use on slideshows */
function slideshowClickTrack(tab) {
	if (typeof dcsMultiTrack == "function") dcsMultiTrack('DCSext.ib_ctab',tab);
	if (window.Ads && Ads.refreshAll) Ads.refreshAll();
}


// End scripts


