
/* Click on Detroit scripts */
// Begin national js scripts
/**
 * Copyright 2006, Internet Broadcasting.
 * All Rights Reserved.
 *
 * Namespace management. Usage is: using("com.foo.bar") = { ... }
 *
 * Author:  $Author: ddjohnson $
 * Date:    $Date: 2006/07/25 19:47:42 $
 * Version: $Name:  $
 * ID:      $Id: base.js,v 1.2 2006/07/25 19:47:42 ddjohnson Exp $
 */

var ibsys = {
};

function using(namespace)
{
	var parts = namespace.split(/\./);
	var context = window;
	while(parts.length != 0)
	{
		var obj = parts.shift();
		if(!(obj in context))
			context[obj] = {};
		context = context[obj];
	}
	return context;
}


var siteinfo = {lang:"en",timezone:"EST",
distribution: 'core',

"id":"8624313",
"advertisingid":"det",
"ultraseekregion":"eastern",
"timezone":"EST",
"affiliate":"nbc",
"state":"mi",
"owner":"post",
"region":"midwest",
"tld":"com",
"is_ia":"yes",
"cssrepository":"svn",
"emailsignup":{
"v":"2",
"severeCOID":"1428535",
"coreg":{
"display":"true",
"partner":{
"active":"true",
"name":"Opt-Intelligence",
"oi_pid":"10470987"}}},
"topstory":{
"facelift":"true"},
"sitekey":{
"lc":"det",
"uc":"DET"},
"sitename":{
"lc":"clickondetroit",
"mx":"ClickOnDetroit",
"uc":"CLICKONDETROIT",
"display":"Click on Detroit"},
"callletters":{
"lc":"wdiv",
"uc":"WDIV"},
"statecode":{
"uc":"MI",
"lc":"mi"},
"statename":{
"uc":"MICHIGAN",
"lc":"mighigan",
"mx":"Michigan"},
"city":{
"uc":"DETROIT",
"lc":"detroit",
"mx":"Detroit"},
"surveyemail":"detnews@clickondetroit.com",
"slideshow":{
"version":"2"},
"surveyResults":{
"display":"inline",
"status":"live"},
"header":{
"DataCoId":"17451974",
"WxLink":"http://justweather.com/?site=detroit"},
"storysettings":{
"tools":{
"display":"true"},
"discussion":{
"status":"live",
"type":"disqus",
"disclaimer":"true",
"disclaimerlink":"/station/19979203/detail.html#UserConduct"}},
"contentrights":{
"red":"yes",
"cnn":"yes",
"nbcoo":"no",
"group":"red"},
"ibs_ad_config":{
"amp":{
"allow":"yes"},
"format":"jsPageModel"},
"search":{
"ultraseekregion":"post",
"engineType":"autonomy",
"keywordlist":{
"id":"9404305"},
"usingTestServer":"true",
"yellowpagessearch":{
"display":"true",
"YP_action":"http://clk.atdmt.com/AST/go/ntrgiypc0220000132ast/direct/01/",
"link":"http://yellowpages.clickondetroit.com/detroit+mi.z.html"},
"autonomySearchConfig":{
"mediaTypesSearched":{
"stories":"off",
"video":"off"}}},
"source_names":{
"source":{
"poolid":"1782",
"name":"CNN",
"display":"true"}},
"widget":{
"local":{
"name":"localNews",
"coid":"228377",
"label":"News"},
"sports":{
"name":"sportsNews",
"coid":"228523",
"label":"Sports"},
"weird":{
"name":"weirdNews",
"coid":"4068067",
"label":"Weird"},
"other":{
"name":"mostPopular",
"coid":"4735896",
"label":"Most Popular"}},
"thirdparty_info":{
"dss":{
"clicktracker":"http://ad.doubleclick.net/clk;218679548;8704162;v?",
"clicktracker_2":"http://ad.doubleclick.net/clk;219206348;8704162;g?",
"clicktracker_3":"http://ad.doubleclick.net/clk;219247061;8704162;d?",
"clicktracker_4":"http://ad.doubleclick.net/clk;219254051;8704162;a?"},
"insweb":{
"clicktracker":"http://ad.doubleclick.net/clk;215852654;8704162;j?"},
"rhg":{
"clicktracker":"http://ad.doubleclick.net/clk;160573773;8704162;k?",
"tabtracker":"http://ad.doubleclick.net/clk;199660261;8704162;l?",
"tabtoptracker":"http://ad.doubleclick.net/clk;207835850;8704162;j?",
"bdwidget":"http://ad.doubleclick.net/clk;207875884;8704162;u?",
"stlinks":"http://ad.doubleclick.net/clk;209210622;8704162;v?",
"fbelt":"http://ad.doubleclick.net/clk;209210634;8704162;y?",
"eh_clicktracker":"http://ad.doubleclick.net/clk;210078962;8704162;g?",
"eh_fbelt":"http://ad.doubleclick.net/clk;210078982;8704162;i?",
"eh_stlinks":"http://ad.doubleclick.net/clk;210078994;8704162;l?",
"eh_bdwidget":"http://ad.doubleclick.net/clk;210079017;8704162;y?",
"eh_tabtracker":"http://ad.doubleclick.net/clk;210079031;8704162;u?",
"wte_clicktracker":"http://ad.doubleclick.net/clk;210079616;8704162;d?",
"wte_fbelt":"http://ad.doubleclick.net/clk;210079630;8704162;z?",
"wte_stlinks":"http://ad.doubleclick.net/clk;210079642;8704162;c?",
"wte_bdwidget":"http://ad.doubleclick.net/clk;210079661;8704162;d?",
"wte_tabtracker":"http://ad.doubleclick.net/clk;210079672;8704162;f?",
"diet_clicktracker":"http://ad.doubleclick.net/clk;215478922;8704162;l?",
"diet_jm_clicktracker":"http://ad.doubleclick.net/clk;216520597;8704162;i?",
"diet_sbd_clicktracker":"http://ad.doubleclick.net/clk;216520605;8704162;y?"},
"care":{
"clicktracker":"http://ad.doubleclick.net/clk;196846991;8704162;y?",
"tabtracker":"http://ad.doubleclick.net/clk;199560370;8704162;l?"},
"mains":{
"clicktracker":"http://ad.doubleclick.net/clk;202691657;8704162;j?",
"tabtracker":"http://ad.doubleclick.net/clk;203108378;8704162;d?",
"entrbdwidget":"http://ad.doubleclick.net/clk;209177416;8704162;i?",
"rbdwidget":"http://ad.doubleclick.net/clk;209177424;8704162;h?",
"slideshow":"http://ad.doubleclick.net/clk;209177433;8704162;h?",
"sidebar":"http://ad.doubleclick.net/clk;209177447;8704162;m?",
"stlinks":"http://ad.doubleclick.net/clk;209216652;8704162;e?",
"fbelt":"http://ad.doubleclick.net/clk;209216661;8704162;e?"},
"elrnrs":{
"clicktracker":"http://ad.doubleclick.net/clk;215984310;8704162;e?"},
"next":{
"fixed":"5000529",
"lwl":"5000509",
"tabbox":"5000536",
"tabtracker":"http://ad.doubleclick.net/clk;206779450;8704162;l?",
"clicktracker":"http://ad.doubleclick.net/clk;207330831;8704162;y?"},
"mnstr":{
"clicktracker":"http://ad.doubleclick.net/clk;155881542;8704162;k?",
"lid":"468,470,707,472,695,473,467",
"tabtracker":"http://ad.doubleclick.net/clk;199660025;8704162;j?",
"tabsearchtracker":"http://ad.doubleclick.net/clk;201968228;8704162;j?",
"bdwidget":"http://ad.doubleclick.net/clk;207937793;8704162;s?",
"findajob":"http://ad.doubleclick.net/clk;207984702;8704162;k?",
"stlinks":"http://ad.doubleclick.net/clk;209140636;8704162;c?",
"fbelt":"http://ad.doubleclick.net/clk;209140652;8704162;a?"},
"netq":{
"tabtracker":"http://ad.doubleclick.net/clk;199660140;8704162;h?"},
"hvolt":{
"clicktracker":"http://ad.doubleclick.net/clk;155601789;8704162;n?",
"tabtracker":"http://ad.doubleclick.net/clk;199657600;8704162;o?",
"uofp_form":"http://ad.doubleclick.net/clk;210577954;8704162;l?",
"uofp_widgetlinks":"http://ad.doubleclick.net/clk;210577963;8704162;l?",
"uofp_lwl":"http://ad.doubleclick.net/clk;210660886;8704162;i?",
"uofp_tabbox":"http://ad.doubleclick.net/clk;211050313;8704162;n?",
"uofp_rotatingwidget":"http://ad.doubleclick.net/clk;211050334;8704162;q?",
"uofp_featurebelt":"http://ad.doubleclick.net/clk;211050354;8704162;s?",
"uofp_sponsoredtextlinks":"http://ad.doubleclick.net/clk;211050363;8704162;s?"},
"hmstr":{
"clicktracker":"http://ad.doubleclick.net/clk;155576395;8704162;r?",
"source":"a10088",
"tabtracker":"http://ad.doubleclick.net/clk;199662067;8704162;r%3F",
"stlinks":"http://ad.doubleclick.net/clk;209177850;8704162;k?",
"fbelt":"http://ad.doubleclick.net/clk;209177857;8704162;r?"},
"ara":{
"clicktracker":"http://ad.doubleclick.net/clk;155721837;8704162;k?"},
"exprn":{
"tabtracker":"http://ad.doubleclick.net/clk;199656773;8704162;y?",
"fbelt":"http://ad.doubleclick.net/clk;209178274;8704162;l?"},
"brate":{
"clicktracker":"http://ad.doubleclick.net/clk;155705107;8704162;c?",
"feedstracker":"http://ad.doubleclick.net/clk;199663798;8704162;d?",
"im_stlinks":"http://ad.doubleclick.net/clk;212240147;8704162;u?",
"im_fbelt":"http://ad.doubleclick.net/clk;212240142;8704162;p?",
"im_dapwidget":"http://ad.doubleclick.net/clk;212240135;8704162;r?",
"im_clicktracker":"http://ad.doubleclick.net/clk;212240152;8704162;q?",
"im_tabtracker":"http://ad.doubleclick.net/clk;212240141;8704162;o?",
"ratestracker":"http://ad.doubleclick.net/clk;216668609;8704162;p?",
"tabtracker":"http://ad.doubleclick.net/clk;216671588;8704162;p?"},
"ccard":{
"pid":"2bdfc716",
"rate":"f71227c2",
"tabtracker":"http://ad.doubleclick.net/clk;199560591;8704162;q?",
"stlinks":"http://ad.doubleclick.net/clk;212358987;8704162;q?"},
"sureh":{
"lwl":"http://ad.doubleclick.net/clk;212582145;8704162;b?",
"rotatingwidget":"http://ad.doubleclick.net/clk;212582138;8704162;d?",
"widgetlanding":"http://ad.doubleclick.net/clk;212582134;8704162;z?",
"tabbox":"http://ad.doubleclick.net/clk;212582124;8704162;y?",
"stlinks":"http://ad.doubleclick.net/clk;212582120;8704162;u?",
"subnav":"http://ad.doubleclick.net/clk;214611062;8704162;u?"},
"class":{
"clicktracker":"http://ad.doubleclick.net/clk;212811499;8704162;i?"},
"eharm":{
"cid":"1195",
"clicktracker_dfp":"12700826;8704162;b",
"clicktracker":"http://ad.doubleclick.net/clk;40584330;8704162;c?",
"tabtracker":"http://ad.doubleclick.net/clk;199574294;8704162;v?"},
"quin":{
"qlink":"n=203;c=319589;s=6102;x=7936;f=200709211646450;"},
"tripa":{
"mcode":"10735",
"subdomain":"clickondetroit"},
"hybryd":{
"clicktracker":"http://ad.doubleclick.net/clk;216027972;8704162;h?"},
"tzoo":{
"ac":"DTT",
"tabtracker":"http://ad.doubleclick.net/clk;199660720;8704162;l?",
"stlinks":"http://ad.doubleclick.net/clk;209219706;8704162;h?",
"fbelt":"http://ad.doubleclick.net/clk;209219717;8704162;j?"},
"creditcard":{
"pid":"2bdfc716"},
"google":{
"searchid":"8026243618",
"verify":"e2xoa1+3UwKHDQMvJk1DipDVgm/ffNZt4PnwJO7aPDQ=",
"analytics":{
"code":"UA-3515011-14",
"display":"true"}},
"quantcast":{
"id":{
"code":"p-41jrVeSPpekVU",
"label":"Post-Newsweek Television Stations",
"urlencodedlabel":"Post-Newsweek%20Television%20Stations%20",
"display":"true"}},
"yahoo":{
"verify":"326f76cd43f1b257"},
"moving":{
"id":"a10088"},
"tripadvisor":{
"id":"10735",
"subdomain":"clickondetroit"},
"titantv":{
"id1":"53460"},
"homestore":{
"code":"ib",
"clicktracker_dfp":"7412515;8704162;e"},
"experion":{
"id":"6380",
"tabtracker":"http://ad.doubleclick.net/clk;199656773;8704162;y?"},
"eharmony":{
"cid":"1195",
"clicktracker_dfp":"12700826;8704162;b"},
"monster":{
"lid":"468,470,707,472,695,473,467"},
"flustar":{
"id":"1029"},
"WT_info":{
"id":"dcs0ty8ah00000o6lfz92okrt_8x3c",
"weather_id":"dcszpimux00000oymn0bmzgzs_2b5s"},
"titantv":{
"id1":"53460"},
"aolaut":{
"clicktracker":"http://ad.doubleclick.net/clk;211773901;8704162;c?",
"tabtracker":"http://ad.doubleclick.net/clk;211773949;8704162;o?",
"stlinks":"http://ad.doubleclick.net/clk;211773865;8704162;l?",
"fbelt":"http://ad.doubleclick.net/clk;211773862;8704162;i?",
"daprwidget":"http://ad.doubleclick.net/clk;211773916;8704162;i?",
"slideshow":"http://ad.doubleclick.net/clk;211773880;8704162;i?",
"insidearticles":"http://ad.doubleclick.net/clk;211773852;8704162;h?",
"editauto":"http://ad.doubleclick.net/clk;211773941;8704162;g?",
"editorial":"http://ad.doubleclick.net/clk;211773838;8704162;l?",
"search":"http://ad.doubleclick.net/clk;211772896;8704162;o?",
"forum":"http://ad.doubleclick.net/clk;211773927;8704162;k?"},
"srvmg":{
"clicktracker":"http://ad.doubleclick.net/clk;213342451;8704162;w?"},
"nplay":{
"stlinks":"http://ad.doubleclick.net/clk;213597187;8704162;o?",
"fbelt":"http://ad.doubleclick.net/clk;213597141;8704162;e?",
"clicktracker":"http://ad.doubleclick.net/clk;213597297;8704162;q?",
"tabtracker":"http://ad.doubleclick.net/clk;213597090;8704162;h?"},
"bankmw":{
"clicktracker":"http://ad.doubleclick.net/clk;215076874;8704162;l?",
"tabtracker":"http://ad.doubleclick.net/clk;215077504;8704162;c?",
"daprwidget":"http://ad.doubleclick.net/clk;215076841;8704162;f?",
"stlinks":"http://ad.doubleclick.net/clk;215076296;8704162;j?",
"fbelt":"http://ad.doubleclick.net/clk;215076357;8704162;h?"},
"allhea":{
"clicktracker":"http://ad.doubleclick.net/clk;215270054;8704162;x?",
"diabetes_clicktracker":"http://ad.doubleclick.net/clk;215554701;8704162;b?"},
"fdoor":{
"clicktracker":"http://ad.doubleclick.net/clk;215342681;8704162;d?",
"tabtracker":"http://ad.doubleclick.net/clk;215342680;8704162;c?",
"modules":"http://ad.doubleclick.net/clk;215342679;8704162;k?",
"daprwidget":"http://ad.doubleclick.net/clk;215342682;8704162;e?",
"slideshow":"http://ad.doubleclick.net/clk;215342678;8704162;j?",
"fbelt":"http://ad.doubleclick.net/clk;215343405;8704162;y?",
"stlinks":"http://ad.doubleclick.net/clk;215343406;8704162;z?"},
"rtrac":{
"clicktracker":"http://ad.doubleclick.net/clk;215443001;8704162;r?"}},
"video":{
"playerversion":"5",
"cpcode":"12942",
"liveflashcpcode":"51590"},
"linkmethods":{
"mt":{
"name":"livestream",
"mtid":"859",
"dynamic_url":"/video/[ibs_variable type=iburl att=coid]/index.html"},
"mt":{
"name":"slideshow",
"mtid":"181",
"method":"popup",
"width":"1024",
"height":"750",
"top":"0",
"left":"0",
"dynamic_url":"/slideshow[ibs_variable type=iburl att=sectionpath][ibs_variable type=iburl att=coid]/detail.html"}}};


