
	function cnnToggleVideo(el,e) {
		var browser = navigator.userAgent.indexOf('MSIE');
		var desc = d.getElementById(el.id + 'Desc');
		var abbrevDesc = d.getElementById(el.id + 'Abbrev');
		var parent = d.getElementById(el.id);
		if (e.type == 'mouseover') {
			parent.style.height = 'auto';
			parent.style.border = (parent.className.indexOf('cnnActive') == -1) ? '4px solid #000' : '';
			desc.style.display = 'block';
			abbrevDesc.style.display = 'none';
		} else {
			parent.style.height = (browser != -1) ? '157px' : '135px';
			parent.style.border = (parent.className.indexOf('cnnActive') == -1) ? '4px solid #f2f2f2' : '';
			desc.style.display = 'none';
			abbrevDesc.style.display = 'block';
		}
	}
	
	function cnnToggleSlider(el) {
		if (d.getElementById('cnnSliderTabs')){
			d.getElementById('cnnSliderTabs').style.backgroundPosition = (el.id == 'cnnVideoLatest') ? '0 0' : '0 -29px';
			d.getElementById('cnnVideoLatestSwf').style.zIndex = (el.id == 'cnnVideoLatest') ? '1' : '0';
			d.getElementById('cnnVideoMostPopularSwf').style.zIndex = (el.id != 'cnnVideoLatest') ? '1' : '0';
		}
	}
	
	
	var cnnArchivePlaylists = new Array();
	cnnArchivePlaylists = [['cnnDriversArchive','0 -38','drivers'],['cnnRacesArchive','0 -76px','races'],['cnnFeaturesArchive','0 -114px','features']];
	var inline = d.getElementById('cnnVideoInline');
	var iframe = d.getElementById('cnnVideoIframe');
	
	function cnnShowVideoArchive(el,num) {
		var inline = d.getElementById('cnnVideoInline');
		var iframe = d.getElementById('cnnVideoIframe');
		if (defaultTab && el.id == cnnArchivePlaylists[num][0]) {
			if ('cnn' + defaultTab + 'Archive' == el.id) {
				if (iframe) {
					iframe.style.display = 'none';
				}
				inline.style.display = 'block';
			} else {
				inline.style.display = 'none';
				if (iframe) {
					iframe.parentNode.removeChild(iframe);
				}
				cnnBuildPlaylistIframe(cnnArchivePlaylists[num][2]);
			}
			d.getElementById('cnnArchiveTabs').style.backgroundPosition = cnnArchivePlaylists[num][1];
		}
	}
	
	/* builds the iframe on the video sect. page, to avoid being added to the browser's history */
	function cnnBuildPlaylistIframe(id,video) {
		var iframe = d.createElement('iframe');
		var src = '/.element/iframe/2.1/sect/video/' + id + '.html';
		if (video) {
			src += '?' + video;
		}
		iframe.setAttribute('src',src);
		iframe.setAttribute('scrolling','no');
		iframe.setAttribute('frameborder','no');
		iframe.setAttribute('class','cnnVideoIframe');
		iframe.style.position = 'absolute';
		iframe.style.left = '2px';
		iframe.style.display = 'block';
		iframe.style.width = '674px';
		iframe.style.height = '740px';
		iframe.setAttribute('id','cnnVideoIframe');
		d.getElementById('cnnVideoInline').parentNode.appendChild(iframe);
	}
	
	
	/* revision to load driver playlists on a video page */
	function cnnLoadDriver() {
		var iframe = d.getElementById('cnnVideoIframe');
		var driver = d.drivers.cupDdDrivers.value;
		if (inline) { /* then it's the video page making the request */
			inline.style.display = 'none';
			if (iframe) {
				iframe.parentNode.removeChild(iframe);
			}
			cnnBuildPlaylistIframe('drivers',driver);
		} else { /* it's the playlist (iframe) making the request */
			cnnGetPlaylistUrl(driver);
		}
	}
	
	
	/* revision to load race playlists on a video page */
	function cnnLoadRace() {
		var iframe = d.getElementById('cnnVideoIframe');
		var race = d.archive.archiveDdRace.value;
		if (race.indexOf('.element') == -1) {
			top.location = race;
		} else if (inline) { /* then it's the video page making the request */
			inline.style.display = 'none';
			if (iframe) {
				iframe.parentNode.removeChild(iframe);
			}
			cnnBuildPlaylistIframe('races',race);
		} else { /* it's the playlist (iframe) making the request */
			cnnGetPlaylistUrl(race);
		}
	}
	
	////// Update year dropdown //////
	function cnnUpdateYear() {
		var series = d.archive.series.value;
		var year = d.archive.year.value;
		if (series == 'cup') {
			cnnBuildArchiveYear(nascarGetObject('archiveDdYear'),'cup');
		} else if (series == 'bg') {
			cnnBuildArchiveYear(nascarGetObject('archiveDdYear'),'bg');
		} else if (series == 'truck') {
			cnnBuildArchiveYear(nascarGetObject('archiveDdYear'),'truck');
		}
		return cnnBuildRace(series);
	}
	
	
	/* revision to load feature playlists on a video page */
	function cnnLoadFeature() {
		var iframe = d.getElementById('cnnVideoIframe');
		var feature = d.features.cupDdFeatures.value;
		if (inline) { /* then it's the video page making the request */
			inline.style.display = 'none';
			if (iframe) {
				iframe.parentNode.removeChild(iframe);
			}
			cnnBuildPlaylistIframe('features',feature);
		} else { /* it's the playlist (iframe) making the request */
			cnnGetPlaylistUrl(feature);
		}
	}
	
	
	/* used to load the passed url (or a url param) as the playlist iframe's content */
	function cnnGetPlaylistUrl(url) {
		cnnSetPlaylistLinksTarget();
		
		if (!url && location.search) { /* the url is not passed so check the location for a param */
			var url = location.search.substring(1,location.search.length);
		}
		if (url) { /* if there is a url (either in location or passed to function), proceed */
			if (url.indexOf('.element') != -1) {
				var getPage = false;
				if (window.XMLHttpRequest) {
					getPage = new XMLHttpRequest();
				} else if (window.ActiveXObject) {
					try {
						getPage = new ActiveXObject("Msxml2.XMLHTTP")
					} 
					catch (e) {
						try{
							getPage = new ActiveXObject("Microsoft.XMLHTTP")
						}
						catch (e){}
					}
				} else {
					return false;
				}
				getPage.open('GET', url, false);
				getPage.send(null);
				d.getElementById('cnnVideoIframe').innerHTML = getPage.responseText;
				cnnBuildPagination();
			} else {
				top.location = url;
			}
		}
	}
	
	
	/* set the default tab on video pages -- "defaultTab" is defined in the page, via CMS */
	function cnnCheckDefaultTab(tab) {
		var url = location.search.substring(1,location.search.length);
		if (url && (url.indexOf('defaultTab') != -1)) {
			var defaultTab = url.substring(url.indexOf('=')+1,url.length);
			if (inline && (defaultTab == 'Drivers')) {
				d.getElementById('cnnArchiveTabs').style.backgroundPosition = cnnArchivePlaylists[0][1];
				var getPage = false;
				if (window.XMLHttpRequest) {
					getPage = new XMLHttpRequest();
				} else if (window.ActiveXObject) {
					try {
						getPage = new ActiveXObject("Msxml2.XMLHTTP")
					} 
					catch (e) {
						try{
							getPage = new ActiveXObject("Microsoft.XMLHTTP")
						}
						catch (e){}
					}
				} else {
					return false;
				}
				getPage.open('GET', '/.element/ssi/auto/2.1/aps/video/playlists/drivers/drivers.html', false);
				getPage.send(null);
				inline.innerHTML = getPage.responseText;
				inline.style.display = 'block';
			}
		 } else if (tab != '') { /* check to make sure this doesn't run for playlist loads */
			var currTab = 'cnn' + tab + 'Archive';
			for (var i = 0; i < cnnArchivePlaylists.length; i++) {
				if (currTab == cnnArchivePlaylists[i][0]) {
					d.getElementById('cnnArchiveTabs').style.backgroundPosition = cnnArchivePlaylists[i][1];
					inline.style.display = 'block';
				}
			}
		}
	}
	
	
	function cnnBuildPagination(num) {
		cnnCheckDefaultTab(defaultTab);
		if (!num) {
			num = 1;
		}
						
		if (d.location.href.indexOf('/iframe/2.1/') != -1) {
			var playlist = d.getElementById('cnnVideoIframe');
		} else {
			var playlist = d.getElementById('cnnVideoInline');
		}
		
		var playlistDivs = playlist.getElementsByTagName('div');
		
		var pages = 0;
		for (var h = 0; h < playlistDivs.length; h++) {
			if (playlistDivs[h].id.indexOf('cnnPage') != -1) {
				pages++;
			}
		}
		
		if (pages > 1) {
			var div = d.createElement('div');
			div.id = 'cnnPagination';
			playlist.appendChild(div);
			
			var prev = d.createElement('a');
			prev.id = 'cnnPrevPage';
			prev.href = (num > 1) ? 'javascript:cnnLoadPage(' + (num - 1) + ')' : 'javascript:;';
			var prevSpan = d.createElement('span');
			prevSpan.appendChild(d.createTextNode('<'));
			prev.appendChild(prevSpan);
			prev.appendChild(d.createTextNode(' Prev'));
			div.appendChild(prev);
			
			for (var i = 0; i < playlistDivs.length; i++) {
				if (playlistDivs[i].id.indexOf('cnnPage') != -1) {
					var id = playlistDivs[i].id.substring(7);
					var page = d.createElement('a');
					page.href = 'javascript:cnnLoadPage(' + id + ')';
					page.id = 'cnnPlaylistLink' + id;
					page.appendChild(d.createTextNode(id));
					page.className = (id == num) ? 'cnnActive' : '';
					div.appendChild(page);
				}
			}
	
			var next = d.createElement('a');
			next.id = 'cnnNextPage';
			next.href = (d.getElementById('cnnPlaylistLink' + (num + 1))) ? 'javascript:cnnLoadPage(' + (num + 1) + ')' : 'javascript:;';
			var nextSpan = d.createElement('span');
			nextSpan.appendChild(d.createTextNode('>'));
			next.appendChild(d.createTextNode('Next '));
			next.appendChild(nextSpan);
			div.appendChild(next);
			d.getElementById('cnnPage' + num).className = '';
		} else {
			d.getElementById('cnnPage1').style.display = 'block';
		}
	}
	
	function cnnLoadPage(num) {
		if (d.location.href.indexOf('/iframe/2.1/') != -1) {
			var playlist = d.getElementById('cnnVideoIframe');
		} else {
			var playlist = d.getElementById('cnnVideoInline');
		}
		
		var playlistDivs = playlist.getElementsByTagName('div');
		for (var i = 0; i < playlistDivs.length; i++) {
			if (playlistDivs[i].id.indexOf('cnnPage') != -1) {
				var page = playlistDivs[i].id.substring(7);
				d.getElementById('cnnPage' + page).style.display = (page == num) ? 'block' : 'none';
				d.getElementById('cnnPlaylistLink' + page).className = (page == num) ? 'cnnActive' : '';
			}
		}
		d.getElementById('cnnPrevPage').href = (num > 1) ? 'javascript:cnnLoadPage(' + (num - 1) + ')' : 'javascript:;';
		d.getElementById('cnnNextPage').href = (d.getElementById('cnnPlaylistLink' + (num + 1))) ? 'javascript:cnnLoadPage(' + (num + 1) + ')' : 'javascript:;';
	}
	
	
	/* runs through the playlist and adds target=_parent as necessary */
	function cnnSetPlaylistLinksTarget() {
		if (d.getElementById('cnnVideoIframe')) {
			var h3s = d.getElementById('cnnVideoIframe').getElementsByTagName('h3');
			for (var i = 0; i < h3s.length; i++) {
				if (h3s[i].parentNode.className == 'cnnDescription') {
					h3s[i].getElementsByTagName('a')[0].setAttribute('target','_parent');
				}
			}
		}
	}
	
