
/*  scripts */
// Begin scripts


var bEnv = {
  MacIE: ((navigator.userAgent.indexOf("IE")  > -1) && (navigator.userAgent.indexOf("Mac")  > -1)) ? 1 : 0
};



/*	Implement array.push for browsers which don't support it natively.
	Please remove this if it's already in other code */
if(Array.prototype.push == null) {
	Array.prototype.push = function() {
		for(var i = 0; i < arguments.length; i++) {
			this[this.length] = arguments[i];
		};
		return this.length;
	};
};

/**
 * Add/Remove Event Listeners
 **/
var Events = {
	addEvent: function(el, evType, fn, useCapture) {
		if(Events) Events.addtoList(el, evType, fn);
		if (el.addEventListener) {
			el.addEventListener(evType, fn, useCapture);
			return true;
		} else if (el.attachEvent) {
			var r = el.attachEvent("on"+evType, fn);
			return r;
		} else {
			return el["on" + evType] = fn;
		}
	},
	
	// Remove event listeners
	removeEvent: function(el, evType, fn) {
		if (el.removeEventListener) {
			el.removeEventListener(evType, fn, false);
			return true;
		} else if (el.detachEvent) {
			var r = el.detachEvent("on"+evType, fn);
			return r;
		} else {
			return el["on" + evType] = null;
		}
	},
	
	// list events
	eventList: [],
	// add event to list
	addtoList: function(el, evType, fn) {
		Events.eventList.push(arguments);
	},
	// run through array and detach events
	removeEvents: function() {
		for (var i = Events.eventList.length-1; i >= 0; i--) {
			var obj = Events.eventList[i];
			Events.removeEvent(obj[0], obj[1], obj[2]);
		}
	}
};
// remove events when window is unloaded
Events.addEvent(window, "unload", Events.removeEvents, false);
// called at bottom of each page
function domLoaded(){
}



//  Cookie parser
var IBCookies = new Object();
IBCookies.cookies = new Object();
IBCookies.host = document.domain;
var __tmp = document.domain.split( '.');
IBCookies.domain = __tmp[__tmp.length-2] + '.' + __tmp[__tmp.length-1];

var tmp = document.cookie.split( '; ');
for( var i=0; i < tmp.length; ++i) {
  try {
		var tmp1 = tmp[i].split( '=');
		if( tmp1[1] == null) tmp1[1] = '';
		IBCookies.cookies[tmp1[0].toLowerCase()] = tmp1[1];
	} catch( e) {}
}
IBCookies.get = function( name) {
	if( name == null) return null;
	name = name.toLowerCase();
	if( IBCookies.cookies && IBCookies.cookies[name] != null) return IBCookies.cookies[name];
	return null;
}
IBCookies.set = function( name, value, expires, domain, path, secure) {
	if( expires == null) {
		var exp = new Date();
		exp.setTime( exp.getTime() + 630720000000);
		expires = exp.toGMTString();
	} else if( expires.charAt( 0) == '+') {
		var exp = new Date();
		exp.setTime( exp.getTime() + (86400000 * expires)); // 10 days in the future
		expires = exp.toGMTString();
	}
	if( domain == null || domain == 'undefined' || domain == 'domain') domain = this.domain;
	else if( domain == 'host') domain = this.host;
	if( path == null) path = '/';
	IBCookies.cookies[name.toLowerCase()] = value; 
	document.cookie = name + '=' + value + '; expires=' + expires + '; domain=' + domain + '; path=' + path;
}
IBCookies.nuke = function( name) {
  if( name == null) return;
	name = name.toLowerCase();
	delete IBCookies.cookies[name];
	document.cookie = name + '=; expires=Sat, 1 Jan 2005 00:00:01 UTC; domain=' + IBCookies.host + '; path=/'
	document.cookie = name + '=; expires=Sat, 1 Jan 2005 00:00:01 UTC; domain=' + IBCookies.domain + '; path=/'
}



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.onreadystatechange = function() {
			/* Opera may return status 304; unchanged */
			if(req.readyState == 4 ) {
				handler(req.responseXML, req.responseText);
			}
		};
		req.send(params);
	}
};



/** 
 * Rollover 
 **/
function initRollOvers(ulid) {
	if (!document.getElementById || !document.getElementsByTagName || !document.getElementsByName || !Events || !document.getElementById(ulid)) return;
	
	var ul = document.getElementById(ulid).getElementsByTagName("img");
	var preloads = new Object();
	for (var i = ul.length-1; i >= 0; i--) {
		preloads["off" + ul[i].id] = new Image;
		preloads["off" + ul[i].id].src = ul[i].src;
		preloads["on" + ul[i].id] = new Image;
		preloads["on" + ul[i].id].src = ul[i].src.replace(/off/, "on");
		Events.addEvent(ul[i], "mouseover", function (e) { var t = window.event ? window.event.srcElement : e ? e.currentTarget : null; t.src = preloads["on" + t.id].src; }, false );
		Events.addEvent(ul[i], "mouseout", function (e) { var t = window.event ? window.event.srcElement : e ? e.currentTarget : null; t.src = preloads["off" + t.id].src; }, false );
	}
}

Events.addEvent(window, "load", function() { initRollOvers("mainnav"); }, false);

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

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

// Use with pulldown display of index
function redirectIndexPulldown(el) {
	if(el[el.selectedIndex].value == '') {
		return false;
	} else if (el[el.selectedIndex].value.indexOf('NW:') == 0) {
		child = window.open(el[el.selectedIndex].value.substring(3));
	} else {
		window.location.href = el[el.selectedIndex].value;
		
	}
}

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

//Fix PNG images in IE
function fixPngImage(p) {
	var imgsrc;
	var trans = "/images/structures/misc/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 PNG
	   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;
	   }
   }
}

// Ad variables
var dcadposition, segQS, adid;



