
/* WFTV.com 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":"1852299",
"tld":"com",
"advertisingid":"orlc",
"station":"orlc",
"ultraseekregion":"cox",
"timezone":"EST",
"affiliate":"fox",
"state":"fl",
"owner":"cox",
"region":"cox",
"is_ia":"yes",
"version":"3",
"cssrepository":"svn",
"refresh":"600",
"sitekey":{
"lc":"orlc",
"uc":"ORLC"},
"sitename":{
"lc":"wftv",
"mx":"WFTV",
"uc":"WFTV",
"display":"WFTV.com",
"publication":"WFTV Orlando"},
"callletters":{
"lc":"wftv",
"uc":"WFTV"},
"statecode":{
"uc":"FL",
"lc":"fl"},
"statename":{
"uc":"FLORIDA",
"lc":"florida",
"mx":"Florida"},
"city":{
"uc":"ORLANDO",
"lc":"orlando",
"mx":"Orlando"},
"surveyemail":"orlcnews@wftv.com",
"slideshow":{
"version":"2"},
"emailsignup":{
"v":"2",
"severeCOID":"1795039",
"mobileurl":"http://www.localwireless.com/wireless/signup.cfm?sid=147",
"coreg":{
"display":"true",
"partner":{
"active":"true",
"name":"Opt-Intelligence",
"oi_pid":"10470987"}}},
"dynamiclede":{
"rotation":"true",
"interval":"25000"},
"surveyResults":{
"display":"inline",
"status":"live"},
"slantly":{
"display":"true"},
"timeheader":{
"scope":"index"},
"storysettings":{
"tools":{
"display":"true"},
"discussion":{
"status":"live",
"type":"kickapps",
"stylesheet":"http://clientapps.kickapps.com/coxtv/ka_test.css",
"scriptlocation":"http://clientapps.kickapps.com/coxtv/",
"as":"6696",
"psize":"5",
"token":"ZAI9+G6LSQ3PE2+4cTwuqtLMHq/Wiqdh"}},
"header":{
"version":"2",
"status":"live",
"DataCoId":"16960096",
"weather":{
"display":"true",
"weatherpage":"myweather"}},
"contentrights":{
"red":"yes",
"cnn":"yes",
"nbcoo":"no",
"group":"red",
"ah":"no"},
"ibs_ad_config":{
"amp":{
"allow":"yes"},
"format":"jsPageModel",
"referrerZones":{
"rz":{
"referrer":"cnn.com",
"zone":"cnn_national"}}},
"source_names":{
"source":{
"poolid":"1782",
"name":"CNN",
"display":"true"}},
"widget":{
"local":{
"name":"localNews",
"coid":"1815457",
"label":"News"},
"sports":{
"name":"sportsNews",
"coid":"1815478",
"label":"Sports"},
"weird":{
"name":"weirdNews",
"coid":"4068067",
"label":"Weird"},
"other":{
"name":"mostPopular",
"coid":"4736147",
"label":"Most Popular"}},
"thirdparty_info":{
"allhea":{
"clicktracker":"http://ad.doubleclick.net/clk;220390547;42510811;t?",
"daprwidget":"http://ad.doubleclick.net/clk;222260223;42510811;i?"},
"ara":{
"clicktracker":"http://ad.doubleclick.net/clk;220379107;42510811;s?",
"editorial":"http://ad.doubleclick.net/clk;220379107;42510811;s?"},
"bankmw":{
"clicktracker":"http://ad.doubleclick.net/clk;220450692;42510811;r?",
"daprwidget":"http://ad.doubleclick.net/clk;220452025;42510811;j?",
"stlinks":"http://ad.doubleclick.net/clk;220481300;42510811;h?"},
"brate":{
"clicktracker":"http://ad.doubleclick.net/clk;220502336;42510811;k?",
"feedstracker":"http://ad.doubleclick.net/clk;220501838;42510811;q?",
"im_stlinks":"http://ad.doubleclick.net/clk;212357170;8704162;z?",
"im_fbelt":"http://ad.doubleclick.net/clk;212357171;8704162;a?",
"im_dapwidget":"http://ad.doubleclick.net/clk;212357172;8704162;b?",
"im_clicktracker":"http://ad.doubleclick.net/clk;212357168;8704162;g?",
"ratestracker":"http://ad.doubleclick.net/clk;220501665;42510811;o?",
"tabtracker":"http://ad.doubleclick.net/clk;220502079;42510811;o?",
"editorial":"http://ad.doubleclick.net/clk;220502336;42510811;k?"},
"care":{
"tabtracker":"http://ad.doubleclick.net/clk;220500201;42510811;z?",
"clicktracker":"http://ad.doubleclick.net/clk;220481835;42510811;u?",
"daprwidget":"http://ad.doubleclick.net/clk;220490437;42510811;s?",
"misc":"http://ad.doubleclick.net/clk;220760831;42510811;q?",
"stlinks":"http://ad.doubleclick.net/clk;220497394;42510811;b?",
"fbelt":"http://ad.doubleclick.net/clk;220491483;42510811;u?"},
"ccard":{
"pid":"85e27f4d",
"rate":"2a8ee888",
"tabtracker":"http://ad.doubleclick.net/clk;220861821;42510811;r?",
"stlinks":"",
"misc":"http://ad.doubleclick.net/clk;220861700;42510811;n?",
"clicktracker":"http://ad.doubleclick.net/clk;220862329;42510811;v?",
"rotatingwidget":"http://ad.doubleclick.net/clk;220862138;42510811;t?",
"fixedwidgets":"http://ad.doubleclick.net/clk;220861994;42510811;c?"},
"creditcard":{
"pid":"85e27f4d"},
"dss":{
"clicktracker":"http://ad.doubleclick.net/clk;220423218;42510811;l?",
"clicktracker_2":"http://ad.doubleclick.net/clk;220424328;42510811;o?",
"clicktracker_3":"http://ad.doubleclick.net/clk;220424740;42510811;m?",
"clicktracker_4":"http://ad.doubleclick.net/clk;220425473;42510811;q?"},
"dtm":{
"clicktracker":"http://ad.doubleclick.net/clk;220422918;42510811;r?"},
"eharm":{
"cid":"1225",
"clicktracker":"http://ad.doubleclick.net/clk;220505291;42510811;n?",
"tabtracker":"http://ad.doubleclick.net/clk;220601981;42510811;q?",
"rotatingwidget":"http://ad.doubleclick.net/clk;220509339;42510811;u?",
"misc":"http://ad.doubleclick.net/clk;220667598;42510811;g?",
"fixedwidgets":"http://ad.doubleclick.net/clk;220602815;42510811;n?"},
"eharmony":{
"cid":"1225"},
"elrnrs":{
"clicktracker_csp":"http://ad.doubleclick.net/clk;220382581;42510811;s?",
"clicktracker_osfa":"http://ad.doubleclick.net/clk;220382807;42510811;t?",
"clicktracker_nyr":"http://ad.doubleclick.net/clk;221542567;42510811;v?"},
"exprn":{
"tabtracker":"http://ad.doubleclick.net/clk;220411797;42510811;u?",
"clicktracker":"http://ad.doubleclick.net/clk;220388709;42510811;a?",
"misc":"http://ad.doubleclick.net/clk;220396758;42510811;d?",
"rotatingwidget":"http://ad.doubleclick.net/clk;220395867;42510811;d?"},
"experion":{
"id":"6413",
"tabtracker":"http://ad.doubleclick.net/clk;220411797;42510811;u?"},
"fdoor":{
"clicktracker":"http://ad.doubleclick.net/clk;220386441;42510811;r?",
"tabtracker":"http://ad.doubleclick.net/clk;220396467;42510811;a?",
"modules":"http://ad.doubleclick.net/clk;220395944;42510811;z?",
"daprwidget":"http://ad.doubleclick.net/clk;220391849;42510811;z?",
"slideshow":"http://ad.doubleclick.net/clk;220398128;42510811;w?",
"fbelt":"http://ad.doubleclick.net/clk;220398273;42510811;x?",
"stlinks":"http://ad.doubleclick.net/clk;220398317;42510811;w?",
"editorial":"http://ad.doubleclick.net/clk;220387725;42510811;x?",
"misc":"http://ad.doubleclick.net/clk;220386964;42510811;b?"},
"flustar":{
"id":"1013",
"clicktracker":"http://ad.doubleclick.net/clk;220502245;42510811;j?"},
"google":{
"verify":"XBw6v2NvV/bjCR2VE6up08c1kg4+qW1IUBCBYrkxdaQ=",
"analytics":{
"code":"UA-5438030-11",
"display":"true"},
"adsense":{
"searchId":"partner-pub-6068200365010040:6uskt3qfbjw"}},
"hybryd":{
"clicktracker":"http://ad.doubleclick.net/clk;220415794;42510811;v?"},
"mains":{
"clicktracker":"http://ad.doubleclick.net/clk;220123442;42510811;h?",
"tabtracker":"http://ad.doubleclick.net/clk;220267888;42510811;e?",
"rbdwidget":"http://ad.doubleclick.net/clk;220381834;42510811;s?",
"slideshow":"http://ad.doubleclick.net/clk;220382058;42510811;r?",
"stlinks":"http://ad.doubleclick.net/clk;220383079;42510811;v?",
"fbelt":"http://ad.doubleclick.net/clk;220382985;42510811;a?",
"misc":"http://ad.doubleclick.net/clk;220382716;42510811;s?",
"sidebar":"http://ad.doubleclick.net/clk;220382378;42510811;w?",
"editorial":"http://ad.doubleclick.net/clk;220382378;42510811;w?"},
"mnstr":{
"clicktracker":"http://ad.doubleclick.net/clk;220427664;42510811;u?",
"clicktracker_empl":"http://ad.doubleclick.net/clk;220427764;42510811;v?",
"lid":"377,382,385",
"tabtracker":"http://ad.doubleclick.net/clk;220428876;42510811;a?",
"tabsearchtracker":"http://ad.doubleclick.net/clk;220428876;42510811;a?",
"bdwidget":"http://ad.doubleclick.net/clk;220429258;42510811;v?",
"findajob":"http://ad.doubleclick.net/clk;220428654;42510811;u?",
"fixedwidgets":"http://ad.doubleclick.net/clk;220428462;42510811;r?",
"misc":"http://ad.doubleclick.net/clk;220428279;42510811;x?",
"stlinks":"http://ad.doubleclick.net/clk;220880537;42510811;w?",
"fbelt":"http://ad.doubleclick.net/clk;220880768;42510811;c?",
"slideshow":"http://ad.doubleclick.net/clk;220429046;42510811;q?"},
"monster":{
"lid":"377,382,385"},
"rhg":{
"clicktracker":"http://ad.doubleclick.net/clk;220359546;42510811;x?",
"tabtracker":"http://ad.doubleclick.net/clk;220530087;42510811;o?",
"tabtoptracker":"http://ad.doubleclick.net/clk;220530087;42510811;o?",
"bdwidget":"http://ad.doubleclick.net/clk;220537441;42510811;p?",
"stlinks":"http://ad.doubleclick.net/clk;220705985;42510811;z?",
"fbelt":"http://ad.doubleclick.net/clk;220706136;42510811;o?",
"cp_clicktracker":"http://ad.doubleclick.net/clk;220529190;42510811;r?",
"eh_clicktracker":"http://ad.doubleclick.net/clk;220362409;42510811;p?",
"eh_fbelt":"http://ad.doubleclick.net/clk;220706694;42510811;x?",
"eh_stlinks":"http://ad.doubleclick.net/clk;220541032;42510811;g?",
"eh_bdwidget":"http://ad.doubleclick.net/clk;220537722;42510811;r?",
"eh_tabtracker":"http://ad.doubleclick.net/clk;220536580;42510811;s?",
"wte_clicktracker":"http://ad.doubleclick.net/clk;220527643;42510811;s?",
"wte_fbelt":"http://ad.doubleclick.net/clk;220540986;42510811;x?",
"wte_stlinks":"http://ad.doubleclick.net/clk;220719308;42510811;t?",
"wte_bdwidget":"http://ad.doubleclick.net/clk;220538535;42510811;u?",
"wte_tabtracker":"http://ad.doubleclick.net/clk;220537008;42510811;o?",
"diet_jm_clicktracker":"http://ad.doubleclick.net/clk;220362793;42510811;v?",
"diet_jm_bdwidget":"http://ad.doubleclick.net/clk;220538059;42510811;v?",
"diet_jm_tabtracker":"http://ad.doubleclick.net/clk;220536766;42510811;y?",
"editorial":"http://ad.doubleclick.net/clk;220572656;42510811;w?",
"misc_eh":"http://ad.doubleclick.net/clk;220540727;42510811;q?"},
"rtrac":{
"clicktracker":"http://ad.doubleclick.net/clk;220508274;42510811;r?"},
"srvmg":{
"clicktracker":"http://ad.doubleclick.net/clk;220426717;42510811;s?"},
"sureh":{
"lwl":"http://ad.doubleclick.net/clk;220422519;42510811;o?",
"clicktracker":"http://ad.doubleclick.net/clk;220422519;42510811;o?",
"rotatingwidget":"http://ad.doubleclick.net/clk;220425485;42510811;t?",
"widgetlanding":"http://ad.doubleclick.net/clk;220483173;42510811;r?",
"tabbox":"http://ad.doubleclick.net/clk;220427420;42510811;k?",
"stlinks":"http://ad.doubleclick.net/clk;220426839;42510811;x?"},
"tripa":{
"mcode":"10755",
"subdomain":"wftv"},
"tripadvisor":{
"id":"10755",
"subdomain":"wftv"},
"tzoo":{
"ac":"MCO",
"tabtracker":"http://ad.doubleclick.net/clk;220421398;42510811;s?",
"fbelt":"http://ad.doubleclick.net/clk;220424538;42510811;r?",
"stlinks":"http://ad.doubleclick.net/clk;220424364;42510811;o?",
"clicktracker":"http://ad.doubleclick.net/clk;220421544;42510811;l?",
"promo":"Cox/LWL/L17/L17/2019737928/x92/TZOO/631040-535--5-Nt5-DayDisneyRoomT/creative.html/4a6d646e326b7078723759414169444e",
"misc":"http://ad.doubleclick.net/clk;220421852;42510811;n?"},
"bd":{
"owner":"Cox"},
"autotrader":{
"number":"050",
"id":"IBSCOBRNDSITE050",
"sell":"IBSCOBRNDSYC0050",
"coxid":"001"},
"autot":{
"number":"050",
"id":"IBSCOBRNDSITE050",
"sell":"IBSCOBRNDSYC0050",
"coxid":"001"},
"quantcast":{
"id":{
"code":"p-41jrVeSPpekVU",
"label":"Cox Television Stations",
"urlencodedlabel":"Cox%20Television%20Stations%20",
"display":"true"}},
"yahoo":{
"verify":"ec2de34538c2d4b0"},
"roommateservice":{
"tracker_id":"3848"},
"careerbuilder":{
"tracker_id":"4078"},
"moviesearch":{
"zip":"32801"},
"mailforms":{
"email":"brett.bowman:icFevents"},
"titantv":{
"id1":"52999",
"id2":"53000"},
"cheaptickets":{
"tracker_id":"4176"},
"WT_info":{
"id":"dcsni6zdb00000wg2qtdmqirt_7m3y"},
"tacoda":{
"id":"13742"}},
"video":{
"playerversion":"5",
"skin":"blue",
"wxicons":"cox",
"cpcode":"12939",
"liveflashcpcode":"51587",
"availableskins":{
"skin":{
"name":"blue",
"path":"blue"},
"skin":{
"name":"gray",
"path":"gray"}}},
"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":"820",
"top":"0",
"left":"0",
"dynamic_url":"/slideshow[ibs_variable type=iburl att=sectionpath][ibs_variable type=iburl att=coid]/detail.html"},
"mt":{
"name":"quiz",
"mtid":"81",
"method":"popup",
"width":"738",
"height":"460",
"top":"50",
"left":"50",
"dynamic_url":"/sh/quizine/[ibs_variable type=iburl att=coid]/index.html"},
"mt":{
"name":"image",
"mtid":"61",
"method":"popup",
"top":"0",
"left":"0",
"dynamic_url":"/image/[ibs_variable type=iburl att=coid]/detail.html"}},
"search":{
"keywordlist":{
"id":"21339855"},
"defaultSearchType":"site"},
"kickapps":{
"as":"6696"},
"comscore":{
"id":"6035944"}};


// 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()}
}



eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('1h 1g(c){2 e=1f;2 f=1e;2 d=0;j((b(3.m)!="8"&&3.m<f+1d)||(b(3.l)!="8"&&3.l<e+10)){d=1}2 k="1c="+f+",1b="+e+",1a=0,19="+d+",18=0,17=0,16=0,15=0,14=0,13=0";9=12.11("Z://Y.X.W.V/U/6?c="+c.T(),\'S\',k);j(9==R||b(9)=="8"){Q("P! O i N a 5 4 M L\'s K J 7 6.\\n\\I H \'G\' F E h g 5 4 D C B.\\n(A: z y x 7 w v u t r q 7 6 - p i o h g 5 4)")}}',62,80,'||var|screen|blocker|popup|player|the|undefined|win||typeof|aff|ifScrollBar|popupWidth|popupHeight|your|disable|might|if|popupParams|availWidth|availHeight||temporarily|it|launch|to||clicking|when|key|Ctrl|down|holding|try|HINT|again|trying|before|then|below|OK|click|nPlease|with|interfering|that|enabled|have|You|Oops|alert|null|abcfesplayer_window|toLowerCase|streaming|com|go|abc|dynamic|http||open|window|left|top|resizable|menubar|statusbar|location|scrollbars|toolbar|width|height|49|675|1000|openFEP|function'.split('|')))


// End national_js scripts