// GLOBAL Variables
now = new Date();
expire = new Date((now.getFullYear()+1),now.getMonth(),now.getDate());
var child = 0;
var rnd = new Date();
rnd = rnd.getTime();

// Deprecated variables
//var IBS_Sitekey = siteinfo.sitekey.lc;
var IS_IA = siteinfo.is_ia;
IBSSite = new Object();
dotPosition = document.location.host.indexOf('.')+1;
IBSSite.domain = document.location.host.substring(dotPosition);

// Set environment variables
env = new Object();
env.bVer = navigator.appVersion;
env.bName = navigator.appName;
env.platform = navigator.platform;
env.userAgent = navigator.userAgent;
env.cookies = navigator.cookieEnabled;
env.NS4 = (document.layers)? 1 : 0;
env.MacIE = ((navigator.userAgent.indexOf("IE 4")  > -1) && (navigator.userAgent.indexOf("Mac")  > -1))? 1 : 0;
env.IE4 = (document.all && !env.MacIE)? 1 : 0;
env.Gen4 = (document.all || document.layers)? 1 : 0;
if(env.bName.indexOf('Netscape') != -1) isNN = true;
else isNN = false;
if(env.bName.indexOf('Microsoft') != -1) isIE = true;
else isIE = false;

//Open window - pass URL and Attributes
function popUp(URL, ATTRIBUTES)  {
	DEF_ATTRIB = 'width=200,height=200,top=100,left=100,resizable=yes,scrollbars=1';
	if (ATTRIBUTES == null) {
		ATTRIBUTES = DEF_ATTRIB;
	}
	child = window.open(URL, "spawn", ATTRIBUTES + ",scrollbars=1");
	// child.opener = self;
}