rollups = [['KMTX','KMTR'],['KMTZ','KMTR'],['KNDU','KNDO'],['KSNC','KSN'],['KSNG','KSN'],['KSNK','KSN'],['KSNW','KSN'],['KNAZ','KPNX'],['KYUS','KULR'],['WNNE','WPTZ'],['KOBF','KOB'],['KOBG','KOB'],['KOBR','KOB'],['KBZ','KTVM'],['KXAM','KXAN'],['KFTA','KNWA'],['KWAB','KWES'],['KHBC','KHNL'],['KOGG','KHNL'],['WTOM','WPBN'],['KBAO','KTVH'],['KBBJ','KTVH'],['KBGF','KTVH'],['KSWY','KCWY'],['KCHY','KCWY'],['KLK','KCWY'],['KENV','KRNV'],['KWNV','KRNV']]
oly_affs = new Array();
function oly_aff(calls, isactive, unique, name, market, tz, city, state, zip) {
	this.calls = calls.toLowerCase();
	this.isactive = isactive;
	this.unique = unique;
	this.name = name;
	this.market = market;
	this.tz= tz;
	this.city = city;
	this.state = state;
	this.zip = zip;
	this.parent = null;
}
/* Call Letters','Participating','Unique Olympic Zone','Preferred Name','Time Zone','City','State','ZIP' */
oly_affs[oly_affs.length] = new oly_aff('KARK',false,true,'','Little Rock-Pine Bluff','Central','Little Rock','AR','72201');
oly_affs[oly_affs.length] = new oly_aff('KATH',false,true,'','Juneau','Alaska','Juneau','AK','99801');
oly_affs[oly_affs.length] = new oly_aff('KDK',false,false,'','Lead-Deadwood','Mountain','','SD','');
oly_affs[oly_affs.length] = new oly_aff('KDLT',false,true,'','Sioux Falls','Central','Soiux Falls','SD','57106');
oly_affs[oly_affs.length] = new oly_aff('KDLV',false,false,'','Mitchell','Central','Soiux Falls','SD','57106');
oly_affs[oly_affs.length] = new oly_aff('KIEM',false,true,'','Eureka','Pacific','','CA','');
oly_affs[oly_affs.length] = new oly_aff('KLSB',false,true,'','Nacogdoches','','','TX','');
oly_affs[oly_affs.length] = new oly_aff('KMCC',false,false,'','Laughlin','','','NV','');
oly_affs[oly_affs.length] = new oly_aff('KNBN',false,true,'','Rapid City','Mountain','Rapid City','SD','57702');
oly_affs[oly_affs.length] = new oly_aff('KOAA',false,true,'','Colorado Springs-Pueblo','Mountain','Pueblo','CO','81003');
oly_affs[oly_affs.length] = new oly_aff('KSCT',false,true,'','Sitka','Alaska','Sitka','AK','99835');
oly_affs[oly_affs.length] = new oly_aff('KTTC',false,true,'','Rochester-Mason City-Austin','Central','Rochester','MN','55901');
oly_affs[oly_affs.length] = new oly_aff('KTVE',false,true,'','El Dorado&#44;AR/Monroe','Central','','LA','');
oly_affs[oly_affs.length] = new oly_aff('KXGN',false,true,'','Glendive','Mountain','','MT','');
oly_affs[oly_affs.length] = new oly_aff('WCYB',false,true,'','Tri-Cities','Eastern','Bristol','VA','24201');
oly_affs[oly_affs.length] = new oly_aff('WETM',false,true,'','Elmira','Eastern','','NY','');
oly_affs[oly_affs.length] = new oly_aff('WGBC',false,true,'','Meridian','Central','Meridian','MS','39301');
oly_affs[oly_affs.length] = new oly_aff('WHO',false,true,'WHO-TV 13','Des Moines-Ames','Central','Des Moines ','IA','50309');
oly_affs[oly_affs.length] = new oly_aff('WICD',false,true,'','Champaign-Decatur','Central','','IL','');
oly_affs[oly_affs.length] = new oly_aff('WLIO',false,true,'','Lima','Eastern','Lima','OH','45805');
oly_affs[oly_affs.length] = new oly_aff('WLTZ',false,true,'','Columbus','Eastern','Columbus','GA','31907');
oly_affs[oly_affs.length] = new oly_aff('WTVA',false,true,'','Tupelo-Columbus-West Point','Central','Tupelo','MS','38802');
oly_affs[oly_affs.length] = new oly_aff('WTWO',false,true,'','Terre Haute','Eastern','','IN','');
oly_affs[oly_affs.length] = new oly_aff('KALB',true,true,'KALB TV 5','Alexandria&#44; LA','Central','Alexandria','LA','71301');
oly_affs[oly_affs.length] = new oly_aff('KAMR',true,true,'KAMR NBC 4','Amarillo','Central','Amarillo','TX','79101');
oly_affs[oly_affs.length] = new oly_aff('KARE',true,true,'KARE 11','Minneapolis-St. Paul','Central','Golden Valley','MN','55427');
oly_affs[oly_affs.length] = new oly_aff('KBAO',true,false,'','Lewiston','','','MT','');
oly_affs[oly_affs.length] = new oly_aff('KBBJ',true,false,'','Harve','','','MT','');
oly_affs[oly_affs.length] = new oly_aff('KBGF',true,false,'NBC6/50','Beartooth NBC - Great Falls / Havre / Lewistown','Mountain','Helena','MT','59601');
oly_affs[oly_affs.length] = new oly_aff('KBJR',true,true,'NBC 6','Duluth-Superior','Central','Duluth','MN','55802');
oly_affs[oly_affs.length] = new oly_aff('KBTV',true,true,'KBTV 4','Beaumont/Port Arthur','Central','Beaumont','TX','77706');
oly_affs[oly_affs.length] = new oly_aff('KBZ',true,false,'','Bozeman','Mountain','','MT','');
oly_affs[oly_affs.length] = new oly_aff('KCBD',true,true,'KCBD11','NewsChannel 11 / Lubbock','Central','Lubbock','TX','79404');
oly_affs[oly_affs.length] = new oly_aff('KCEN',true,true,'NBC 6','Central Texas','Central','Temple','TX','76503');
oly_affs[oly_affs.length] = new oly_aff('KCFW',true,true,'KCFW 9','Kalispell&#39;s News Channel','Mountain','Missoula','MT','59802');
oly_affs[oly_affs.length] = new oly_aff('KCHY',true,false,'','Cheyenne','','','WY','');
oly_affs[oly_affs.length] = new oly_aff('KCRA',true,true,'KCRA 3','Sacramento-Stockton-Modesto','Pacific','Sacramento','CA','95814');
oly_affs[oly_affs.length] = new oly_aff('KCWY',true,true,'News 13','Casper','Mountain','Mills ','WY','82644');
oly_affs[oly_affs.length] = new oly_aff('KECI',true,true,'KECI 13','Missoula&#39;s News Channel','Mountain','Missoula','MT','59802');
oly_affs[oly_affs.length] = new oly_aff('KENV',true,false,'','Elko','Pacific','','NV','');
oly_affs[oly_affs.length] = new oly_aff('KETK',true,true,'KETK 56','Tyler/Longview','Central','Tyler','TX','75703');
oly_affs[oly_affs.length] = new oly_aff('KFDX',true,true,'KFDX 3','Wichita Falls-Lawton','Central','Wichita Falls','TX','76309');
oly_affs[oly_affs.length] = new oly_aff('KFOR',true,true,'News 4','Oklahoma City','Central','Oklahoma City','OK','73114');
oly_affs[oly_affs.length] = new oly_aff('KFTA',true,false,'','Ft. Smith-Fayetteville-Springdale-Rogers','Central','','AR','');
oly_affs[oly_affs.length] = new oly_aff('KFYR',true,true,'KFYR-TV','Bismarck','Central','Bismarck','ND','58501');
oly_affs[oly_affs.length] = new oly_aff('KGET',true,true,'KGET 17','Bakersfield','Pacific','Bakersfield','CA','93301');
oly_affs[oly_affs.length] = new oly_aff('KGNS',true,true,'KGNS TV-8','Laredo','Central','Laredo','TX','78045');
oly_affs[oly_affs.length] = new oly_aff('KGW',true,true,'KGW','Portland / Vancouver / Salem','Pacific','Portland','OR','97201');
oly_affs[oly_affs.length] = new oly_aff('KHAS',true,true,'KHAS-TV','Hastings-Grand Island-Kearney','Central','Hastings','NE','68901');
oly_affs[oly_affs.length] = new oly_aff('KHBC',true,false,'','Hilo','Hawaiian','','HI','');
oly_affs[oly_affs.length] = new oly_aff('KHNL',true,true,'KHNL NBC 8','Honolulu','Hawaiian','Honolulu','HI','96819');
oly_affs[oly_affs.length] = new oly_aff('KHQ',true,true,'KHQ 6','The Inland Northwest','Pacific','Spokane','WA','99201');
oly_affs[oly_affs.length] = new oly_aff('KING',true,true,'KING 5','Seattle/Tacoma','Pacific','Seattle','WA','98109');
oly_affs[oly_affs.length] = new oly_aff('KJRH',true,true,'2 KJRH','Tulsa','Central','Tulsa','OK','74105');
oly_affs[oly_affs.length] = new oly_aff('KJWY',true,true,'KJWY NBC 2','Jackson Hole','Mountain','Jackson','WY','83002');
oly_affs[oly_affs.length] = new oly_aff('KKCO',true,true,'NBC 11','Grand Junction-Montrose','Mountain','Grand Junction','CO','81505');
oly_affs[oly_affs.length] = new oly_aff('KLK',true,false,'','Laramie','','','WY','');
oly_affs[oly_affs.length] = new oly_aff('KMAY',true,true,'KMAY 23','Bryan/College Station&#44; TX ','Central','College Station','TX','75702');
oly_affs[oly_affs.length] = new oly_aff('KMIR',true,true,'KMIR6','PALM SPRINGS','Pacific','Palm Desert','CA','92260');
oly_affs[oly_affs.length] = new oly_aff('KMOL',true,true,'KMOL','N B C Victoria','Central','Victoria','TX','77901');
oly_affs[oly_affs.length] = new oly_aff('KMOT',true,true,'KMOT-TV','Minot','Central','Minot','ND','58701');
oly_affs[oly_affs.length] = new oly_aff('KMTR',true,true,'KMTR NewsSource 16','Eugene/Springfield','Pacific','Springfield','OR','97477');
oly_affs[oly_affs.length] = new oly_aff('KMTX',true,false,'','Roseburg','Pacific','','OR','');
oly_affs[oly_affs.length] = new oly_aff('KMTZ',true,false,'','Coos Bay','Pacific','','OR','');
oly_affs[oly_affs.length] = new oly_aff('KNAZ',true,false,'','Flagstaff','Mountain','','AZ','');
oly_affs[oly_affs.length] = new oly_aff('KNBC',true,true,'NBC4','Los Angeles','Pacific','Burbank','CA','94523');
oly_affs[oly_affs.length] = new oly_aff('KNDO',true,true,'KNDO KNDU','Yakima / Tri-Cities','Pacific','Yakima','WA','98902');
oly_affs[oly_affs.length] = new oly_aff('KNDU',true,false,'KNDU','Richland','Pacific','Kennewick','WA','99336');
oly_affs[oly_affs.length] = new oly_aff('KNOP',true,true,'KNOP-TV News 2','Greater Nebraska Television&#44; KNOP-TV&#44; NEWS 2 Coverage You Can','Central','North Platte','NE','69101');
oly_affs[oly_affs.length] = new oly_aff('KNSD',true,true,'NBC 7/39','San Diego','Pacific','San Diego','CA','92101');
oly_affs[oly_affs.length] = new oly_aff('KNTV',true,true,'NBC11','San Jose  Oakland  San Francisco','Pacific','San Jose','CA','95131-1002');
oly_affs[oly_affs.length] = new oly_aff('KNVN',true,true,'KNVN 24','Chico-Redding','Pacific','Chico','CA','95973');
oly_affs[oly_affs.length] = new oly_aff('KNWA',true,true,'KNWA','Northwest Arkansas News','Central','Fayetteville','AR','72701');
oly_affs[oly_affs.length] = new oly_aff('KOB',true,true,'KOB-TV','New Mexico','Mountain','Albuquerque','NM','87104');
oly_affs[oly_affs.length] = new oly_aff('KOBF',true,false,'','Farmington','Mountain','','NM','');
oly_affs[oly_affs.length] = new oly_aff('KOBG',true,false,'','Silver City','Pacific','','NM','');
oly_affs[oly_affs.length] = new oly_aff('KOBI',true,true,'KOBI NBC 5','Medford','Pacific','Medford ','OR','97501');
oly_affs[oly_affs.length] = new oly_aff('KOBR',true,false,'','Roswell','Mountain','','NM','');
oly_affs[oly_affs.length] = new oly_aff('KOGG',true,false,'','Wailuku','Hawaiian','','HI','');
oly_affs[oly_affs.length] = new oly_aff('KOMU',true,true,'KOMU-TV8','Mid-Missouri','Central','Columbia','MO','65201');
oly_affs[oly_affs.length] = new oly_aff('KOTI',true,true,'KOTI NBC 2','Klamath Falls','Pacific','Klamath Falls ','OR','97601');
oly_affs[oly_affs.length] = new oly_aff('KPLC',true,true,'KPLC','Lake Charles','Central',' Lake Charles','LA','70601');
oly_affs[oly_affs.length] = new oly_aff('KPNX',true,true,'Channel 12','Phoenix','Arizona','Phoenix','AZ','85004');
oly_affs[oly_affs.length] = new oly_aff('KPRC',true,true,'Local 2','Houston','Central','Houston','TX','77074');
oly_affs[oly_affs.length] = new oly_aff('KPVI',true,true,'NBC Newschannel 6','Pocatello-Idaho Falls','Mountain','Pocatello','ID','83204');
oly_affs[oly_affs.length] = new oly_aff('KQCD',true,true,'KQCD-TV','Dickinson','Mountain','Dickinson','ND','58602');
oly_affs[oly_affs.length] = new oly_aff('KRBC',true,true,'KRBC 9','Abilene','Central','Abilene','TX','79605');
oly_affs[oly_affs.length] = new oly_aff('KRIS',true,true,'KRISTV.COM','Corpus Christi','Central','Corpus Christi','TX','78401');
oly_affs[oly_affs.length] = new oly_aff('KRNV',true,true,'News 4','Reno','Pacific','Reno','NV','89502');
oly_affs[oly_affs.length] = new oly_aff('KSAN',true,true,'KSAN','San Angelo','Central','San Angelo','TX','76903');
oly_affs[oly_affs.length] = new oly_aff('KSBW',true,true,'KSBW','Monterey-Salinas-Santa Cruz  ','Pacific','Salinas','CA','93901');
oly_affs[oly_affs.length] = new oly_aff('KSBY',true,true,'KSBY 6','San Luis Obispo/Santa Maria/Santa Barbara','Pacific','San Luis Obispo','CA','93405');
oly_affs[oly_affs.length] = new oly_aff('KSDK',true,true,'NewsChannel 5','St. Louis','Central','St. Louis','MO','63101');
oly_affs[oly_affs.length] = new oly_aff('KSEE',true,true,'KSEE 24','Fresno-Visalia-Madera','Pacific','Fresno','CA','93727');
oly_affs[oly_affs.length] = new oly_aff('KSHB',true,true,'NBC Action News','Kansas City','Central','Kansas City','MO','64112');
oly_affs[oly_affs.length] = new oly_aff('KSL',true,true,'KSL 5 TV','Salt Lake City','Mountain','Salt Lake City','UT','84110');
oly_affs[oly_affs.length] = new oly_aff('KSN',true,true,'KSN','Wichita','Central','Wichita','KS','67203');
oly_affs[oly_affs.length] = new oly_aff('KSNC',true,false,'','Great Bend','Central','Wichita','KS','67203');
oly_affs[oly_affs.length] = new oly_aff('KSNF',true,true,'KSN','The Four States','Central','Joplin','MO','64801');
oly_affs[oly_affs.length] = new oly_aff('KSNG',true,false,'','Garden City','Central','Wichita','KS','67203');
oly_affs[oly_affs.length] = new oly_aff('KSNK',true,false,'','McCook/Oberlin','Central','Wichita','KS','67203');
oly_affs[oly_affs.length] = new oly_aff('KSNW',true,false,'KSN','Wichita','Central','Wichita','KS','69101');
oly_affs[oly_affs.length] = new oly_aff('KSNT',true,true,'27 News','Northeast Kansas','Central','Topeka ','KS','66618');
oly_affs[oly_affs.length] = new oly_aff('KSWY',true,false,'','Sheridan','Mountain','Mills ','WY','82644');
oly_affs[oly_affs.length] = new oly_aff('KTAL',true,true,'KTAL NewsChannel 6','Shreveport/Bossier-Texarkana-Marshall','Central','Shreveport','LA','71107');
oly_affs[oly_affs.length] = new oly_aff('KTEN',true,true,'KTEN 10','Texoma','Central','Denison','TX','75020');
oly_affs[oly_affs.length] = new oly_aff('KTFT',true,true,'KTFT 38','Twin Falls','Mountain','Boise ','ID','83707');
oly_affs[oly_affs.length] = new oly_aff('KTIV',true,true,'KTIV','Sioux City','Central','Sioux City','IA','51108');
oly_affs[oly_affs.length] = new oly_aff('KTSM',true,true,'NBC 9','El Paso - Las Cruces - Juarez','Mountain','El Paso','TX','79902');
oly_affs[oly_affs.length] = new oly_aff('KTUU',true,true,'KTUU-TV','Anchorage&#44; Alaska','Alaskan','Anchorage','AK','99503');
oly_affs[oly_affs.length] = new oly_aff('KTVB',true,true,'KTVB 7','Boise','Mountain','Boise','ID','83707');
oly_affs[oly_affs.length] = new oly_aff('KTVF',true,true,'KTVF 11','Fairbanks','Alaskan','Fairbanks','AK','99701');
oly_affs[oly_affs.length] = new oly_aff('KTVH',true,true,'Beartooth NBC','Helena','Mountain','Helena','MT','59601');
oly_affs[oly_affs.length] = new oly_aff('KTVM',true,true,'KTVM 6 & 42','Butte & Bozeman&#39;s News Channel','Mountain','Missoula','MT','59802');
oly_affs[oly_affs.length] = new oly_aff('KTVZ',true,true,'NEWSCHANNEL 21','Central Oregon','Pacific','Bend','OR','97702');
oly_affs[oly_affs.length] = new oly_aff('KUAM',true,true,'KUAM TV8','Guam','GMT + 10','Dededo','GU','96929');
oly_affs[oly_affs.length] = new oly_aff('KULR',true,true,'KULR-8 TV','Billings','Mountain','Billings','MT','59102');
oly_affs[oly_affs.length] = new oly_aff('KUMV',true,true,'KUMV-TV','Williston','Central','Williston','ND','58801');
oly_affs[oly_affs.length] = new oly_aff('KUSA',true,true,'9NEWS','Denver','Mountain','Denver','CO','80203');
oly_affs[oly_affs.length] = new oly_aff('KVBC',true,true,'KVBC','Las Vegas','Pacific','Las Vegas','NV','89101');
oly_affs[oly_affs.length] = new oly_aff('KVEO',true,true,'NBC 23','Rio Grande Valley','Central','Brownsville ','TX','78521');
oly_affs[oly_affs.length] = new oly_aff('KVLY',true,true,'KVLY-TV11','Fargo-Grand Forks','Central','Fargo','ND','58103');
oly_affs[oly_affs.length] = new oly_aff('KVOA',true,true,'KVOA4','Southern Arizona','Mountain','Tucson','AZ','85705');
oly_affs[oly_affs.length] = new oly_aff('KWAB',true,false,'','Big Springs','Central','Big Springs','TX','');
oly_affs[oly_affs.length] = new oly_aff('KWES',true,true,'NewsWest 9','West Texas','Central','Midland','TX','79711');
oly_affs[oly_affs.length] = new oly_aff('KWNV',true,false,'','Winnemucca','Pacific','','NV','');
oly_affs[oly_affs.length] = new oly_aff('KWQC',true,true,'KWQC-TV6','Davenport-Quad Cities','Central','Davenport','IA','52803');
oly_affs[oly_affs.length] = new oly_aff('KWWL',true,true,'KWWL','Waterloo/Dubuque/Cedar Rapids/Iowa City','Central','Waterloo ','IA','50703');
oly_affs[oly_affs.length] = new oly_aff('KXAM',true,false,'','Llano','Central','','TX','');
oly_affs[oly_affs.length] = new oly_aff('KXAN',true,true,'NBC Austin','Austin','Central','Austin','TX','78701');
oly_affs[oly_affs.length] = new oly_aff('KXAS',true,true,'NBC 5 ','Dallas-Fort Worth','Central','Fort Worth','TX','76103');
oly_affs[oly_affs.length] = new oly_aff('KYMA',true,true,'KYMA 11 ','Yuma-El Centro','Mountain','Yuma','AZ','85365');
oly_affs[oly_affs.length] = new oly_aff('KYTV',true,true,'KY3','Springfield&#44; MO','Central','Springfield','MO','65807');
oly_affs[oly_affs.length] = new oly_aff('KYUS',true,false,'','Miles City','Mountain','','MT','');
oly_affs[oly_affs.length] = new oly_aff('TEST',true,true,'TEST NBC 12','NBC','Central','Mendota Heights','MN','55120');
oly_affs[oly_affs.length] = new oly_aff('WAFF',true,true,'WAFF 48 ','Heart of the Valley','Central','Huntsville ','AL','35801');
oly_affs[oly_affs.length] = new oly_aff('WAGT',true,true,'NBC 26','Georgia Carolina','Eastern','Augusta','GA','30901');
oly_affs[oly_affs.length] = new oly_aff('WALB',true,true,'WALBNews10','Albany / Valdosta / Thomasville','Eastern','Albany','GA','31707');
oly_affs[oly_affs.length] = new oly_aff('WAND',true,true,'WANDTV NBC 17','Decatur Springfield Champaign','Central','Decatur','IL','62521');
oly_affs[oly_affs.length] = new oly_aff('WAVE',true,true,'WAVE 3','Louisville','Eastern','Louisville','KY','40203');
oly_affs[oly_affs.length] = new oly_aff('WAVY',true,true,'WAVY','Hampton Roads','Eastern','Portsmouth','VA','23704');
oly_affs[oly_affs.length] = new oly_aff('WBAL',true,true,'WBAL-TV 11','Baltimore','Eastern','Baltimore','MD','21211');
oly_affs[oly_affs.length] = new oly_aff('WBBH',true,true,'NBC2','Southwest Florida','Eastern','Ft. Myers','FL','33901');
oly_affs[oly_affs.length] = new oly_aff('WBGH',true,true,'NBC 5','Binghamton','Eastern','Binghamton','NY','13903');
oly_affs[oly_affs.length] = new oly_aff('WBIR',true,true,'Channel 10','East Tennessee','Eastern','Knoxville','TN','37917');
oly_affs[oly_affs.length] = new oly_aff('WBOY',true,true,'12 News','North Central West Virginia','Eastern','Clarksburg','WV','26301');
oly_affs[oly_affs.length] = new oly_aff('WBRE',true,true,'WBRE','Wilkes Barre-Scranton','Eastern','Wilkes-Barre','PA','18701');
oly_affs[oly_affs.length] = new oly_aff('WCAU',true,true,'NBC 10','Philadelphia','Eastern','Bala Cynwyd','PA','19004');
oly_affs[oly_affs.length] = new oly_aff('WCBD',true,true,'Count on 2','Charleston&#44; SC','Eastern','Mt. Pleasant','SC','29464');
oly_affs[oly_affs.length] = new oly_aff('WCMH',true,true,'NBC 4','Columbus','Eastern','Columbus','OH','43202');
oly_affs[oly_affs.length] = new oly_aff('WCNC',true,true,'WCNC-TV','Charlotte','Eastern','Charlotte','NC','28217');
oly_affs[oly_affs.length] = new oly_aff('WCSH',true,true,'WCSH 6','Portland','Eastern','Portland','ME','04101');
oly_affs[oly_affs.length] = new oly_aff('WDAM',true,true,'WDAM TV ','Laurel-Hattiesburg','Central','Hattiesburg','MS','39401');
oly_affs[oly_affs.length] = new oly_aff('WDIV',true,true,'Local 4','Detroit','Eastern','Detroit','MI','48226');
oly_affs[oly_affs.length] = new oly_aff('WDSU',true,true,'WDSU 6','New Orleans','Central','New Orleans','LA','70113');
oly_affs[oly_affs.length] = new oly_aff('WDTN',true,true,'WDTN-TV','Dayton','Eastern','Dayton','OH','45439');
oly_affs[oly_affs.length] = new oly_aff('WEAU',true,true,'WEAU-TV 13','Western Wisconsin','Central','Eau Claire','WI','54702');
oly_affs[oly_affs.length] = new oly_aff('WECT',true,true,'WECT TV6','Wilmington','Eastern','Wilmington','NC','28412');
oly_affs[oly_affs.length] = new oly_aff('WEEK',true,true,'WEEK','Peoria-Bloomington','Central','East Peoria ','IL','61611');
oly_affs[oly_affs.length] = new oly_aff('WESH',true,true,'WESH 2','Central Florida','Eastern','Winter Park','FL','32789');
oly_affs[oly_affs.length] = new oly_aff('WEYI',true,true,'WEYI 25','Flint / Saginaw / Midland / Bay City','Eastern','Clio','MI','48420');
oly_affs[oly_affs.length] = new oly_aff('WFIE',true,true,'14WFIE','Evansville Henderson Owensboro','Central','Evansville','IN','47720');
oly_affs[oly_affs.length] = new oly_aff('WFLA',true,true,'News Channel 8','Tampa-St. Petersburg-Sarasota','Eastern','Tampa','FL','33606');
oly_affs[oly_affs.length] = new oly_aff('WFMJ',true,true,'21 WFMJ','Youngstown','Eastern','Youngstown','OH','44503');
oly_affs[oly_affs.length] = new oly_aff('WGAL',true,true,'WGAL 8','Harrisburg/Lancaster/Lebanon/York','Eastern','Lancaster','PA','17603');
oly_affs[oly_affs.length] = new oly_aff('WGBA',true,true,'NBC26','Green Bay - Appleton','Central','Green Bay','WI','54313');
oly_affs[oly_affs.length] = new oly_aff('WGEM',true,true,'WGEM','Quincy-Hannibal-Keokuk','Central','Quincy','IL','62301');
oly_affs[oly_affs.length] = new oly_aff('WGRZ',true,true,'WGRZ-TV 2','Western New York','Eastern','Buffalo','NY','14202');
oly_affs[oly_affs.length] = new oly_aff('WHAG',true,true,'NBC25','NBC25 / NBC25.com','Eastern','Hagerstown','MD','21740');
oly_affs[oly_affs.length] = new oly_aff('WHDH',true,true,'WHDH-TV','Boston','Eastern','Boston','MA','02114');
oly_affs[oly_affs.length] = new oly_aff('WHEC',true,true,'NEWS 10NBC','Rochester&#44; New York','Eastern','Rochester','NY','14604');
oly_affs[oly_affs.length] = new oly_aff('WHIZ',true,true,'WHIZ-TV','Zanesville','Eastern','Zanesville','OH','43701');
oly_affs[oly_affs.length] = new oly_aff('WICU',true,true,'WICU 12','Erie','Eastern','Erie','PA','16508');
oly_affs[oly_affs.length] = new oly_aff('WILX',true,true,'WILX-TV 10','Mid-Michigan','Eastern','Lansing','MI','48911');
oly_affs[oly_affs.length] = new oly_aff('WIS',true,true,'WIS 10','Columbia','Eastern','Columbia','SC','29201');
oly_affs[oly_affs.length] = new oly_aff('WISE',true,true,'NBC 33','Fort Wayne','Eastern','Fort Wayne','IN','46808');
oly_affs[oly_affs.length] = new oly_aff('WITN',true,true,'WITN','Washington - Greenville - New Bern','Eastern','Washington','NC','27889');
oly_affs[oly_affs.length] = new oly_aff('WJAC',true,true,'WJAC-TV','Johnstown-Altoona-State College','Eastern','Johnstown','PA','15905');
oly_affs[oly_affs.length] = new oly_aff('WJAR',true,true,'NBC 10','Providence - New Bedford','Eastern','Cranston','RI','02920');
oly_affs[oly_affs.length] = new oly_aff('WJFW',true,true,'WJFW NBC12','Rhinelander/Wausau','Central','Rhinelander','WI','54501');
oly_affs[oly_affs.length] = new oly_aff('WJHG',true,true,'WJHG','Panama City','Central','Panama City Beach','FL','32407');
oly_affs[oly_affs.length] = new oly_aff('WKTV',true,true,'NEWSChannel 2','Utica','Eastern','Utica','NY','13502');
oly_affs[oly_affs.length] = new oly_aff('WKYC',true,true,'WKYC','Cleveland','Eastern','Cleveland','OH','44114');
oly_affs[oly_affs.length] = new oly_aff('WLBT',true,true,'WLBT 3','Jackson','Central','Jackson','MS','39201');
oly_affs[oly_affs.length] = new oly_aff('WLBZ',true,true,'WLBZ 2','Bangor','Eastern','Bangor','ME','04401');
oly_affs[oly_affs.length] = new oly_aff('WLEX',true,true,'LEX 18','Lexington','Eastern','Lexington','KY','40505');
oly_affs[oly_affs.length] = new oly_aff('WLUC',true,true,'TV6','Upper Michigan&#39;s News Leader','Eastern','Negaunee','MI','49866');
oly_affs[oly_affs.length] = new oly_aff('WLWT',true,true,'News 5','Cincinnati','Eastern','Cincinnati','OH','45210');
oly_affs[oly_affs.length] = new oly_aff('WMAQ',true,true,'NBC5','Chicago','Central','Chicago','IL','60611');
oly_affs[oly_affs.length] = new oly_aff('WMC',true,true,'WMC-TV5','Memphis','Central','Memphis','TN','38104');
oly_affs[oly_affs.length] = new oly_aff('WMGM',true,true,'NBC 40','South Jersey','Eastern','Linwood','NJ','08221');
oly_affs[oly_affs.length] = new oly_aff('WMGT',true,true,'41NBC','Macon','Eastern','Macon','GA','31201');
oly_affs[oly_affs.length] = new oly_aff('WMTV',true,true,'NBC15','Madison','Central','Madison','WI','53711');
oly_affs[oly_affs.length] = new oly_aff('WNBC',true,true,'NBC4','New York','Eastern','New York','NY','10112');
oly_affs[oly_affs.length] = new oly_aff('WNCN',true,true,'NBC17','Raleigh Durham, Chapel Hill, Fayetteville','Eastern','Raleigh','NC','27609');
oly_affs[oly_affs.length] = new oly_aff('WNDU',true,true,'WNDU-TV','South Bend','Eastern','South Bend','IN','46637');
oly_affs[oly_affs.length] = new oly_aff('WNKY',true,true,'NBC 40','Bowling Green and Glasgow','Central','Bowling Green','KY','42101');
oly_affs[oly_affs.length] = new oly_aff('WNNE',true,false,'WNNE','Burlington','Eastern','White River Junction','VT','05001');
oly_affs[oly_affs.length] = new oly_aff('WNWO',true,true,'NBC 24','Toledo','Eastern','Toledo','OH','43615');
oly_affs[oly_affs.length] = new oly_aff('WNYT',true,true,'WNYT','NewsChannel 13 - WNYT Albany','Eastern','Albany','NY','12204');
oly_affs[oly_affs.length] = new oly_aff('WOAI',true,true,'News 4 WOAI','San Antonio','Central','San Antonio','TX','78205');
oly_affs[oly_affs.length] = new oly_aff('WOOD',true,true,'WOOD TV8','West Michigan','Eastern','Grand Rapids','MI','49503');
oly_affs[oly_affs.length] = new oly_aff('WOWT',true,true,'CHANNEL 6','Omaha','Central','Omaha','NE','68131');
oly_affs[oly_affs.length] = new oly_aff('WPBN',true,true,'TV 7&4','Traverse City - Cadillac - Cheboygan - Petoskey','Eastern','Traverse City','MI','49685');
oly_affs[oly_affs.length] = new oly_aff('WPMI',true,true,'NBC 15','WPMI TV/DT Mobile - Pensacola   ','Central','Mobile','AL','36609');
oly_affs[oly_affs.length] = new oly_aff('WPSD',true,true,'WPSD NewsChannel 6','Paducah','Central','Paducah','KY','42003');
oly_affs[oly_affs.length] = new oly_aff('WPTV',true,true,'WPTV','Palm Beaches and Treasure Coast','Eastern','West Palm Beach','FL','33401');
oly_affs[oly_affs.length] = new oly_aff('WPTZ',true,true,'WPTZ/WNNE','Burlington Plattsburgh','Eastern','Plattsburgh','NY','12901');
oly_affs[oly_affs.length] = new oly_aff('WPXI',true,true,'WPXI','Pittsburgh','Eastern','Pittsburgh','PA','15214');
oly_affs[oly_affs.length] = new oly_aff('WRC',true,true,'NBC4','Washington&#44; DC','Eastern','Washington','DC','20016');
oly_affs[oly_affs.length] = new oly_aff('WRCB',true,true,'Channel 3','Chattanooga','Eastern','Chattanooga','TN','37405');
oly_affs[oly_affs.length] = new oly_aff('WREX',true,true,'WREX','Rockford','Central','Rockford','IL','61103');
oly_affs[oly_affs.length] = new oly_aff('WSAV',true,true,'WSAV 3','Savannah/Hilton Head','Eastern','Savannah','GA','31404');
oly_affs[oly_affs.length] = new oly_aff('WSAZ',true,true,'WSAZ','Charleston-Huntington','Eastern','Huntington','WV','25714');
oly_affs[oly_affs.length] = new oly_aff('WSFA',true,true,'WSFA 12','Montgomery','Central','Montgomery','AL','36105');
oly_affs[oly_affs.length] = new oly_aff('WSLS',true,true,'WSLS Newschannel 10','Roanoke-Lynchburg','Eastern','Roanoke','VA','24011');
oly_affs[oly_affs.length] = new oly_aff('WSMV',true,true,'Channel 4 News','Nashville','Central','Nashville ','TN','37209');
oly_affs[oly_affs.length] = new oly_aff('WSTM',true,true,'NBC 3','Central New York','Eastern','Syracuse','NY','13203');
oly_affs[oly_affs.length] = new oly_aff('WTAP',true,true,'WTAP','Parkersburg-Marietta','Eastern','Parkersburg','WV','26101');
oly_affs[oly_affs.length] = new oly_aff('WTHR',true,true,'Channel 13','Indiana&#39;s News Leader','Eastern','Indianapolis','IN','46204');
oly_affs[oly_affs.length] = new oly_aff('WTLV',true,true,'WTLV-NBC12','Jacksonville ','Eastern','Jacksonville','FL','32202');
oly_affs[oly_affs.length] = new oly_aff('WTMJ',true,true,'TMJ4','Milwaukee','Central','Milwaukee','WI','53212');
oly_affs[oly_affs.length] = new oly_aff('WTOM',true,false,'','Cheboygan','Eastern','Traverse City','MI','49685');
oly_affs[oly_affs.length] = new oly_aff('WTOV',true,true,'WTOV9','Ohio Valley','Eastern','Steubenville ','OH','43952');
oly_affs[oly_affs.length] = new oly_aff('WTVJ',true,true,'NBC 6','South Florida','Eastern','Miramar','FL','33027');
oly_affs[oly_affs.length] = new oly_aff('WTWC',true,true,'WTWC NBC40','Tallahassee','Eastern','Tallahassee','FL','32312');
oly_affs[oly_affs.length] = new oly_aff('WVGN',true,true,'WVGN-NBC','Virgin Islands','Atlantic (GMT - 4)','St. Thomas','USVI','00802');
oly_affs[oly_affs.length] = new oly_aff('WVIR',true,true,'NBC29','Charlottesville','Eastern','Charlottesville','VA','22902');
oly_affs[oly_affs.length] = new oly_aff('WVIT',true,true,'NBC 30','NBC 30 News','Eastern','West Hartford','CT','06110');
oly_affs[oly_affs.length] = new oly_aff('WVLA',true,true,'NBC 33','Baton Rouge','Central','Baton Rouge','LA','70810');
oly_affs[oly_affs.length] = new oly_aff('WVTM',true,true,'NBC13','Birmingham Anniston Tuscaloosa','Central','Birmingham','AL','35209');
oly_affs[oly_affs.length] = new oly_aff('WVVA',true,true,'ChannelSix','Bluefield&#44; Beckley&#44; Oak Hill','Eastern','Bluefield','WV','24701');
oly_affs[oly_affs.length] = new oly_aff('WWBT',true,true,'NBC12','Richmond','Eastern','Richmond','VA','23218');
oly_affs[oly_affs.length] = new oly_aff('WWLP',true,true,'22News','Western Massachusetts','Eastern','Springfield','MA','01102-2210');
oly_affs[oly_affs.length] = new oly_aff('WXIA',true,true,'11ALIVE','Atlanta','Eastern','Atlanta','GA','30309');
oly_affs[oly_affs.length] = new oly_aff('WXII',true,true,'WXII 12','Winston-Salem/Greensboro/HIgh Point  ','Eastern','Winston-Salem','NC','27106');
oly_affs[oly_affs.length] = new oly_aff('WYFF',true,true,'WYFF 4','Greenville-Spartanburg-Asheville-Anderson','Eastern','Greenville','SC','29609');