//  LaunchVideo -- Redesign '09 updates -- 12/8/08, Dave Young //
function cnnLaunchVideo(url, tab) {
var videoUrl = url;
var popupWidth = '800';
var popupHeight = '600';
	var name = 'video';
var suffixRE = /\.?$/;
var suffix = suffixRE.exec(videoUrl);
	
	if (videoUrl.indexOf('/pr/') != -1) {
		videoUrl = videoUrl.replace('.html', "_frameset_exclude.html");
		popupWidth = 577;
	popupHeight = 465;
		name = 'oldVideo';
	}
	
if (suffix != '') {
if ((videoUrl.indexOf('/2006/') != -1) && (videoUrl.indexOf('/pr/video') == -1)) {
			videoUrl = '/pr/video' + videoUrl.replace(suffixRE, "_frameset_exclude.html");
			popupWidth = 577;
	    	popupHeight = 465;
			name = 'oldVideo';
		} else {
videoUrl = videoUrl.replace(suffixRE, "/frameset.exclude.html");
}
}
	
	if ((videoUrl.indexOf('/video/') == -1) && ((videoUrl.indexOf('/promos/') == -1) || (videoUrl.indexOf('/multimedia/') == -1))) {
videoUrl = "/video" + videoUrl;
	}

	if (tab) {
		videoUrl += ('?'+tab);
	} else {
		videoUrl += ('?MostPopular');
	}

if ((videoUrl.indexOf('/video/') != -1) && ((videoUrl.indexOf('/frameset.exclude.html') != -1) || (videoUrl.indexOf('_frameset_exclude.html') != -1))) {
var popupWindow = window.open(videoUrl,name,'width=' + popupWidth + ',height=' + popupHeight + ',scrollbars=no,resizable=yes');
		popupWindow.focus();
} else {
top.location.href = videoUrl;
}
}

/*
if (d.getElementById('cnnBelowFold')) {
	d.getElementById('cnnBelowFold').removeChild(d.getElementById('cnnVideoIframe'));
}
*/