// FIX THE STRINGS ( apostrophes)
function fixString(strText) {
	if(!strText || strText == null) return "";
	var newstr = strText.replace(/~/g, "&#39;");
	return newstr;
}

// Replace white space around tags in teaser - used in TopStory and PhotoArray
function padTags(s){
	if(!s || s == null) return "";
	var tmp = s.replace(/(<\w)/ig, " $1");
	tmp = tmp.replace(/(<\/\w>)/ig, "$1 ");
	return tmp;
}

/**
 * returns the parent widget ID of the given indexID, for use
 * with jsIndex
 */
function getWidgetID(indexId)
{
	var el = document.getElementById("index"+indexId);
	if(el == null) return null;
	var p = el.parentNode;
	while(p)
	{
		if(p.id && p.id.match(/sw[0-9]+/))
			return p.id.replace(/sw/,"");
		p = p.parentNode;
	}
	return null;
}




var XMLObj = {
	impl: function() {
		return (window.XMLHttpRequest ? new XMLHttpRequest() : 
				(window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : 
					new Error("No XMLHttpRequest Implementation")));
	},
	
	get: function(url, handler) {
		var req = XMLObj.impl();
		req.open("get", url, true);
		req.onreadystatechange = function() {
			/* Opera may return status 304; unchanged */
			if(req.readyState == 4) {
				handler(req.responseXML, req.responseText);
			}
		};
		req.send(null);
	},
	
	post: function(url, params, handler) {
		var req = XMLObj.impl();
		req.open("post", url, true);
		req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		req.setRequestHeader("Referer", document.location.href);
		req.onreadystatechange = function() {
			/* Opera may return status 304; unchanged */
			if(req.readyState == 4 ) {
				handler(req.responseXML, req.responseText);
			}
		};
		req.send(params);
	}
};