affs = new Array();
for(var a=0; a<oly_affs.length; a++) {
	affs[oly_affs[a].calls.toLowerCase()] = oly_affs[a];
}
for(var r=0; r<rollups.length; r++) {
	if(affs[rollups[r][0].toLowerCase()]) affs[rollups[r][0].toLowerCase()].parent = rollups[r][1].toLowerCase();;
	//alert(affs[rollups[r][0].toLowerCase()].calls+' to '+rollups[r][1].toLowerCase());
}




// coid: 5068724
var olympicZone = {
	localized:false,
	call:'',
	timezone:'-5',
	zip:'',
	branding:'',
	market:'',
	city:'',
	state:''}

// check the cookie, populate the object
var ozone = IBCookies.get("call");
if(ozone != '' && ozone != null) loadOzoneObj(ozone);

function loadOzoneObj(call){
		if(ozone == 'olympiczone') {
			olympicZone.localized = true;
			olympicZone.call = call;
			olympicZone.timezone = IBCookies.get('tz');
			olympicZone.zip = IBCookies.get('zip');
			olympicZone.branding = IBCookies.get('stationbrand');
			olympicZone.market = '';
			olympicZone.city = '';
			olympicZone.state = '';
		} else {
			for(var z=0; z<oly_affs.length; z++) {
				if(oly_affs[z].calls == ozone){
					olympicZone.localized = true;
					olympicZone.call = oly_affs[z].calls;
					olympicZone.timezone = oly_affs[z].tz;
					olympicZone.zip = oly_affs[z].zip;
					olympicZone.branding = oly_affs[z].name;
					olympicZone.market = oly_affs[z].market;
					olympicZone.city = oly_affs[z].city;
					olympicZone.state = oly_affs[z].state;
				break;
				}
			}
		}
	}


var navBranded = false;
function brandNav(){
	var loco = "Home";
	// redirect users who aren't localized, if they somehow land on /tv/
	if (pageProps.sectiontag == 'tvlistings'){
		if (document.getElementById('loco')) loco=document.getElementById('loco').getAttribute('value');
		if (!olympicZone.localized) {
			var thisurl = escape(document.location.href) + ((document.location.href.indexOf('?') == -1)?'%3F':'%26') + "v2";
			window.location.replace("/getlocal/index.html?locm=tvlistings&loco=" + loco + "&redirect="+thisurl);
		}
	}
	if (olympicZone.localized  && document.getElementById('getlocal_nav')) {
		var localnav = document.getElementById('getlocal_nav');
		localnav.src = "/images/structures/navigation/nav_off"+olympicZone.call+".gif";
		document.getElementById('getlocal_navLink').href = "/"+olympicZone.call+"/";
		localnav.alt = olympicZone.branding+" Zone";
		localnav.title = olympicZone.branding+" Zone";
		localnav.onmouseover = null;
		localnav.onmouseout = null;
		Events.addEvent(localnav, "mouseover", function (e) { var t = window.event ? window.event.srcElement : e ? e.currentTarget : null; t.src = "/images/structures/navigation/nav_on"+olympicZone.call+".gif"; }, false );
		Events.addEvent(localnav, "mouseout", function (e) { var t = window.event ? window.event.srcElement : e ? e.currentTarget : null; t.src = "/images/structures/navigation/nav_off"+olympicZone.call+".gif"; }, false );
		} else {
			if (document.getElementById('loco')) loco=document.getElementById('loco').getAttribute('value');
			if (document.getElementById('tvlistings_navLink')) document.getElementById('tvlistings_navLink').href = "/getlocal/index.html?redirect=tv&locm=tvlistings&loco=" + loco;
		}
	navBranded = true;
}