// Define client cookie values
cookiesList = document.cookie.split('; ');
myCookies = new Array();
for(c=0; c<cookiesList.length; c++) {
	cookieTemp = cookiesList[c].split('=');
	myCookies[cookieTemp[0]] = cookieTemp[1];
}

// Added new variable to support multiple sub domains
var docDomain = document.domain.split('.');
var dd='';
for(var i=1; i<docDomain.length; i++) {
	dd+="."+docDomain[i];
}
docDomain=dd;

// Set cookie info
function setCookie( name, value, path, expires, domain, secure ) {
	expire.setTime(now.getTime() + expires * 24 * 60 * 60 * 1000);
	curCookie =  name + "=" + escape(value) +
		((expires) ? "; expires=" + expire.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
	if ((name + "=" + escape(value)).length <= 4000) document.cookie = curCookie;
	else if (confirm("Cookie exceeds 4KB and will be cut!")) document.cookie = curCookie;
}

// Get cookie info
function getCookie(c) {
	if(typeof myCookies[c] != 'undefined') return myCookies[c];
	else return '';
}

// Remove cookie
function deleteCookie(name,path) {
	setCookie(name,"",path,-1,docDomain);
}

// In case old cookie functions are used somewhere...
WM_setCookie  = setCookie;
WM_readCookie = getCookie;
WM_killCookie = deleteCookie;



function fixPngImage(p) {
	var imgsrc;
	var trans = "http://images.ibsys.com/sh/images/spacer.gif";   
	if(typeof p.tested != undefined && !p.tested &&  typeof p.runtimeStyle != 'undefined') {
	   // retain image src
	   imgsrc = p.src;

	   // make sure the image is a PING
	   if ( /\.png$/.test( imgsrc.toLowerCase() ) ) {
	   	// If it is set it to a transparent image
		p.src = trans;
		// Set the runtime style to load the alpha image in the background
		p.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + imgsrc + "',sizingMethod='scale')";
		p.tested = true;
	   }
   }
}

// Calls 'func' on 'eventName' in 'obj'
function addEvent(obj, eventName, func) {
	if (typeof YAHOO != 'undefined') {
		window.addEvent = function(obj, eventName, func) {
			return YAHOO.util.Event.addListener(obj, eventName, func);
		}
	} else {
		this.setObj = function(obj) {
			return (typeof obj == 'string' ? document.getElementById(obj) || false : typeof obj == 'object' ? obj : false);
		}
		obj = setObj(obj);
		if (obj.addEventListener) {
			window.addEvent = function(obj, eventName, func) {
				obj = setObj(obj);
				if (obj) {
					return obj.addEventListener(eventName, func, true);
				} else {
					return false;
				}
			}
		} else if (obj.attachEvent) {
			window.addEvent = function(obj, eventName, func) {
				obj = setObj(obj);
				if (obj) {
					obj.attachEvent("on" + eventName, func);
					return true;
				} else {
					return false;
				}
			}
		} else {
			return false;
		}
	}
	return addEvent(obj, eventName, func);
}
/**
 * Copyright 2006, Internet Broadcasting Systems. All Rights Reserved.
 * Author:    $Author: bstime $
 * Date:      $Date: 2007/11/27 22:17:40 $
 * Version:   $Name:  $
 * ID:        $Id: AdObj.js,v 1.13 2007/11/27 22:17:40 bstime Exp $
*/

/**
 * Generic AdObj holds properties to ease calling pixel ads for specific uses
 *
 * Usage of class methods:
 *	<li>AdObj.create(position,sz,swId,coId,section) - create and return a new AdObj</li>
 *  <li>AdObj.refreshPosition(positions...) - refresh one or more positions</li>
 *  <li>AdObj.refreshAll() - refresh all ads</li>
 *	<li>AdObj.remove(name) - remove ad</li>
 *
 * @constructor
 * @param {String} position Corresponds to ad position, like mediawidow, banner or tile
 * @param {String} sz Size, formatted as 2x2
 * @param {String} swId Section widget id
 * @param {String} coId Content id
 * @param {String} section Section widget section
 */

function AdObj(position, sz, swId, coId, section) {
	this.position = position;
	this.sz = sz;
	this.swId = swId;
	this.coId = coId ? "+"+coId : "";
	this.section = section;
	var size = this.sz.split("x");
	this.width = size[0];
	this.height = size[1];
}

/**
 * @deprecated in favor of {@link AdObj#refresh}
 *
 * Append iframe with ad call to end of document or refresh the ad of set position
 * NOTE: DART key set to ibs.[sitekey].interactive
 * NOTE: Changed .refresh Removed the extra + between position and coid
 */
AdObj.prototype.callAd = function() {
	if (!document.getElementById(this.position)) {
		// append iframe to document
		document.getElementsByTagName("body")[0].appendChild(document.createElement("span")).innerHTML = "<iframe id="+this.position+" src='http://ad.doubleclick.net/adi/ibs."+siteinfo.sitekey.lc+".interactive/"+adZone+";kw="+this.section+"+"+this.position+this.coId+";comp="+adid+";ad=true;tile="+dcadposition+ ";pgtype=detail;sz="+this.sz+";ord="+rnd+"?' width='"+this.width+"' height='"+this.height+"' marginwidth='0' marginheight='0' frameborder='0' scrolling='no'></iframe>";
	} else {
		// refreshAd is defined in base js
		refreshAd(this.position);
	}
}

/**
 * Refresh this ad.
 */
AdObj.prototype.refresh = function(adid,tileNum)
{
	var randInt = parseInt(Math.random(1)*100000000);
                adid = (typeof adid == "undefined") ? "" : adid;
	var category = (typeof WT != 'undefined' && WT.cg_n != '' && adid == '')?WT.cg_n.toLowerCase():'interactive';
	// var obj = document.getElementById(this.position);
	// if(obj == null)
	// {
		var arr = getByClassName(document.body, "ad"+this.position);
		if(arr.length == 0)
			return;
		// obj = arr[0];
	// }
	//http://ad.doubleclick.net/adi/ibs.chi.interactive/;kw=video+news+null+banner1+9385129;ad=true;pgtype=detail;sz=728x90;adid=36780253;ord=940767630?
	var tileNum = (typeof dcadposition != 'undefined' ? dcadposition : tileNum || 1);
	var src = "http://ad.doubleclick.net/adi/ibs."+siteinfo.sitekey.lc+"."+category+"/"+adZone+";kw="+this.section+"+"+this.position+this.coId+";ad=true;tile="+tileNum+ ";pgtype=detail;sz="+this.sz+";"+adid+";ord="+randInt+"?";
	// if(/iframe/i.exec(obj.nodeName) != null)
	// {
	// 	obj.src = "";
	// 	obj.src = src;
	// }
	// else
	arr[0].innerHTML = "<iframe id="+this.position+" src='"+src+"' width='"+this.width+"' height='"+this.height+"' marginwidth='0' marginheight='0' frameborder='0' scrolling='no'></iframe>";
}

/** AdObj class members */
/**
 * collection of Ad Objects
 */
AdObj.elements = new Object();

/**
 * Create a AdObj instance and add it to the collection
 */
AdObj.create = function create(position,sz,swId,coId,section)
{
	return AdObj.elements[position] = new AdObj(position,sz,swId,coId,section);
}

/**
 * Refresh ads by position: AdObj.refreshPosition("banner1","tile1","square");
 */
AdObj.refreshPosition = function refreshPosition()
{
	for(var j=0; j < arguments.length; j++)
		if(AdObj.elements[arguments[j]])
			AdObj.elements[arguments[j]].refresh();
}

/**
 * Refresh all ads
 */
AdObj.refreshAll = function refreshAll(adid)
{
	var i=1;
	for(var p in AdObj.elements) {
		AdObj.elements[p].refresh(adid,i);
		i++;
	}
}

AdObj.adIds = new Object();

/**
 * Returns an event handler for WMP CurrentItemChange event.
 *
 * The returned handler refreshes ads if the currentMedia has a
 * "dcAdTag" parameter.
 *
 * @param <String> videoPlugID
 * @return <function>
 */
AdObj.createAdRefreshHandler = function createAdRefreshHandler(videoPlugID)
{
	return (function()
	{
		if(!document ||
		   !document.body ||
		   !document.getElementById(videoPlugID))
		{
			return;
		}
		// NOTE: may need to change this if the format of the 'adid' parameter
		// value changes.  currently it is 'adid=[0-9]+'
		var adTagParam = document.getElementById(videoPlugID).currentMedia.getItemInfo("dcAdTag");
		if(/adid=[0-9]+/.exec(adTagParam) != null && !AdObj.adIds[adTagParam])
		{
			AdObj.adIds[adTagParam] = true;
			// log("Refreshing: " + adTagParam);
			AdObj.refreshAll(adTagParam);
			window.setTimeout(
				(function()
				{
					AdObj.adIds[adTagParam] = false;
				}), 1000);
		}
		else
		{
			// log("NOT Refreshing ads; adid="+adTagParam);
		}
	});
}

/**
 * Remove an ad by name.
 * @param <String> name
 * @return true if the object was deleted.
 */
AdObj.remove = function(name)
{
	if(AdObj.elements[name])
		return delete AdObj.elements[name];
	else
		return false;
}

/**
 * TODO: put this function somewhere else
 */
function getByClassName(parent,className)
{
	var nl = parent.getElementsByTagName("*");
	var arr = [];
	for(var j=0; j < nl.length; j++)
	{
		if(nl.item(j).className && nl.item(j).className.indexOf(className) != -1)
			arr.push(nl.item(j));
	}
	return arr;
}
// 

function setDCSid(id) {
     gDcsId=id;
}

function mwpop(path,w,h) {
	var atts = 'width='+w+',height='+h+',\'scrollbars=yes,toolbar=no,status=no,location=no,menubar=no,top=50,left=50';
	popUp(path, atts);
//window.location.href=path.split('?')[0];
}

function setMediaPlayerCookie (num) {
  setCookie("mediaWindow",num,"",30,window.location.host,"");
  return "done";
}

function getMediaPlayerCookie () {
  var myCookie = new String(getCookie("mediaWindow"));
  return myCookie;
}


/* toggleData function
 * toggles all elements inside a parent element
 * 2 params 
 *   id - the parent element id
 *   cn - class name of elements you want to hide
 */
function toggleData(id,cn){
	var div = document.getElementById(id);
	var cond = div.getElementsByTagName('*');
	for(var i = 0;i<cond.length;i++){
		if(cond[i].className.indexOf(cn) != -1) {
		cond[i].style.display = (cond[i].style.display != 'none') ? 'none' : '';
		}
	}
}
/* hideData function
 * hides all elements inside a parent element
 * same params as toggleData
 * current usage - full display of current conditions weather object calls this function 
 */
function hideData(id,cn){
	var div = document.getElementById(id);
	var cond = div.getElementsByTagName('*');
	for(var i = 0;i<cond.length;i++){
		if(cond[i].className.indexOf(cn) != -1) {
			if(cond[i].style.display != 'none') cond[i].style.display = 'none';
		}
	}
}
	


/*
 * Copyright 2006, Internet Broadcasting Systems. All Rights Reserved.
 * CVS: $Id: tagCNN.js,v 1.2 2007/07/27 15:19:07 mwakefield Exp $
 * CVS Path: $Source: /u01/cvsroot/javascript/webtrends/tagCNN.js,v $
 * Phaedra Content ID: 
 * Example URL: http://preview.wesh.com/index.html
*/

getElementsByClassName = function(node, classname) {
    var a = [];
    var re = new RegExp('\\b' + classname + '\\b');
    var els = node.getElementsByTagName("*");
    for(var i=0,j=els.length; i<j; i++)
	if(re.test(els[i].className))a.push(els[i]);
    return a;
}

var cnnTaggingForWebTrends = {
	load: function() {
		var cnnButtons = getElementsByClassName(document, "source_name_CNN");
		for (var button = 0; button < cnnButtons.length; button++) {
			addEvent(cnnButtons[button].parentNode, "click", 
				function(event) {
					if(event.target){
						// Firefox uses event.target to reference object that was clicked
						cnnTaggingForWebTrends.action(event.target);
					}
					else {
						// Internet Explorer uses event.srcElement to reference object that was clicked
						cnnTaggingForWebTrends.action(event.srcElement);
					}
				}
			);
		}
	},
	action: function(clickedCNN) {
		var temp = gDcsId;
		gDcsId="dcs2dg4lq00000gw3pkr8nynl_3j5j";
		dcsMultiTrack(
			'DCSext.ib_partner',siteinfo.owner,
			'DCSext.ib_station',siteinfo.callletters.uc,
			'DCSext.ib_cnn_linkname',clickedCNN.innerHTML,
			'DCSext.ib_cnn_linkurl',clickedCNN.href,
			'DCSext.ib_pool',siteinfo.sitekey.uc
		);
		gDcsId=temp;
	}
}

addEvent(window, "load", 
	function(){
		cnnTaggingForWebTrends.load();
	} 
);



/***
* Function to launch nbc video pop-up window player added 8.22.06
***/
    function  launchNbcVideo(pathid) { 
	site='http://video.'+ siteinfo.sitename.lc  +'.'+ siteinfo.tld +'/player.html'; 
	param = '?dlid='; 
	newwindow=window.open(site+param+pathid,'sendtofriend','toolbar=no,scrollbars=no,location=no,statusbar=no,menubar=no,resizable=no,width=750,height=550');	
	if (window.focus) {
		newwindow.focus()
	}
}



/***
* Changed by Aron B-- 8.23.06
* Changed by Joe L -- 1/24/07
***/
function launchvideo(pathid) {
	if (siteinfo.video.dmps == 'true') {
		site='http://video.'+ siteinfo.sitename.lc  +'.'+ siteinfo.tld +'/player/?id=' + pathid;
		document.location = site;
	} else {
		site='http://video.'+ siteinfo.sitename.lc  +'.'+ siteinfo.tld +'/player.html';
		param = '?dlid=';
		newwindow=window.open(site+param+pathid,'sendtofriend','toolbar=no,scrollbars=no,location=no,statusbar=no,menubar=no,resizable=no,width=750,height=550');
		if (window.focus) {newwindow.focus()}
	}
}
function launchvideodir(pathid) {
	site='http://video.'+ siteinfo.sitename.lc  +'.'+ siteinfo.tld +'/player.html';
	param = '?dl=';
	newwindow=window.open(site+param+pathid,'sendtofriend','toolbar=no,scrollbars=no,location=no,statusbar=no,menubar=no,resizable=no,width=750,height=550');
	if (window.focus) {newwindow.focus()}
}


// End national_js scripts