function localizeLinks(){
	if (!navBranded) brandNav();

	/* 	Writes new Paths for a hrefs pathed to /olympiczone/ 
		t = the new path
	*/
	function olympicZoneUrlWrite (t)	{
		var arr = document.getElementsByTagName("a");
		for(var j=0; j < arr.length; j++)	{
			var a = arr.item(j);
			if(a.href.indexOf("olympiczone") != -1)	{
				var newurl = a.href.replace(/olympiczone/, t);
				 a.href = newurl;
			}
		}
	}
	if (olympicZone.localized) {
		if (document.getElementById('localizeAnchor')) document.getElementById('localizeAnchor').innerHTML = "Update Olympic Zone Preferences";
		if (document.getElementById('ozlink')) document.getElementById('ozlink').href = "/"+olympicZone.call+"/";
		/* 
			Localized and on your local page 
			example: Your localized to kare and your section path is /kare/
		*/
		if(pageProps.sectiontag == olympicZone.call)	{
			olympicZoneUrlWrite (olympicZone.call);
		} else if(pageProps.sectionsite == 'oly')	{
		/* 
			Loclaized and on the any olympics pages
			example: your Localized to kare and your section path is /
		*/
			olympicZoneUrlWrite (olympicZone.call);
		} else {
		/* 
			localized but sent a link to a different station
			example: Your localized to kare and your section path is /wdsu/
		 */
			olympicZoneUrlWrite (pageProps.sectiontag);
		}
	} else {
		/* 
			Not localized but on a local page
			example Not loclaized and your section path is /kare/
		 */
		if(pageProps.sectionsite == 'aff')
			olympicZoneUrlWrite (pageProps.sectiontag);
	}

}



	/*
	
	JAVASCRIPT FOR LOCALIZATION OF VIEWERS
	(c) 	Internet Broadasting Systems, Inc.
		Brian Betz 2005
	
	*/
	// lineupids that I need to filter out:
	var badlids = 'WA62877:-';

	var localization = {
			status:'trans',
			tempTz:'-5',
			tempZip:'',
			tempLineup:'',
			device:'',
			tempCall:'',
			provName:'',
			brand:'',
			city:'',
			state:'',
			isContest:(document.location.href.indexOf('contest') != -1)?true:false,
			isESPN:(document.location.href.indexOf('espn') != -1)?true:false,
			step2Desc:'By entering your TV provider, you will receive the most accurate and up-to-date Olympic TV listings and content from your local NBC station.<br /><br />(If this is not your correct ZIP, <a href="#" onclick="localization.goToOne();">click here</a>)',
			step2DescContest:'<p>By <b>entering your TV provider below</b>, you will have the most accurate and up-to-date Olympic TV listings and content from your local NBC station.<br />',
			step2DescESPN:'<p>By <b>selecting your TV provider below</b>, you will receive the most accurate and up-to-date Olympic TV listings based upon your <b>local NBC station.</b><br />',
			step2Post:'',
			step2PostContest:'<p><strong>Olympic Zone sweepstakes information is just one step away!</strong></p><p>(If this is not your correct ZIP, <a href="#" onclick="localization.goToOne();">click here</a>)</p>',
			step2PostESPN:'<p>(If this is not your correct ZIP, <a href="#" onclick="localization.goToOne();">click here</a>)</p>',
			step3Post:'',
			step3PostContest:'<p><strong>Click FINISH below to view Olympic Zone sweepstakes information</strong></p>',
			step3PostESPN:'<p><strong>Click FINISH below to view localized Olympic TV listings from NBCOlympics.com</strong></p>',
			goToOne: function() {
				var qs='?';
				for(p in qsPairs){
					if(p != 'zip') {
						if(qs.length > 1) qs+='&';
						qs += p+'='+qsPairs[p]
					}
 				}
				document.location = 'index.html'+qs;
			},
			cookieTemps:function(c){
				//alert(localization.tempTz + ' - ' + localization.tempZip + ' - ' + localization.tempLineup + ' - ' + localization.tempCall);
				if(localization.tempCall != '') var myaffcalls = (affs[localization.tempCall.toLowerCase()].parent)?affs[localization.tempCall.toLowerCase()].parent:localization.tempCall.toLowerCase();
				else var myaffcalls = '';
				IBCookies.set( 'tz', localization.tempTz, null, 'domain', '/', false);
				IBCookies.set( 'zip', localization.tempZip, null, 'domain', '/', false);
				IBCookies.set( 'lineupid', localization.tempLineup, null, 'domain', '/', false);
				IBCookies.set( 'call', myaffcalls, null, 'domain', '/', false);
				IBCookies.set( 'provider', localization.provName, null, 'domain', '/', false);
				IBCookies.set( 'stationbrand', affs[myaffcalls].name, null, 'domain', '/', false);
				// track this event with WebTrends
				var locm = "getlocal";
				if (qsPairs['locm']) locm=qsPairs['locm'];
				var loco = "getlocal";
				if (qsPairs['loco']) loco=qsPairs['loco'];
				// these cookies are deleted when the localization event is captured in WT
				IBCookies.set( 'wtlocm', locm, null, 'domain', '/', false);
				IBCookies.set( 'wtloco', loco, null, 'domain', '/', false);
				if(qsPairs['redirect']){
					if(qsPairs['redirect'].indexOf('[aff]') != -1) qsPairs['redirect'] = qsPairs['redirect'].split('[aff]')[0] + myaffcalls + qsPairs['redirect'].split('[aff]')[1];
					if(qsPairs['redirect'].indexOf('.html') != -1) {
						document.location = unescape(qsPairs['redirect']);
					} else {
						document.location = '/' + qsPairs['redirect'] + '/index.html';
					}
				} else if(localization.isESPN) {
					document.location = '/tv/index.html?qs=pt=espn';
				} else {
					document.location = '/' + localization.tempCall.toLowerCase() + '/index.html';
				}
			},
			setDefaultCookies:function(c){
				var myaffcalls = 'olympiczone';
				IBCookies.set( 'tz', localization.tempTz, null, 'domain', '/', false);
				IBCookies.set( 'zip', localization.tempZip, null, 'domain', '/', false);
				IBCookies.set( 'lineupid', localization.tempLineup, null, 'domain', '/', false);
				IBCookies.set( 'call', myaffcalls, null, 'domain', '/', false);
				IBCookies.set( 'provider', localization.provName, null, 'domain', '/', false);
				IBCookies.set( 'stationbrand', 'NBC Olympics', null, 'domain', '/', false);
				// track this event with WebTrends
				var locm = "getlocal";
				if (qsPairs['locm']) locm=qsPairs['locm'];
				var loco = "getlocal";
				if (qsPairs['loco']) loco=qsPairs['loco'];
				// these cookies are deleted when the localization event is captured in WT
				IBCookies.set( 'wtloco', loco, null, 'domain', '/', false);
				IBCookies.set( 'wtlocm', locm, null, 'domain', '/', false);
				if(qsPairs['redirect']){
					if(qsPairs['redirect'].indexOf('[aff]') != -1) qsPairs['redirect'] = qsPairs['redirect'].split('[aff]')[0] + myaffcalls + qsPairs['redirect'].split('[aff]')[1];
					if(qsPairs['redirect'].indexOf('.html') != -1) {
						document.location = qsPairs['redirect'];
					} else {
						document.location = '/' + qsPairs['redirect'] + '/index.html';
					}
				} else if(localization.isESPN) {
					document.location = '/tv/index.html';
				} else {
					document.location = '/olympiczone/index.html';
				}
			},
			getProvsByZip:function(z){
				if(getEl('locError')) getEl('locError').innnerHTML = '';
				localization.tempZip = z;
				XMLObj.get('/localization/query?zipCode='+z, localization.processZipResults);
			},
			processZipResults:function(xml, responseText) {
				if(xml) {
					var myXML = xml;
					localization.tempTz = (getTag('lineupList', myXML).length != 0)?getTag('lineupList', myXML)[0].getAttribute('timeZone'):'-5';
					var items = getTag('lineupItem', myXML);
					if(items.length == 0) {
						localization.tempZip = '';
						if(getEl('locError')) {
							var errorEl = getEl('locError');
						} else {
							var errorEl = buildElement('div', [['id', 'locError'],['class', 'error'], ['style','color:#f00;']]);
							getEl('localizer').appendChild(errorEl);
						}
						errorEl.innerHTML = 'We\'re sorry, the zip code you entered is not valid, please re-enter a valid five-digit U.S. Zip Code';
						getEl('locError').style.display = 'block';
					} else {
						out = '<b>PLEASE SELECT YOUR TELEVISION SERVICE PROVIDER:</b><br />';
						
						out += '<div class="provideroptions" align="center"><form style="display:inline;"><select size="8" onchange="localization.tempLineup = this.options[this.options.selectedIndex].value; localization.device=this.options[this.options.selectedIndex].getAttribute(\'device\'); localization.provName = this.options[this.options.selectedIndex].innerHTML;">';
						localization.city = (getTag('localization', myXML).length != 0)?getTag('localization', myXML)[0].getAttribute('city'):'';
						localization.state = (getTag('localization', myXML).length != 0)?getTag('localization', myXML)[0].getAttribute('state'):'';
						for(var x=0; x<items.length; x++){
							var provname = (getTag('name',items[x]).length != 0 && getTag('name',items[x])[0].childNodes.length > 0)? getTag('name',items[x])[0].childNodes[0].nodeValue:'';
							var provloc = (getTag('location',items[x]).length != 0 && getTag('location',items[x])[0].childNodes.length > 0)? getTag('location',items[x])[0].childNodes[0].nodeValue:'';
							var provdevice = (getTag('device',items[x]).length != 0 && getTag('device',items[x])[0].childNodes.length > 0)? getTag('device',items[x])[0].childNodes[0].nodeValue:'';
							var provid = items[x].getAttribute('lineupId');
							var provdisplay = provname + '' + provdevice;
							if(badlids.toLowerCase().indexOf(provid.toLowerCase()) == -1){
								if(provdevice.toLowerCase() == 'cable' || provdevice.toLowerCase() == 'digital') out += '<option value="' + provid + '" device="' + provdevice + '"> ' + provname + ' ' + provloc + ' ' + provdevice + '</option>';
								else out += '<option value="' + provid + '" device="' + provdevice + '"> ' + provname + ' ' + provdevice + '</option>';
							}
						}
						out += '</select><br /><input style="" type="button" value="NEXT" onclick="if(localization.tempLineup != \'\') localization.getAffsByProv(localization.tempLineup);dcsMultiTrackScenario(2);" /></form></div>';
						if(localization.isContest) out += localization.step2PostContest;
						else if(localization.isESPN) out += localization.step2PostESPN;
						else out += localization.step2Desc;
						getEl('localizer').innerHTML = out;
						if(localization.isContest && getEl('locPreText')) getEl('locPreText').innerHTML = localization.step2DescContest;
						else if(localization.isESPN && getEl('locPreText')) getEl('locPreText').innerHTML = localization.step2DescESPN;
						localization.showStatus();
						getEl('locError').style.display = 'none';
					}
				}

			},
			getAffsByProv:function(l){
				localization.tempLineup = l;
				//XMLObj.get('/localization/query?lineupId='+l+'&zipCode='+localization.tempZip, localization.processProvResults);
				XMLObj.get('/localization/query?lineupId='+l, localization.processProvResults);
			},
			processProvResults:function(xml, responseText) {
				if(xml) {
					var myXML = xml;
					var items = getTag('stationItem', myXML)
					var affcount = 0;
					for(var x=0; x<items.length; x++){
						var affch = (getTag('channel',items[x]).length != 0)? getTag('channel',items[x])[0].childNodes[0].nodeValue:'';
						if((localization.device.toLowerCase() == 'local satellite' && affch < 100) || localization.device.toLowerCase() != 'local satellite') {
							affcount++;
						}
					}
					out = '<form style="display:inline;">';
					if(affcount == 1) out +='The station below is your local NBC affiliate:';
					else out += 'Select an NBC affiliate from the list below';
					out += '<div class="provideroptions"><br /><table border="0" width="100%"><tr><th>&#160;</th><th colspan="2">NBC Station</th><th>Channel Number</th><th>Market</th></tr>';
					var tempList = new Array();
					var activeCount = 0;
					for(var x=0; x<items.length; x++){
						var affname = (getTag('name',items[x]).length != 0)? getTag('name',items[x])[0].childNodes[0].nodeValue:'';
						var affid = (getTag('callSign',items[x]).length != 0)? getTag('callSign',items[x])[0].childNodes[0].nodeValue.substring(0,4):'';
						var affch = (getTag('channel',items[x]).length != 0)? getTag('channel',items[x])[0].childNodes[0].nodeValue:'';
						if((localization.device.toLowerCase() == 'local satellite' && affch < 100) || localization.device.toLowerCase() != 'local satellite') {
							if(affs[affid.toLowerCase()]){
								if(affs[affid.toLowerCase()].isactive) activeCount++;
								if(affs[affid.toLowerCase()]) tempList[tempList.length] = {name:affname,id:affid,channel:affch,active:affs[affid.toLowerCase()].isactive};
							}
						}
					}
					//sort the array !!!
					tempList = tempList.sort(byChannel);
					//alert( activeCount);
					/* I HAVE MORE THAN ONE ACTIVE AFFILIATE */
					if(activeCount > 0 ){
						for(var c=0; c<tempList.length; c++){
							var thiscalls = (affs[tempList[c].id.toLowerCase()].parent)?affs[tempList[c].id.toLowerCase()].parent:tempList[c].id.toLowerCase()
							if(tempList[c].active) {
								out += '<tr>';
								if( activeCount > 1) {
									out += '<td width="50"><input type="radio" name="stationcall" onclick="localization.tempCall = \'' + thiscalls + '\';" /></td>'
								} else {
									localization.tempCall = tempList[c].id;
									localization.showStatus();
									out += '<td></td>';
								}
								out += '<td width="50"><img src="/images/stationlogos_small/affiliatelogo_small_' + thiscalls + '.jpg" width="70" height="70" alt="' + thiscalls + '" /></td>';
								out += '<td align="left">' + affs[tempList[c].id.toLowerCase()].name + '</td>';
								out += '<td align="center">' + tempList[c].channel + '</td>';
								out += '<td>' + affs[tempList[c].id.toLowerCase()].market + '</td>';
								out += '</tr>';	
							}
						}
						out += '</table>';
						if(localization.isContest)  out += localization.step3PostContest;
						else if(localization.isESPN) out += localization.step3PostESPN;
						out += '<input type="button" value="FINISH" onclick="if(localization.tempCall != \'\') localization.cookieTemps();" /></form></div>'
					/* I HAVE NO ACTIVE AFFILIATE BUT I DO HAVE ONE OR MORE NON PARTICIPATING AFFILIATE(S) */
					} else if(tempList.length >= 1){
						for(var c=0; c<tempList.length; c++){
							var thiscalls = (affs[tempList[c].id.toLowerCase()].parent)?affs[tempList[c].id.toLowerCase()].parent:tempList[c].id.toLowerCase()
							out += '<tr>';
							if( tempList > 1) {
								out += '<td width="50"><input type="radio" name="stationcall" onclick="localization.tempCall = \'' + tempList[c].id + '\';" /></td>'
							} else {
								localization.tempCall = tempList[c].id;
								out += '<td></td>';
							}
							out += '<td width="50"><img src="/images/stationlogos_small/affiliatelogo_small_nbc.jpg" width="70" height="70" alt="' + thiscalls + '" /></td>';
							out += '<td align="left">' + affs[tempList[c].id.toLowerCase()].name + '</td>';
							out += '<td align="center">' + tempList[c].channel + '</td>';
							out += '<td>' + affs[tempList[c].id.toLowerCase()].market + '</td>';
							out += '</tr>';	
						}
						out += '</table>';
						if(localization.isContest)  out += localization.step3PostContest;
						out += '<input type="button" value="FINISH" onclick="if(localization.tempCall != \'\') localization.setDefaultCookies();" /></form></div>'
					} else {
						out += '<tr><td></td>';
						out += '<td width="50"><img src="/images/stationlogos_small/affiliatelogo_small_nbc.jpg" width="70" height="70" alt="NBC" /></td>';
						out += '<td align="left">NBC Olympic Zone</td>';
						out += '<td align="center"></td>';
						out += '<td></td>';
						out += '</tr>';	
						out += '</table>';
						if(localization.isContest)  out += localization.step3PostContest;
						out += '<input type="button" value="FINISH" onclick="localization.setDefaultCookies();" /></form></div>'
					}
					getEl('localizer').innerHTML = out;
					if((localization.isContest || localization.isESPN) && getEl('locPreText')) getEl('locPreText').innerHTML = '';
				}
				localization.showStatus();
			},
			showStatus:function(){
				if(getEl('locprogress')) {
					pages = getTag('a', getEl('locprogress'));
					if(localization.tempZip != '') {
						pages[1].style.color = '#000';
						pages[1].style.cursor = 'pointer';
						pages[1].onclick = function(){
							localization.tempLineup = '';
							localization.provName = '';
							localization.getProvsByZip(localization.tempZip);
						}
					}
					if(localization.tempLineup != '') pages[2].style.color = '#000';
				}
				var out = '';
				out += 'You\'ve entered <b>'+ localization.tempZip + ' -- '+localization.city+', '+localization.state;
				if(localization.provName != '') out += ' -- '+ localization.provName;
				//if(localization.tempCall != '') out += ' -- '+ localization.tempCall;
				out += '</b>';
				getEl('currlocstate').innerHTML = out;
				getEl('currlocstate').style.display = 'block';
			},
			setTempVals:function(aff){
				if(arguments.length == 0){ // not passed an afiliate in the request
					if(document.location.href.split('?').length > 1) {
						if(qsPairs['call']) {
							var mycalls = qsPairs['call'].toLowerCase();
							if(IBCookies.get('call') == null){
								var myaffcalls = (affs[mycalls].parent)?affs[mycalls].parent:mycalls;
								IBCookies.set( 'call', myaffcalls, null, 'domain', '/', false);
								IBCookies.set( 'tz', affs[myaffcalls].tz, null, 'domain', '/', false);
								IBCookies.set( 'zip', affs[myaffcalls].zip, null, 'domain', '/', false);
								IBCookies.set( 'lineupid', 'PC:'+affs[myaffcalls].zip, null, 'domain', '/', false);
								IBCookies.set( 'provider', 'Local Broadcast', null, 'domain', '/', false);
								IBCookies.set( 'stationbrand', affs[myaffcalls].name, null, 'domain', '/', false);
								// track this event with WebTrends, these cookies are deleted when the localization event is captured in WT
								// track this event with WebTrends
								IBCookies.set( 'wtloco', 'affiliate', null, 'domain', '/', false);
								IBCookies.set( 'wtlocm', 'affiliate', null, 'domain', '/', false);
							} else{
								//alert('sorry already localized');
							}
						}
					}
				}
				localization.doBranding();
			},
			doBranding:function(){
				var c = IBCookies.get('call');
				if(c != null){ // IF THE USER HAS AN AFFILIATE COOKIE
					loadOzoneObj(c);
					}
				Events.addEvent(window, "load", localizeLinks, false);
			},
			clearCookies:function(){
				IBCookies.nuke( 'call');
				IBCookies.nuke( 'tz');
				IBCookies.nuke( 'zip');
				IBCookies.nuke( 'lineupid');
				IBCookies.nuke( 'provider');
				IBCookies.nuke( 'stationbrand');
				// WT cookies
				IBCookies.nuke( 'wtlocm');
				IBCookies.nuke( 'wtloco');
				document.location.href=document.location.href;
				//document.location.href='/getlocal/index.html';
			},
			getWhatsOn:function(call){
				if(call && call != ''){
					// something different
					XMLObj.get('/whatson/query?zipCode=' + IBCookies.get( 'zip') + '&callSign=' + call + '&lineupId=' + IBCookies.get( 'lineupid'), localization.displayWhatsOn);
				} else if(IBCookies.get( 'call')) {
					XMLObj.get('/whatson/query?zipCode=' + IBCookies.get( 'zip') + '&callSign=' + IBCookies.get( 'call') + '&lineupId=' + IBCookies.get( 'lineupid'), localization.displayWhatsOn);
				}
			},
			displayWhatsOn:function(xml, responseText) {
				try {
					var out = '';
					var tzones = new Array('','','','','ADT','ET','CT','MT','PT','AKT','HAT');
					var TS = createDateFromDB(xml.getElementsByTagName('whatson')[0].getAttribute('requestParameterFrom'));
					//out += 'http://olydev.ibsys.com/images/tvschedule/msnbc_logo.gif';
					var thisZone = tzones[Number(xml.getElementsByTagName('whatson')[0].getAttribute('timeZone'))*-1];
					if(IBCookies.get( 'call')) {
						for(var s=0; s<xml.getElementsByTagName('stationItem').length; s++){
							var thisStation = xml.getElementsByTagName('stationItem')[s];
							var thisCallSign = thisStation.getAttribute('callSign').toLowerCase();
							var thisProgram = thisStation.getElementsByTagName('programItem')[0];
							var thisProgramTS = createDateFromDB(thisProgram.getElementsByTagName('start')[0].childNodes[0].nodeValue);
							if(thisCallSign == 'nbc' || affs[thisCallSign]) {
								if(thisProgram.getAttribute('isOn').toLowerCase() == 'true'){
									out += '<b>ON AIR: ' + parseTime(thisProgram.getElementsByTagName('start')[0].childNodes[0].nodeValue) + ' ' + thisZone + '</b><br />';
								} else {
									out += '<b>ON NEXT: ' + parseTime(thisProgram.getElementsByTagName('start')[0].childNodes[0].nodeValue) + ' ' + thisZone + '</b><br />';
								}
								out += thisProgram.getElementsByTagName('shortDescription')[0].childNodes[0].nodeValue;
							} else {
								if(getEl(thisCallSign+'program')) {
									var status = document.createElement('div');
									var programdate = document.createElement('div');
									programdate.className = 'wotvdate';
									if(!thisProgramTS.isDay(TS)) {
										programdate.innerHTML = (thisProgramTS.getMonth()+1)+'/'+(thisProgramTS.getDate());
									} else {
										programdate.innerHTML = 'TODAY';
									}
									status.appendChild(programdate);
									var programtime = document.createElement('div');
									if(thisProgram.getAttribute('isOn') == 'true') {
										programtime.innerHTML = 'ON<br />AIR';
										programtime.className = 'wotvonair';
									} else if(TS.getTime() < thisProgramTS.getTime()){
										programtime.innerHTML = parseTime(thisProgram.getElementsByTagName('start')[0].childNodes[0].nodeValue);
										programtime.className = 'wotvtime';
									}
									status.appendChild(programtime);
									status.style.fontSize = '10px';
									status.style.fontWeight = 'bold';
									getEl(thisCallSign+'program').appendChild(status);
								}
							}
						}
					}
					getEl('whatson-now').innerHTML = out;
				} catch( e) {}
			}
		}

		// FIX OLD AFFILIATE COOKIE SETS
		if(IBCookies.get('call') && IBCookies.get('zip') && !IBCookies.get('lineupid')) IBCookies.set('lineupid', 'PC:'+IBCookies.get('zip'), null, 'domain', '/', false);
		
	
		// TOOLS FOR TV LISTINGS
		Date.prototype.isDay = function(T) {
			return (this.getDate() == T.getDate() && this.getMonth() == T.getMonth() && this.getYear == T.getYear());
		}
		Date.prototype.offsetDays = function(T) {
			return (this.getTime() - T.getTime());
		}
		function isBefore(a,b){
			dateA = a.getTime();
			dateB = b.getTime();
			return (dateA < dateB);
		}
		
		function createDateFromDB(t) {
			var dateList = t.split('T')[0].split('-');
			var timeList = t.split('T')[1].split(':');
			var TS = new Date(Number(dateList[0]),Number(dateList[1])-1,Number(dateList[2]),Number(timeList[0]),Number(timeList[1]),Number(timeList[2]));
			return TS;	
		}
		
		function parseTime(t,z) {
			var mer = (mer)?mer:true;
			var hour = new Number(t.split('T')[1].split(':')[0]);
			var min = (t.split('T')[1].split(':')[1] != '00')?':'+t.split('T')[1].split(':')[1]:':00';
			var ampm = (hour > 11)?'P':'A';
			hour = (hour < 13)?hour:hour-12;
			return hour+min+ampm;
		}
		
		
	// PAIRS BUILT FROM THE CONTENTS OF THE QUERY STRING
	var myVars = new Array();
	var qsPairs = new Array();
	if(document.location.href.indexOf('?') != -1) {
		myVars = document.location.href.split('?')[1].split('&');
		for(var v in myVars){
			var tempPairs = myVars[v].split('=');
			qsPairs[tempPairs[0]] = unescape(tempPairs[1]);
		}
	}
	// TOOLS FOR LOCALIZATION
	// GetElementById shortcut
	function getEl(i) {
		return document.getElementById(i);
	}
	// Get elements By Attribute Value  (attribute name, attribute value, tagname, parentElement)
	function getByAtt(att, val, tag, top) {
		if(att=='class' && isIE) var att='className';
		var elemArray = new Array();
		var tag=(tag)?tag:false;
		var top=(top)?top:document;
		// Not sure how to handle a request that has not tag name ??
		if(tag){
			tlist = top.getElementsByTagName(tag);
			for(e=0; e<tlist.length; e++) {
				if (tlist[e].getAttribute(att) == val) {
					elemArray[elemArray.length] = tlist[e];
				}
			}
		}
		return elemArray;
	}
	function getTag(tag, top) { //tag:the tags I am looking for, top:the element in which I am looking
		var top=(top)?top:document;
		return top.getElementsByTagName(tag);
	}
	// Build HTML ELement with attributes	
	function buildElement(nodename, attributes) { // nodename:string  attributes:array
	    var tmpNode = document.createElement(nodename);
	    for(var a in attributes)  {
		tmpNode.setAttribute(attributes[a][0], attributes[a][1]);
		if(attributes[a][0] == 'class') tmpNode.setAttribute('className', attributes[a][1]);
	    }
	    return tmpNode;
	}
	
	function byChannel(a,b){
		adata = Number(a.channel);
		bdata = Number(b.channel);
		//alert(adata + '-' + bdata);
		if (adata > bdata) {
		   return 1; 
		} else if(adata < bdata) {
		   return -1; 
		} else {
			return 0;
		}
	} 
	// BUILD THE OZONE LINKS TO TV LISTINGS BUTTONS
	function ozoneWOTVButtons(c) {
		if(getEl('fivedaytv')){
			var tvl_callsign = c;
			var tvl_zip = (affs[tvl_callsign.toLowerCase()])? affs[tvl_callsign.toLowerCase()].zip : '10003';
			var tvl_days  = getTag('li', getEl('fivedaytv'));
			for (var t=0; t < tvl_days.length; t++) {
				tvl_days[t].style.cursor = 'pointer';
				tvl_days[t].onclick = function(){
					var tvl_day = new Date(2006,1,this.getAttribute('daynum'),12,0,0);
					if(IBCookies.get('call') && IBCookies.get('call').toLowerCase() == tvl_callsign.toLowerCase()) document.location.href = '/tv/index.html?fromTimeInMillis=' + tvl_day.getTime() + '&network=' + IBCookies.get('call').toUpperCase() + '&state=1&zipCode=' + IBCookies.get('zip') + '&callSign=' + IBCookies.get('call').toUpperCase() + '&lineupId=' +  IBCookies.get('lineupid');
					else if(IBCookies.get('call') && tvl_callsign.toLowerCase() == 'olympic zone') document.location.href = '/tv/index.html?fromTimeInMillis=' + tvl_day.getTime() + '&network=NBC&state=1&zipCode=' + IBCookies.get('zip') + '&callSign=NBC&lineupId=' +  IBCookies.get('lineupid');
					else document.location.href = '/tv/index.html?fromTimeInMillis=' + tvl_day.getTime() + '&network=' + tvl_callsign + '&state=1&zipCode=' + tvl_zip + '&callSign=' + tvl_callsign + '&lineupId=PC:' +  tvl_zip;
					return false;
				}
			}
		}
	}

	function showLocalization(){
		getEl('locprogress').style.display = 'none';
		var out = '<div class="provideroptions"><br /><table border="0" width="100%" cellpadding="5" cellspacing="0"><tr><th colspan="5" align="center">You are currently localized to the following NBC affiliate:</th></tr>';
		out += '<tr>';
		out += '<td width="50"></td>'
		out += '<td width="50"><img src="/images/stationlogos_small/affiliatelogo_small_' + IBCookies.get( 'call').toLowerCase() + '.jpg" width="70" height="70" alt="' + IBCookies.get( 'stationbrand') + '" /></td>';
		out += '<td align="left">' + IBCookies.get( 'stationbrand') + '</td>';
		out += '<td align="left"></td>';
		out += '<td>'+olympicZone.market+'</td>';
		out += '</tr>';		
		out += '<tr><th colspan="5" align="center"><a href="#" onclick="localization.clearCookies(); return false;">To update or change your preferences, click here</a></th></tr></table></div>';
		getEl('localizer').innerHTML = out;
	}	
	// THIS FUNCTION WILL CHECK FOR A QUERY STRING THAT INDICATES AN AFFILIATE AND SET THE COOKIE IF POSSIBLE
	localization.setTempVals();



/* Top Story sequencial blurb display */
function TSSeq(data) {
	var self = this;
	this.data = data;
	this.timeout = this.data.timeout;
	this.count = this.data.timeout; // countdown
	this._ppState = this.data.autoplay; // 0 pause, 1 play
	this._ppText = ["play", "pause"]; // image text
	this._ppBtn = [];
	this.currentslide = 0; // default to 0
	this.slideImages = {}; // new Object for preloaded slides
	this._intervalId = "";
	
	/** 
	 * Define methods...
	**/
	if (typeof TSSeq._initialized == "undefined") {
		TSSeq.prototype.init = function() {
			if (!document.getElementById || !document.getElementsByTagName || !document.getElementsByName || 
				!(window.XMLHttpRequest || (window.ActiveXObject && !bEnv.MacIE))) return;
			this._preloadImages();
			this._olympicZoneUrlWrite();
			this.buildControls(); // if HTML handled in peices
			if (this._ppState == 1) this.play();
		};
		
		TSSeq.prototype._preloadImages = function() {
			for (var i = this.data.co.length-1; i >= 0; i--) {
				this.slideImages[i] = new Image();
				this.slideImages[i].src = this.data.co[i].img.imgSrc;
			}
			for (var j in this._ppText) {
				this._ppBtn[j] = new Image();
				this._ppBtn[j].src = "/images/structures/buttons/"+this._ppText[j]+".gif";
			}
		};
		// resetting paths from /olympiczone/ to /CALLLETTERS/
		TSSeq.prototype._olympicZoneUrlWrite = function() {
             for(var k=0; k < this.data.co.length; k++)	{
				if(this.data.co[k].link.indexOf("olympiczone") != -1)	{
					var newurl = this.data.co[k].link.replace(/olympiczone/, pageProps.sectiontag);
					this.data.co[k].link = newurl;
					//this.data.co[k].link=this.data.co[k].link.replace(/\/olympiczone\//,pageProps.sectionpath);
				}
			}	
             for(var m=0; m < this.data.co.length; m++)	{
				if(this.data.co[m].img.imgLink.indexOf("olympiczone") != -1)	{
					var newurl = this.data.co[m].img.imgLink.replace(/olympiczone/, pageProps.sectiontag);
					this.data.co[m].img.imgLink = newurl;
				}
			}		
		};
		
		/* create controls; back, play/pause, next, button per slide */
		TSSeq.prototype.buildControls = function() {
			var cs = this.data.co[this.currentslide]; // shortcut
			var controlsDiv = document.createElement("div");
			controlsDiv.id = "ssControlsindex"+this.data.coid;
			controlsDiv.className = "ssControls";
			controlsDiv.style.top = cs.img.imgH+"px";
			
			var backAnchor = document.createElement("a");
			var playAnchor = document.createElement("a");
			var nextAnchor = document.createElement("a");
			backAnchor.id = "ssBackindex" + this.data.coid;
			playAnchor.id = "ssPlayindex" + this.data.coid;
			nextAnchor.id = "ssNextindex" + this.data.coid;
			backAnchor.className = "ssControlsImg";
			playAnchor.className = "ssControlsImg";
			nextAnchor.className = "ssControlsImg";
			
			var backImg = document.createElement("img");
			var playImg = document.createElement("img");
			var nextImg = document.createElement("img");
			backImg.src = "/images/structures/buttons/reverse.gif";
			playImg.src = "/images/structures/buttons/play.gif";
			nextImg.src = "/images/structures/buttons/forward.gif";
			backImg.id = "backImg"+this.data.coid;
			playImg.id = "playImg"+this.data.coid;
			nextImg.id = "nextImg"+this.data.coid;
			
			backAnchor.appendChild(backImg);
			playAnchor.appendChild(playImg);
			nextAnchor.appendChild(nextImg);
			
			controlsDiv.appendChild(backAnchor);
			controlsDiv.appendChild(playAnchor);
			controlsDiv.appendChild(nextAnchor);
			
			// append controls
			document.getElementById("index"+this.data.coid).getElementsByTagName("li")[0].appendChild(controlsDiv);
			
			// Add event listeners
			Events.addEvent(document.getElementById("ssBackindex" + this.data.coid), "click", self.back, false);
			Events.addEvent(document.getElementById("ssPlayindex" + this.data.coid), "click", self.playpause, false);
			Events.addEvent(document.getElementById("ssNextindex" + this.data.coid), "click", self.next, false);
			for (var i = 0; i < this.data.co.length; i++) {
				var ii = i+1; // for display
				var slideBtn = document.createElement("a"), slideBtnTxt = document.createTextNode(ii);
				if(i==0) {
					slideBtn.className = "ssSlide ssOn";
				} else {
					slideBtn.className = "ssSlide ssOff";
				}
				slideBtn.id = "ssSlide" + i;
				slideBtn.appendChild(slideBtnTxt);
				controlsDiv.appendChild(slideBtn);
				// this feels like a hack
				Events.addEvent(document.getElementById("ssSlide"+i), "click", function(e) {
					var t = window.event ? window.event.srcElement : e ? e.currentTarget : null;
					if (t.nodeType == 3) t = t.parentNode; // Safari busted...
					self.showSlide(t.id.replace(/ssSlide/, "")); 
				}, false);
			}
		};
		
		TSSeq.prototype.updateSlide = function(s) {
			// reset className for slide buttons
			for (var k=0; k<this.data.co.length; k++) {
				document.getElementById("ssSlide"+k).className= "ssSlide ssOff";
			}
			document.getElementById("ssSlide"+s).className = "ssSlide ssOn";
			document.getElementById("img"+this.data.co[0].img.coid).src = this.slideImages[s].src;
			
			if(this.data.co[s].img.imgLink!='') document.getElementById("imgA"+this.data.co[0].img.coid).href = this.data.co[s].img.imgLink;
			else document.getElementById("imgA"+this.data.co[0].img.coid).removeAttribute("href");
			
			if(this.data.co[s].img.imgCredit) document.getElementById("imgCredit"+this.data.co[0].img.coid).innerHTML = this.data.co[s].img.imgCredit; 
			else document.getElementById("imgCredit"+this.data.co[0].img.coid).innerHTML = "";
			
			document.getElementById("coHeadlineLink"+this.data.co[0].coid).innerHTML = fixString(this.data.co[s].headline);
			
			if(this.data.co[s].img.imgLink!='') document.getElementById("coHeadlineLink"+this.data.co[0].coid).href = this.data.co[s].link;
			else document.getElementById("coHeadlineLink"+this.data.co[0].coid).removeAttribute("href");
			
			var teaser = padTags(this.data.co[s].teaser);
			document.getElementById("coTeaser"+this.data.co[0].coid).innerHTML = fixString(teaser);
		};
		
		// show current slide
		TSSeq.prototype.showSlide = function(s) {
			this.pause();
			if (s == this.currentslide) { 
				return;
			} else {
				this.currentslide = s;
				this.updateSlide(s);
			}
		};
		
		// play/pause toggle
		TSSeq.prototype.playpause = function() {
			self._ppState = self._ppState == 0 ? 1 : 0;
			self._ppState == 1 ? self.play() : self.pause();
			document.getElementById("playImg"+self.data.coid).src = self._ppBtn[self._ppState].src;
		};
		
		// external trigger to autoplay
		TSSeq.prototype.playOnCommand = function() {
			self._ppState = 0; // make certain it is paused
			self.playpause();
		};
		
		// next/auto advance
		TSSeq.prototype.advanceSlide = function() {
			this.currentslide++;
			if (this.currentslide > this.data.co.length-1) this.currentslide = 0;
			this.updateSlide(this.currentslide);
		};
		
		// set current slide to previous
		TSSeq.prototype.back = function() {
			self.pause();
			self.currentslide--;
			if (self.currentslide < 0) self.currentslide = self.data.co.length-1;
			self.updateSlide(self.currentslide);
		};
		
		// set interval to run function
		TSSeq.prototype.play = function() {
			if (this._ppState == 1) {
				this._intervalId = setInterval(function() { self.advanceSlide(); }, 1000*this.timeout);
			}
		};
		
		// stop countdown(?)
		TSSeq.prototype.pause = function() {
			this.abortCountdown();
			document.getElementById("playImg"+self.data.coid).src = self._ppBtn[self._ppState].src;
		};
		
		// set current slide to next
		TSSeq.prototype.next = function() {
			self.pause();
			self.advanceSlide();
		};
		
		TSSeq.prototype.abortCountdown = function() {
			this._ppState = 0; // reset ppState
			clearInterval(this._intervalId);
			this.count = this.data.timeout; // reset count
		};
		
		TSSeq.prototype.toString = function() {
			return "TSSeq object";
		}
		
		/* Set flag so methods aren't redefined */
		TSSeq._initialized = true;
	}
}



// generateObj function - requires 3 arrays of objects
// writes object, param and embed tags for active content

function generateObj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object';
  for (var i = 0; i<objAttrs.length; i++){
  	str += ' ' + objAttrs[i].name + '="' + objAttrs[i].value + '"';
    }
  str += '>';
   for (var i = 0; i<params.length; i++){
    str += '<param name="' + params[i].name + '" value="' + params[i].value + '" /> ';
	}
  str += '<embed';
   for (var i = 0; i<embedAttrs.length; i++){
    str += ' ' + embedAttrs[i].name + '="' + embedAttrs[i].value + '"';
	}
  str += ' ></embed></object>';
  document.write(str);
}

// Name-value pair object 
function NV_Pair(n,v){
	this.name = n;
	this.value = v;
	}



/** 
 * photoarray
**/

function myPhotoArray(data) {	
	var self = this;
                var myid = 'photoarray' + data.coid;
	this.data = data;
	this.images = {};
	this.desc = {};

	this.init = function() {		
		this._preloadImagesandTeaser();
		var thewrap = document.getElementById(myid);
		thewrap.className =  'ppwrap';
		for (var i = 0; i < data.co.length; i++) {
		var theul = document.createElement('ul');
		var theli = document.createElement('li');
		var thelink = document.createElement('a');
		var theimg = document.createElement('img');
		theul.className = 'photoarray';
		theul.id = myid;
		theli.className = 'ppli';
		theimg.src = data.co[i].img.imgSrc;
		theimg.width = data.co[i].img.imgW;
		theimg.height = data.co[i].img.imgH;
                                if (i == 0) {thelink.className = "transOFF";}
                                else { thelink.className = 'rollover'; }
                                var iplus = i + 1;
		thelink.id = data.coid + '_' + iplus;
		thelink.href = data.co[i].link;
		thelink.onmouseover = this.mouseover;
		thelink.onmouseout = this.mouseout;
		thelink.appendChild(theimg);
		theli.appendChild(thelink);
		theul.appendChild(theli);
		thewrap.appendChild(theul);
		}
		var thedesc = document.createElement('div');
		thedesc.id = 'desc' + data.coid;
		thedesc.className = 'desc';
		thedesc.innerHTML = fixString(this.desc[0]);
		thewrap.appendChild(thedesc);

	}

	this._preloadImagesandTeaser = function() {		
			for (var i = this.data.co.length-1; i >= 0; i--) {
				this.images[i] = new Image;
				this.images[i].src = data.co[i].img.imgSrc;
				this.desc[i] = data.co[i].teaser
		}
	}
	
	this.setdesc = function(nodenum) {
		var desctext = this.desc[nodenum - 1]; 
		var descvar = 'desc' + data.coid;
		var desc = document.getElementById(descvar);
		desctext = padTags(desctext);
		desc.innerHTML = fixString(desctext);
	}
	
	this.mouseover = function(e) {
		var target = find_target_id(e); 
                                for (var i = 0; i < data.co.length; i++) {
                                   var iplus = i + 1;
                                   var thetarget = data.coid + '_' + iplus;
                                   var theelem = document.getElementById(thetarget);
                                   theelem.className = "rollover";
                                   if (thetarget == find_target_id(e)) { 
                                      self.setdesc(i + 1);
                                      theelem.className = "transOFF";
                                   }
                                }		
	}

	this.mouseout = function(e) {
		//var target = find_target_pa(e);
		//if (!target) return;
		//target.className = "rollover";
	}
}
			
			
function find_target_pa(e) {
  var target; 
  if (window.event && window.event.srcElement) target = window.event.srcElement;
  else if (e && e.target) target = e.target;
  
  if (!target) return null;

  while (target != document.body && target.nodeName.toLowerCase() != 'a') target = target.parentNode;

  if (target.nodeName.toLowerCase() != 'a') return null;
 //if (target.nodeName.toLowerCase() == 'img') { target = target.parentNode.parentNode;}
  return target;
}

function find_target_id(e) {
  var target; 
  if (window.event && window.event.srcElement) target = window.event.srcElement;
  else if (e && e.target) target = e.target;
  
  if (!target) return null;

  //while (target != document.body && target.nodeName.toLowerCase() != 'a') target = target.parentNode;
  //target = target.Id;
 // if (target.nodeName.toLowerCase() != 'a') return null;
 if (target.nodeName.toLowerCase() == 'img') { target = target.parentNode.id;}
  return target;
}



/** 
 * daybyday
**/
                                    
var currday = pageProps.currentDay;

function myDayByDay(data) {
	var self = this;
	this.data = data;
	this.images = {};
	this.desc = {};
                this.link = {};
	this.init = function() {			
		this._preloadTeaser();
		var wrapname = 'daybyday' + data.coid;
		var thewrap = document.getElementById(wrapname);
		var theul = document.createElement('ul');
		theul.className = 'dbdtabs';		
		var thelidesc = document.createElement('li');
		thelidesc.id = 'desc';
		thelidesc.className = 'descblank';
		
		var thedesc = document.createElement('div');
		thedesc.id = 'desc';
		thedesc.className = 'desctext';
		thedesc.innerHTML = fixString(this.desc[0]);
		
		thelidesc.appendChild(thedesc);
		theul.appendChild(thelidesc);
		var theli = document.createElement('li');
		theli.className = 'prev';
		if (currday == 'pre') theli.className = 'dbdfuture';
		if (currday == 0) theli.className = 'dbdcurr';
                                //if (currday > 0) theli.className = 'dbdcurr';
		theli.id = 'oc';
		theli.onmouseover = this.mouseover;
		theli.onmouseout = this.mouseout;
		theli.onclick = this.mouseclick;
		theli.innerHTML = '<b>O/C</b><br>2/10';
		theul.appendChild(theli);
		for (var i = 1; i < data.co.length; i++) {
			var theli = document.createElement('li');
			theli.id = i;
			theli.className = 'dbdfuture';
			if (i < currday) theli.className = 'dbdprev';
			if (i == currday) theli.className = 'dbdcurr';
			//if (i > currday) theli.className = 'dbdfuture';	
			theli.onmouseover = this.mouseover;
			theli.onmouseout = this.mouseout;
			theli.onclick = this.mouseclick;
			var thenum = i;
			var thedatenum = i + 10;
			var theinnertext = '<b>Day ' + thenum + '</b><br>2/' + thedatenum;
			theli.innerHTML = theinnertext;
			theul.appendChild(theli);
		}
		thewrap.appendChild(theul);
	}

	this._preloadTeaser = function() {		
			for (var i = this.data.co.length-1; i >= 0; i--) {
                                                     var changedDesc = padTags(data.co[i].teaser);
			     this.desc[i] = changedDesc;
                                                     this.link[i] = data.co[i].link;
		}
	}
	

	this.setdesc = function(nodenum) {
		if (nodenum == 'oc') nodenum = 0;
		var desctext = this.desc[nodenum]; 
		var desc = document.getElementById('desc');
		desc.innerHTML = fixString(desctext);
	}
	
	this.mouseover = function(e) {
		var target = find_target(e); 
		var cpa = target.id;
		var theelem = document.getElementById(cpa);
		if (theelem.className == 'dbdprev') theelem.className = 'dbdprev_hov';
		if (theelem.className == 'dbdcurr') theelem.className = 'dbdcurr_hov';
		if (theelem.className == 'dbdfuture') theelem.className = 'dbdfuture_hov';
		self.setdesc(cpa);
	}

	this.mouseout = function(e) {
		var target = find_target(e); 
		var cpa = target.id;
		var theelem = document.getElementById(cpa);
		if (theelem.className == 'dbdprev_hov') theelem.className = 'dbdprev';
		if (theelem.className == 'dbdcurr_hov') theelem.className = 'dbdcurr';
		if (theelem.className == 'dbdfuture_hov') theelem.className = 'dbdfuture';
	}	


	this.mouseclick = function(e) {
		var target = find_target(e); 
		var nodenum = target.id;
		if (nodenum == 'oc') nodenum = 0;
		var linktext = myDayByDay.link[nodenum]; 
		location.href=linktext; 
	}
}

			
function find_target(e)
{	
  var target; 
  if (window.event && window.event.srcElement) target = window.event.srcElement;
  else if (e && e.target) target = e.target;
    if (target.nodeName.toLowerCase() == 'a') {target = target.parentNode;}
     if (target.nodeName.toLowerCase() == 'b') {target = target.parentNode;}
  return target;
}                
    



/** 
 * Sortables 2006 (initially for medals tables)
**/

	lastsort = -1;
	dir = '-';
	column = -1;
	sortfield = -1;
	navdrawn = false;
	var out = '';
	var resultsperpage = ['5','10','20','50','100'];
	
	function datatable_summary(n,l) {
		this.name = n;
		document.write('<div id="' + n + 'div" class="' + n + 'div"></div>');
		this.data = new Array();
		this.display = buildTable_summary;
		this.div = document.getElementById(n+'div');
		this.langcode = (typeof le != 'undefined')?l:'en';
		this.pagename = (this.langcode == 'en')?'Page':'Pagina';
		this.of = (this.langcode == 'en')?'of':'de';
		this.currentpage = 1;
		// basic config
		this.displaysize = 100;
		this.noresultstext = 'No results were found';
		this.backbutton = '&#160;&lt;Previous';
		this.tostartbutton = '&lt;&lt;Start&#160;';
		this.nextbutton = 'Next&#160;&gt;&#160;&#160;';
		this.toendbutton = 'End&#160;&gt;&gt;';
		this.navdisplay = 'top';
		this.showselectlist = true;
		this.showsnumresults = true;
		this.showpages = true;
		this.resulttype = 'result';
	}
	function hlrow(e, c) {
		e.className = c+'over';
	}
	function uhlrow(e, c) {
		e.className = c;
	}
	function tostart(d) {
		d.start = 0;
		d.currentpage = 1;
		d.display();
	}
	function toend(d) {
		d.start = (d.data.length%d.displaysize == 0)?d.data.length-d.displaysize:d.data.length-(d.data.length%d.displaysize)
		d.currentpage = Math.ceil(d.data.length/d.displaysize);
		d.display();
	}
	function page(d, dir) {
		d.currentpage = (dir)?d.currentpage+1:d.currentpage-1;
		if (dir) d.start = d.end;
		else d.start = d.start-d.displaysize;
		d.display();
	}
	
function buildNav_summary(table, pos){
		if (table.showsnumresults && table.showselectlist && pos == 'top'){
			out += '<table border="0" cellpadding="0" cellspacing="0" class="nav" width="100%">';
			out+= '<tr>';
			// number of results
			if (table.showsnumresults){
				out+= '<td class="results">'+ table.data.length + ' ' + table.resulttype;
				if (table.data.length > 1){ out+= 's';}
				out+=' found</td>';
				}
			// page display select list
			if (table.showselectlist){
				out+= '<td class="selectlength"><span class="setpagelength">Show</span>&#160<select onchange="setPageLength(' + table.name + ', this.options[this.options.selectedIndex].value);">';
				for(i=0; i < resultsperpage.length; i++) {
					out += '<option value="' + resultsperpage[i] + '"';
					if (table.displaysize == resultsperpage[i]) {out += 'selected=""';} 
					out +='>' + resultsperpage[i] + '</option>';
				}
				out+= '</select><span class="resultsperpage">&#160;' + table.resulttype + 's&#160;per&#160;page</span></td>';
			}
			out+= '</tr>';
	out += '<tr><td class="totalbar" colspan="2">Total</td><td class="totalbar">' + this.totalbar[0] + '</td><td class="totalbar">' + this.totalbar[1] + '</td><td class="totalbar">' + this.totalbar[2] + '</td><td class="totalbar">' + this.totalbar[3] + '</td></tr>';
			out+= '</table>';
			
		}
		out += '<table border="0" cellpadding="0" cellspacing="0" class="nav" width="100%">';
			// page back
			out += '<tr><td align="left" class="pageback">';
			if(table.start != 0) out+= '<a href="#" onclick="tostart(' + table.name + ', 0); return false;">' + table.tostartbutton + '</a>&#160;<a href="#" onclick="page(' + table.name + ', 0); return false;">' + table.backbutton + '</a>';
		out += '&#160;</td>';
			// page # of #
			if (table.showpages){out+= '<td class="pages">' + table.pagename + '&#160;' + table.currentpage + '&#160;' + table.of + '&#160;' + table.pages +'</td>';}
			// page forward
			out +='<td align="right" class="pageforward">';
			if(table.data.length != table.end) out += '<a href="#" onclick="page(' + table.name + ', 1); return false;">' + table.nextbutton + '</a>&#160;<a href="#" onclick="toend(' + table.name + ', 1); return false;">' + table.toendbutton + '</a>';
		out += '&#160;</td></tr>';
	out += '<tr><td class="totalbar" colspan="2">Total</td><td class="totalbar">' + this.totalbar[0] + '</td><td class="totalbar">' + this.totalbar[1] + '</td><td class="totalbar">' + this.totalbar[2] + '</td><td class="totalbar">' + this.totalbar[3] + '</td></tr>';
		out += '</table>';
		navdrawn = true;
	}
	
	function buildTable_summary() {
	   if(this.data.length != 0) {
		out = '';
		this.start = (this.currentpage-1) * this.displaysize;
		this.end = this.start + this.displaysize;
		if (this.end >= this.data.length) this.end = this.data.length;
		this.pages = (this.data.length%this.displaysize == 0)?this.data.length/this.displaysize:parseInt(this.data.length/this.displaysize+1)
		//nav
		if (this.navdisplay == 'top' || this.navdisplay == 'both'){buildNav_summary(this, 'top');}
		out += '<table border="1" cellpadding="2" cellspacing="0" class="datatable" width="100%">';
		// header row
		out += '<tr>';

		// check for sortheader array
		if(typeof this.sortheader != 'undefined'){
			for(h=0; h < this.sortheader.length; h++){
				if (sortfield == this.sortheader[h][2]) colclass = (dir == '+')?'sortD':'sortU';
				  else colclass = 'header';
				if(this.sortheader[h][3] != 'u') {
					out += '<td class="header"';
					// check for colspan
					if(this.sortheader[h][1] > 0) out += ' colspan="' +this.sortheader[h][1] + '"';
					out += '><div id="header' + this.sortheader[h][2] + '" class="' + colclass + '" onclick="sortit_summary(' + this.name + ',' + this.sortheader[h][2] + ');">' + this.sortheader[h][0] + '</div></td>';
					} else {
					out += '<td class="header">' + this.sortheader[h][0] + '</td>';
					}
				}
		} else {
		
			for(h=1; h<  this.columns.length; h++){
				if (sortfield == h) colclass = (dir == '+')?'sortD':'sortU';
				  else colclass = 'header';
				if(this.columns[h][1] != 'u') out += '<td class="header header' + h + 'summary"><div id="header' + h + '" class="' + colclass + '" onclick="sortit_summary(' + this.name + ',' + h + ');">' + this.columns[h][0] + '</div></td>';
				else out += '<td class="header noleft">' + this.columns[h][0] + '</td>';		//for the oly 05 - i used 'u' to denote the medalists column.
				}
			}
		out += '</tr>';
		// data rows
			for(r=this.start; r<this.end; r++){
				myclass = (r%2 == 1)?'even':'odd'; 
				out += '<tr class="' + myclass + '" onmouseover="hlrow(this, \'' + myclass + '\')" onmouseout="uhlrow(this, \'' + myclass + '\')">';
				
				out += '<td class="data0">' + this.data[r][0] + '&nbsp;&nbsp;' + this.data[r][1];
				if(this.data[r][0] == ' ' || this.data[r][0] == ''){ out += '&#160;';}
				out += '</td>';
				
				for(d=2; d < this.data[r].length; d++) {
					out += '<td class="data' + d + 'summary">' + this.data[r][d];
					if(this.data[r][d] == ' ' || this.data[r][d] == ''){ out += '&#160;';}
					out += '</td>';
				}
				out += '</tr>';
			}
	out += '<tr><td class="totalbar0" colspan="2">Total</td><td class="totalbar">' + this.totalbar[0] + '</td><td class="totalbar">' + this.totalbar[1] + '</td><td class="totalbar">' + this.totalbar[2] + '</td><td class="totalbar">' + this.totalbar[3] + '</td></tr>';
		out += '</table>';
		//nav
		if (this.navdisplay == 'bottom' || this.navdisplay == 'both'){
				buildNav_summary(this, 'bottom');
			}
	   } else {
			out += '<tr><td colspan="' + this.columns.length + '"><strong>' + this.noresultstext + '</strong></td></tr>'
		}
		this.div.innerHTML = out;
	}
	
	
	
	function setPageLength(source, p) {
		source.displaysize = Number(p);
		source.currentpage = 1;
		source.display();
	}
	function compare(a,b){
		datatype = datatypes[sortfield][1];
		if (datatype == 's') { /* String*/
			adata = a[sortfield];
			bdata = b[sortfield];
		}
		if (datatype == 'l') { /* Link */
			adata = a[sortfield].substring(a[sortfield].indexOf('>'), a[sortfield].lastIndexOf('</'));
			bdata = b[sortfield].substring(b[sortfield].indexOf('>'), b[sortfield].lastIndexOf('</'));
		}
		if (datatype == 'd') { /* Date */
			adata = new Date(a[sortfield]);
			bdata = new Date(b[sortfield]);
		}
		if (datatype == 'n') { /* Number  */
			adata = Number(a[sortfield]);
			bdata = Number(b[sortfield]);
		}
		if (adata > bdata) 
		   if (dir == '-') return 1;
		   else return -1; 
		else if(adata < bdata) 
		   if (dir == '-') return -1;
		   else return 1; 
		else 
			return 0;
	} 

	function sortit_summary(source, column) {
		if(source.columns[column][1] != 'u') {
			sortfield = column;
			datasource = source;
			if (lastsort == sortfield){
				if (dir == '+') dir = '-';
				else dir = '+';
			} else {
				dir = '-';
			}
			dir = '+'; // added - lynn, oct 05, to make sort always go most to least
			if(source.columns[column][1] == 's') { dir = '-';} // if it's country, go small to big
			source.currentpage = 1;
			source.start = (source.currentpage-1)*source.displaysize;
			datatypes = source.columns;
			data = source.data;
			data = data.sort(compare);
			source.display();
			lastsort = sortfield;
		}
	}





/* Modify Adcode */
var Ads = {
	/* find ads served in iframes and reset the source*/
	refreshAll: function() {
		var ifr=document.getElementsByTagName("iframe");
		var m=/ord=([0-9^?]*)\?/g;
		rnd++;
		for (var i=0; i<ifr.length; i++) {
		if(ifr[i].className.match(/adObjIfrm/)) {
			var ifrsrc=ifr[i].src.replace(m, rnd);
			ifr[i].src=ifrsrc;
			}
		}
	}
};




function dynaServ2(logoClick,linkClick,coid,logoLink,logoLocation,logoAlign) {
	//Get COID Content
	var results2 = new XMLObj.get("/_objectxml/"+coid+"/headlines.html", function(msg,content) {
		document.getElementById("dynaserv"+coid).innerHTML = content;
//Align Blurb Image Left
var images = document.getElementById("swContent"+coid).getElementsByTagName("img");
images[0].align = "left";
//Find Links in Content
	var links = document.getElementById("swContent"+coid).getElementsByTagName("a");
	//Loop Through Links
	for(var i=0; i<links.length; i++) {
		//Add Clicktracker
		links[i].href = linkClick + links[i].href;
	}
	//Add Logo
	document.getElementById("titlebar"+coid).innerHTML = 
		"<a href=" + logoClick + logoLink + ">" +
		"<img align=" + logoAlign + " border=0 width=63 height=22 " +
		"onload=fixPngImage(this) src=" + logoLocation + " /></a>" +
		document.getElementById("titlebar"+coid).innerHTML;

	});
}


// End scripts


