function parseParams(string, arrays) {
	var params = new Array();
	var args = string.split('&');
	for (var i=0; i<args.length; i++) {
		var arg = args[i].split('=', 2);
		if (arrays) {
			if (!params[arg[0]]) {
				params[arg[0]] = new Array();
			}
			params[arg[0]][params.length] = arg[1];
		} else {
			params[arg[0]] = arg[1];
		}
	}
	return params;
}

var channelUrls = new Array();
channelUrls["Top Videos"] = "/sections/i_video/videoplayer500251.shtml";
channelUrls["i_video"] = "/sections/i_video/videoplayer500251.shtml";
channelUrls["standard"] = "/sections/i_video/videoplayer500251.shtml";
channelUrls["eveningnews"] = "/sections/eveningnews/videoplayer3420.shtml";
channelUrls["EveningNews"] = "/sections/eveningnews/videoplayer3420.shtml";
channelUrls["CBS Evening News"] = "/sections/eveningnews/videoplayer3420.shtml";
channelUrls["earlyshow"] = "/sections/earlyshow/videoplayer500202.shtml";
channelUrls["The Early Show"] = "/sections/earlyshow/videoplayer500202.shtml";
channelUrls["48Hours"] = "/sections/48hours/videoplayer3410.shtml";
channelUrls["48 Hours Mystery"] = "/sections/48hours/videoplayer3410.shtml";
channelUrls["48 Hours Ondemand"] = "/sections/48hours/ondemand/videoplayer501663.shtml";
channelUrls["48Ondemand"] = "/sections/48hours/ondemand/videoplayer501663.shtml";
channelUrls["48HoursOndemand"] = "/sections/48hours/ondemand/videoplayer501663.shtml";
channelUrls["60Sunday"] = "/sections/60minutes/videoplayer3415.shtml";
channelUrls["60 Minutes"] = "/sections/60minutes/videoplayer3415.shtml";
channelUrls["60Minutes"] = "/sections/60minutes/videoplayer3415.shtml";
channelUrls["60Wed"] = "/sections/60minutes/videoplayer3415.shtml";
channelUrls["us"] = "/sections/national/videoplayer201.shtml";
channelUrls["U.S."] = "/sections/national/videoplayer201.shtml";
channelUrls["national"] = "/sections/national/videoplayer201.shtml";
channelUrls["National"] = "/sections/national/videoplayer201.shtml";
channelUrls["world"] = "/sections/world/videoplayer202.shtml";
channelUrls["World"] = "/sections/world/videoplayer202.shtml";
channelUrls["politics"] = "/sections/politics/videoplayer250.shtml";
channelUrls["Politics"] = "/sections/politics/videoplayer250.shtml";
channelUrls["health"] = "/sections/health/videoplayer204.shtml";
channelUrls["Health"] = "/sections/health/videoplayer204.shtml";
channelUrls["tech"] = "/sections/tech/videoplayer205.shtml";
channelUrls["Tech"] = "/sections/tech/videoplayer205.shtml";
channelUrls["scitech"] = "/sections/tech/videoplayer205.shtml";
channelUrls["SciTech"] = "/sections/tech/videoplayer205.shtml";
channelUrls["entertainment"] = "/sections/entertainment/videoplayer207.shtml";
channelUrls["Entertainment"] = "/sections/entertainment/videoplayer207.shtml";
channelUrls["GameCore"] = "/sections/tech/gamecore/videoplayer500397.shtml";
channelUrls["gamecore"] = "/sections/tech/gamecore/videoplayer500397.shtml";
channelUrls["CBS Evening News On Demand"] = "/sections/eveningnews/ondemand/videoplayer500843.shtml";
channelUrls["cbs evening news on demand"] = "/sections/eveningnews/ondemand/videoplayer500843.shtml";
channelUrls["ondemand"] = "/sections/eveningnews/ondemand/videoplayer500843.shtml";
channelUrls["couricandco"] = "/sections/couricandco/videoplayer500803.shtml";
channelUrls["face the nation"] = "/sections/ftn/videoplayer3460.shtml";
channelUrls["ftn"] = "/sections/ftn/videoplayer3460.shtml";


var channelAdParam = new Array();
channelAdParam["Top Videos"] = "show=news;feat=topvideo";
channelAdParam["i_video"] = "show=news;feat=topvideo";
channelAdParam["standard"] = "show=news;feat=topvideo";
channelAdParam["/sections/i_video/videoplayer500251.shtml"] = "show=news;feat=topvideo";
channelAdParam["eveningnews"] = "show=eveningnews";
channelAdParam["EveningNews"] = "show=eveningnews";
channelAdParam["CBS Evening News"] = "show=eveningnews";
channelAdParam["/sections/eveningnews/videoplayer3420.shtml"] = "show=eveningnews";
channelAdParam["earlyshow"] = "show=earlyshow";
channelAdParam["The Early Show"] = "show=earlyshow";
channelAdParam["/sections/earlyshow/videoplayer500202.shtml"] = "show=earlyshow";
channelAdParam["48Hours"] = "show=48hours";
channelAdParam["48 Hours"] = "show=48hours";
channelAdParam["/sections/48hours/videoplayer3410.shtml"] = "show=48hours";
channelAdParam["60 Minutes"] = "show=60minutes";
channelAdParam["60Minutes"] = "show=60minutes";
channelAdParam["/sections/60minutes/videoplayer3415.shtml"] = "show=60minutes";
channelAdParam["us"] = "show=news;feat=us";
channelAdParam["U.S."] = "show=news;feat=us";
channelAdParam["national"] = "show=news;feat=us";
channelAdParam["National"] = "show=news;feat=us";
channelAdParam["/sections/national/videoplayer201.shtml"] = "show=news;feat=us";
channelAdParam["world"] = "show=news;feat=world";
channelAdParam["World"] = "show=news;feat=world";
channelAdParam["/sections/world/videoplayer202.shtml"] = "show=news;feat=world";
channelAdParam["politics"] = "show=news;feat=politics";
channelAdParam["Politics"] = "show=news;feat=politics";
channelAdParam["/sections/politics/videoplayer250.shtml"] = "show=news;feat=politics";
channelAdParam["health"] = "show=news;feat=health";
channelAdParam["Health"] = "show=news;feat=health";
channelAdParam["/sections/health/videoplayer204.shtml"] = "show=news;feat=health";
channelAdParam["tech"] = "show=news;feat=scitech";
channelAdParam["Tech"] = "show=news;feat=scitech";
channelAdParam["scitech"] = "show=news;feat=scitech";
channelAdParam["SciTech"] = "show=news;feat=scitech";
channelAdParam["/sections/tech/videoplayer205.shtml"] = "show=news;feat=scitech";
channelAdParam["entertainment"] = "show=news;feat=entertainment";
channelAdParam["Entertainment"] = "show=news;feat=entertainment";
channelAdParam["/sections/entertainment/videoplayer207.shtml"] = "show=news;feat=entertainment";
channelAdParam["GameCore"] = "show=news;feat=gamecore";
channelAdParam["gamecore"] = "show=news;feat=gamecore";
channelAdParam["/sections/tech/gamecore/videoplayer500397.shtml"] = "show=news;feat=gamecore";
channelAdParam["CBS Evening News On Demand"] = "show=eveningnews;feat=ondemand";
channelAdParam["cbs evening news on demand"] = "show=eveningnews;feat=ondemand";
channelAdParam["ondemand"] = "show=eveningnews;feat=ondemand";
channelAdParam["/sections/eveningnews/ondemand/videoplayer500843.shtml"] = "show=eveningnews;feat=ondemand";
channelAdParam["couricandco"] = "show=eveningnews;feat=couricandco";
channelAdParam["/sections/couricandco/videoplayer500803.shtml"] = "show=eveningnews;feat=couricandco";
channelAdParam["face the nation"] = "show=facethenation";
channelAdParam["ftn"] = "show=facethenation";
channelAdParam["/sections/ftn/videoplayer3460.shtml"] = "show=facethenation";

var wmvDate = "20031120"


/*updated cchamberlain@cbs.com*/
/*changes css on the fly*/
var currentStyleSheet = null;
function setActiveStyleSheet(title) {
	if (title == currentStyleSheet)
		return;
	currentStyleSheet = title;
  var i, a, main;
  if (title) {
    for(i=0; (a = document.getElementsByTagName('link')[i]); i++) {
      if(a.getAttribute('rel').indexOf('style') != -1 && a.getAttribute('title')) {
        a.disabled = true;
        if(a.getAttribute('title') == title) a.disabled = false;
      }
    }
  }
}


function contract() {
	html = '<img src="http://www.cbsnews.com/htdocs/videoplayer/images/button_exp_open.gif" alt="Open Popular Videos" onclick="expand();" width="27" height="561" border="0" style="cursor:pointer">';
	document.getElementById("popvideos").innerHTML = html;
}

var intro =  "<font class=\"text_left\">A custom playlist lets you pick the CBSNews.com videos you want to watch and plays them one right after the other in the order you've chosen.<br/><br/> To create your playlist, click on the \"Add To Playlist\" button next to the clips you want to see. When you are ready to start watching, click on the \"Play Playlist\" button that appears in the space above.</font>";

function changeHeader(name) {
    document.getElementById('channel_header').innerHTML = name;
}
function emailVideo(id, title, section) {
	javascript:launch('ShareVideo', 540, 480, "/htdocs/emailtoafriend/videoplayer_share.html?id=" + id + "&section=" + section + "&title="+ title);
}
function showVideoHelp() {
	window.open("http://www.cbsnews.com/htdocs/videoplayer/newVid/framesource_mediahelp.html", "video_help", 'width=610,height=450,scrollbars=0,location=0,menubar=0,resizable=0');
}
function playVideo(id, format) {
	if (!format) {
		var idnum = parseInt(id);
		if (idnum < 10) { 
			format = "wmv"; 
		} else if (idnum < 584542) {
			format = "rm";
		} else {
			var video = player.cache.getVideo(id);
			if (video && video.format) {
				if (video.format == 'n') video.format = "rm|wmv|flv";
				format = video.format;
				if ((format.indexOf("wmv") >= 0) && (format.indexOf("flv") < 0)) {
					format += "|flv";
				}
			} else { 
				format = "rm|wmv|flv";
			}
		}
	}
	player.play(id, format);
}
function addVideo(id, format, error) {
	if (!format) {
		var idnum = parseInt(id);
		if (idnum < 10) { 
			format = "wmv"; 
		} else if (idnum < 584542) {
			format = "rm";
		} else {
			var video = player.cache.getVideo(id);
			if (video && video.format) {
				if (video.format == 'n') video.format = "rm|wmv";
				format = video.format;
			} else { 
				format = "rm|wmv";
			}
		}
	}
	if (!player.addVideo(id, format)) {
		if (!error) {
			alert("You browser does not support play lists.  Please see the help for details");
		}
	}
}
var registered = false;
function beforePlayVideo() {
	var video = player.getCurrentVideo();
	if (!registered) {
		var needReg = false;
		if (video.videoId == "5n") {
			needReg = true;
		} else if (video.sectionId == 500843) {
			var now = new Date();
			if ((video.createDate) && (video.createDate.getYear() == now.getYear()) && (video.createDate.getDate() == now.getDate()) && (video.createDate.getMonth() == now.getMonth()) && (now.getDate() < 22)) {
				needReg = true;
			}				
		}
		if (needReg) {
			var iFrame = this.getIFrameDocument();
			iFrame.src = "/common/vplayerCouric/register.php?id=" + video.videoId;
			iFrame.location.href = "/common/vplayerCouric/register.php?id=" + video.videoId;
			player.redraw = true;
			return false;
		}
	}
	return true;
}
function removeVideo(id) {
	player.removeVideo(id);
}

function removeEntities(text) {
	if (text == null)
		return "";
	var regEx = /&lt;/gi;
	text = text.replace(regEx, '<');
	regEx = /&gt;/gi;
	text = text.replace(regEx, '>');
	regEx = /&amp;/gi;
	text = text.replace(regEx, '&');
	return text;
}

//---------------------------------------------------------
//Updates Now Playing copy
function updateNowPlaying() {
	var tabContentElm = document.getElementById('tab_content_np');
	if (!tabContentElm) return;

	var video = player.getCurrentVideo();
	var nextVideo = player.getNextVideo();
	//var nextVideoID = nextVideo.Id.split('n');
	if (!video) {
		tabContentElm.innerHTML = "Please select a video on the right to playback. If your player is in \"mini\" mode, click the \"standard\" button above and then select a video of your choice to playback.";
		return;
	}
	var id = video.videoId;
	var idSplit = id.split('n');
	
	
	var section = escape(video.sectionName);
	if(section == 'U.S.'){section = "national";}else{section = section}
	var vtitle = escape(video.title).replace(/%27/ig, "\\'");
	if (video == null) {
		tabContentElm.innerHTML = "";
	} else {
		var html = "<div class=\"headline_left\"><div style=\"float:right;padding-top:3px\"><span onclick=\"emailVideo('"+id+"','"+vtitle+"', '"+section+"')\" class=\"link_left\" onmouseover=\"this.className='link_left_on'\" onmouseout=\"this.className='link_left'\" title=\"Share & Embed This Video\"><image src=\"http://wwwimage.cbsnews.com/common/vplayerCouric/button_share.gif\" hspace=\"1\"/></span><span onclick=\"Digg.remoteSubmit('http://www.cbsnews.com/sections/i_video/main500251.shtml?id="+id+"','"+unescape(vtitle).replace(/#$/ig, '')+"','', '');return false\" class=\"link_left\" onmouseover=\"this.className='link_left_on'\" onmouseout=\"this.className='link_left'\" title=\"Digg This Video\"><img src=\"http://wwwimage.cbsnews.com/common/vplayerCouric/button_digg.gif\" alt=\"Digg!\"></span></div>"+removeEntities(video.title)+"&nbsp;</div>";
		html += "<span class=\"text_left\">"+removeEntities(video.caption)+" </span><br>";
		
		if(nextVideo){
		html += "<image src=\"/common/images/transp.gif\" width=\"1\" height=\"25\"/><span class=\"textsmall_left\" style=\"font-weight: bold;\">UP NEXT:&nbsp;</span><span class=\"text_playlist_white\" style=\"font-size: 16px\">"+removeEntities(nextVideo.title)+"</span>&nbsp; ("+controls.getTimeString(nextVideo.dur)+")";
		}
		tabContentElm.innerHTML = html;
	}
	executeFrameCommand("IFrame1", "updateNowPlaying");
}

//---------------------------------------------------------
//Updates Related copy
function updateRelated() {
	var tabContentElm = document.getElementById('tab_content_rel');
	if (!tabContentElm) return;

	var video = player.getCurrentVideo();
	if (!video) {
		tabContentElm.innerHTML = "";
		return;
	}
	var id = video.videoId;
	if (video == null) {
		tabContentElm.innerHTML = "";
	} else {
		var html = "";
		html += "<span onmouseover=\"this.className='link_left_on'\" onmouseout=\"this.className='link_left'\" class=\"headline_left\">"+removeEntities(video.title)+"</span><br/>";
		html += "<span class=\"text_left\">"+video.related+" |</span> <span onclick=\"linkTo('"+id+"')\" class=\"link_left\" onmouseover=\"this.className='link_left_on'\" onmouseout=\"this.className='link_left'\" title=\"Read Story\">Read Story</span><br>";
		html += "";
		tabContentElm.innerHTML = html;
	}
}

var moving = 0;
function moveUp(pos) {
	if (pos > 0) {
		if (document.all) {
			moving = moving + 1;
			for (var i=player.playlist.videos.length-1; i>=pos-1; i--) {
			if (player.playlist.videos.length >= 3) {
				var tabset_content = document.getElementById("tabset_content");
				tabset_content.style.overflowY = "scroll";
			}
				var div = document.getElementById("playlistVideo" + i);
				if (document.all) {
					div.style.top = div.offsetTop;
					div.style.left = div.offsetLeft;
				} else {
					div.style.top = div.offsetTop + 44;
					div.style.left = div.offsetLeft + 5;
				}
				div.style.position = "absolute";
			}
			var div1 = document.getElementById("playlistVideo" + (pos-1));
			var div2 = document.getElementById("playlistVideo" + pos);
			
			player.playlist.moveUp(pos);
			
			setTimeout("animateVideoSwitch('playlistVideo" + (pos-1) + "', 'playlistVideo" + pos + "', 1, " + parseInt(div2.style.top) + ", " + parseInt(div1.style.top) + ", 20, " + moving + ")", 20);
		} else {
			player.playlist.moveUp(pos);
			updatePlaylist();
		}
	}
}
function moveDown(pos) {
	if (pos < player.playlist.videos.length-1) {
		if (document.all) {
			moving = moving + 1;
			if (player.playlist.videos.length >= 3) {
				var tabset_content = document.getElementById("tabset_content");
				tabset_content.style.overflowY = "scroll";
			}
			for (var i=player.playlist.videos.length-1; i>=pos; i--) {
				var div = document.getElementById("playlistVideo" + i);
				if (document.all) {
					div.style.top = div.offsetTop;
					div.style.left = div.offsetLeft;
				} else {
					div.style.top = div.offsetTop + 44;
					div.style.left = div.offsetLeft + 5;
				}
				div.style.position = "absolute";
			}
			var div1 = document.getElementById("playlistVideo" + pos);
			var div2 = document.getElementById("playlistVideo" + (pos+1));
			
			player.playlist.moveDown(pos);
			
			setTimeout("animateVideoSwitch('playlistVideo" + pos + "', 'playlistVideo" + (pos+1) + "', 1, " + parseInt(div2.style.top) + ", " + parseInt(div1.style.top) + ", 20, " + moving + ")", 20);
		} else {
			player.playlist.moveDown(pos);
			updatePlaylist();
		}
	}
}
function animateVideoSwitch(id1, id2, step, end1, end2, time, movingNum) {
	if (moving != movingNum) {
		updatePlaylist();
		var tabset_content = document.getElementById("tabset_content");
		tabset_content.style.overflowX = "visible";
		tabset_content.style.overflowY = "auto";
		return;
	}
	var div1 = document.getElementById(id1);
	var div2 = document.getElementById(id2);
	var pos1 = parseInt(div1.style.top);
 	var pos2 = parseInt(div2.style.top);
	var done = true;
	if (Math.abs((pos1 + step) - end1) < Math.abs(step)) {
		div1.style.top = end1;
	} else {
		done = false;
		div1.style.top = pos1 + step;
	}
	if (Math.abs((pos2 - step) - end2) < Math.abs(step)) {
		div2.style.top = end2;
	} else {
		done = false;
		div2.style.top = pos2 - step;
	}
	if ((done) || (!moving)) {
		moving = 0;
		updatePlaylist();
		var tabset_content = document.getElementById("tabset_content");
		tabset_content.style.overflowX = "visible";
		tabset_content.style.overflowY = "auto";
	} else {
		setTimeout("animateVideoSwitch('" + id1 + "', '" + id2 + "', " + step + ", " + end1 + ", " + end2 + ", " + time + ", " + movingNum + ");", time);
	}
}
var clearAllState = "none";
function updatePlaylist() {
	if (moving) return;
	
	var playlist = player.playlist;
	var length = playlist.getLength();
		
	var playlistDiv = document.getElementById("playList");
	var playlistTally = document.getElementById("tab_pl_tally");
	if (playlistDiv) {
		if (playlist.areAllVideosLoaded()) {
			var html = "";
			var i = playlist.getCurrentPosition();
	
			/*CODE ADDITITON/UPDATE - tjlee@cbs.com */            
			if (!player.isStopped()) {      
				if (i < length) {
					var video = playlist.getVideo(i);
					html += "<div id=\"playlistVideo" + i + "\" class=\"playlist_video\"><div style=\"float:left; margin-left: 4px; height:29px; width:220px; overflow:hidden;\"><a name=\"vid\" onclick=\"playVideo('" + video.videoId + "');\" class=\"text_playlist_white\" style=\"cursor:pointer;\">" + video.title + "</a></div>";
					html += "<div style=\"float: right; margin-right: 2px;\">";
					//html += "<img src=\"/common/images/transp.gif\" border=\"0\" onclick=\"playVideo('" + video.videoId + "');\" class=\"playlist_play_off\" alt=\"Play Video\">";                  
					html += "</div></div>";
					playlistTally.innerHTML = '('+length+')';
					i++;
				}
			}
				
			for ( ; i< length; i++) {
				var video = playlist.getVideo(i);
				html += "<div id=\"playlistVideo" + i + "\" class=\"playlist_video\"><div style=\"float: left; margin-left: 4px; height:29px; width:220px; overflow:hidden;\"><a name=\"vid\" onclick=\"playVideo('" + video.videoId + "');\" class=\"text_playlist_white\" style=\"cursor:pointer;\">" + video.title + "</a></div>";
				html += "<div style=\"float: right; margin-right: 2px;\">";
				html += "<img src=\"/common/images/transp.gif\" border=\"0\" onclick=\"playVideo('" + video.videoId + "');\" class=\"playlist_play_off\" alt=\"Play Video\"  onmouseover=\"this.className='playlist_play';\" onmouseout=\"this.className='playlist_play_off';\">";
				if(length > 1 ) {
					html += "<img src=\"/common/images/transp.gif\" border=\"0\" class=\"playlist_clear_off\" onclick=\"removeVideo('" + video.videoId + "');\" alt=\"Remove Video From Playlist\" onmouseover=\"this.className='playlist_clear';\" onmouseout=\"this.className='playlist_clear_off';\">";
					html += "<img src=\"/common/images/transp.gif\" border=\"0\" class=\"playlist_up_off\" onclick=\"moveUp("+i+")\" alt=\"Move Video Up\" onmouseover=\"this.className='playlist_up';\" onmouseout=\"this.className='playlist_up_off';\">";
					html += "<img src=\"/common/images/transp.gif\" border=\"0\" class=\"playlist_down_off\" onclick=\"moveDown("+i+")\" alt=\"Move Video Down\" onmouseover=\"this.className='playlist_down';\" onmouseout=\"this.className='playlist_down_off';\">";
				}
				html += "</div></div>";
				playlistTally.innerHTML = '('+length+')';             
			}        
			playlistDiv.innerHTML = html;
		}
	}
		
	var playlistControlsDiv = document.getElementById("playListStatus");
	if (playlistControlsDiv) {
		if (playlist.getLength() > 0) {
			if (clearAllState != "clear") {
				clearAllState = "clear";
				var html = "<div class=\"playlist_clearall_div\"><img src=\"/common/images/transp.gif\" border=\"0\" class=\"playlist_clearall_off\" onclick=\"player.stop(); player.playlist.removeAllVideos(); player.setCurrentVideo(null);\" alt=\"Clear Playlist\" onmouseover=\"this.className='playlist_clearall';\" onmouseout=\"this.className='playlist_clearall_off';\"></div>";
				playlistControlsDiv.innerHTML = html;
			}
		} else {
			if (clearAllState != "empty") {
				clearAllState = "empty";
				playlistControlsDiv.innerHTML = "Your playlist is empty. To add a video to your playlist click the \"add to playlist\" button on the right. If your player is in \"mini\" mode, click the \"standard\" button above and then add videos to your playlist.";
			}
		}
		playlistTally.innerHTML = '('+length+')';
	}
	  
	executeFrameCommand("IFrame1", "updatePlaylist");
}

/*CODE ADDITITON/UPDATE - tjlee@cbs.com */
//Toggles Playlist, Now Playing, Related tabs
function Tabs(){
    this.tabParentDiv = document.getElementById('tabset_buttons');
    this.tabSet = new Object();

    this.buildTabContentDivs = function (){
        this.contentParentDiv = document.getElementById('tabset_content');
        for(i=0;i<this.vidTabs.length;i++){
            var contentDiv = document.createElement('div');
            contentDiv.id = "tab_content_"+this.vidTabs[i];
            if (this.vidTabs[i] == this.plTab){
                var plStatusDiv = document.createElement('div');
                plStatusDiv.id = "playListStatus";
                var pldiv = document.createElement('div');
                pldiv.id = "playList";
                pldiv.innerHTML = intro;
                contentDiv.appendChild(plStatusDiv);
                contentDiv.appendChild(pldiv);
            }else if (this.vidTabs[i] == this.npTab){
                contentDiv.innerHTML = "Please select a video on the right to playback. If your player is in \"mini\" mode, click the \"standard\" button above and then select a video of your choice to playback."          
            }/*else if (this.vidTabs[i] = this.relTab){
				contentDiv.innerHTML = "No Video Playing" 
			}*/
            contentDiv.style.display = (this.vidTabs[i] == this.defaultTab) ? "block" : "none";
            this.contentParentDiv.appendChild(contentDiv);
        }
    }

    this.init = function (){
        for(i=0;i<this.vidTabs.length;i++){
            this.tabSet[this.vidTabs[i]] = document.createElement('div');
            this.tabSet[this.vidTabs[i]].id = "tab"+player.objectId+"_" + this.vidTabs[i];
            this.tabSet[this.vidTabs[i]].className = (this.vidTabs[i] == this.defaultTab) ? "tab_on" : "tab_off";
            this.tabSet[this.vidTabs[i]].innerHTML = this.vidTabLbls[i];
            if (this.vidTabs[i] == this.plTab) {
                 this.tabSet[this.vidTabs[i]].innerHTML =  this.tabSet[this.vidTabs[i]].innerHTML + "<span id='tab_pl_tally'></span>";        
            }
             
            this.tabSet[this.vidTabs[i]].onmouseover = function (){
                var stateTest = /off/;
                if(stateTest.test(this.className)) this.style.color = "#FFF";         
            }
            
            this.tabSet[this.vidTabs[i]].onmouseout = function (){
                var stateTest = /off/;
                if(stateTest.test(this.className)) this.style.color = "#CCCCDD";         
            }
            
            this.tabSet[this.vidTabs[i]].onclick = function (){
                var tabDivs = document.getElementsByTagName('div');
                var tabTest = /^tab[0-9]+_/;
                var contentTest = /^tab_content_/;
                
                for (i=0;i<tabDivs.length;i++){
                    if(tabTest.test(tabDivs[i].id)){               
                        tabDivs[i].className = 'tab_off';
                        tabDivs[i].style.color = '#ccd';
                    }else if(contentTest.test(tabDivs[i].id)){
                        tabDivs[i].style.display = 'none';
                    }                                   
                }
                
                this.className = 'tab_on';
                this.style.color = '#667';
                document.getElementById('tab_content_'+this.id.replace(/tab[0-9]*_/,'') ).style.display = 'block';                       
            }   
                                 
            this.tabParentDiv.appendChild(this.tabSet[this.vidTabs[i]]);   
        }
    }    
   
}


/*CODE ADDITITON/UPDATE - tjlee@cbs.com */
//Show thumbs/headlines toggle
var headlinesState;

function LayoutViews(argObj){
    this.parentDiv = document.getElementById('layout_views');  
    this.layouts = new Object();
    this.icons = new Array("thumbs","heads");
    this.defaultLayout = "thumbs";
    
    this.init = function (){   
        for (i = 0; i<this.icons.length; i++){
            this.layouts[this.icons[i]] = document.createElement('img');
            this.layouts[this.icons[i]].src = "/common/images/transp.gif";
            this.layouts[this.icons[i]].border = 0;
            if (this.defaultLayout == this.icons[i]){
                this.layouts[this.icons[i]].className = "button_"+this.icons[i];
                this.layouts[this.icons[i]].id = "layoutSet";
            }else{
                this.layouts[this.icons[i]].className = "button_"+this.icons[i]+"_off";
            }
            
            this.layouts[this.icons[i]].onmouseover = function(){
                var stateTest = /off/;
                if(stateTest.test(this.className)) this.className =  this.className.replace(/_off/,'');
            }
            
            this.layouts[this.icons[i]].onmouseout = function(){
                var stateTest = /off/;             
                if(!stateTest.test(this.className) && this.id != "layoutSet" ) this.className = this.className + "_off";
            }
            
            this.layouts[this.icons[i]].onclick = function (){  
                var currLayout = document.getElementById("layoutSet");            
                if (currLayout && this.id != "layoutSet"){
                    currLayout.className = currLayout.className + "_off";
                    currLayout.removeAttribute('id');                       
                }                
                var stateTest = /heads/;
                var state = (stateTest.test(this.className)) ? "on" : "off";
                
								var synopDivs = self.IFrame1.document.getElementsByTagName("div"); 
                var synopIdTest = /^video/;
                for (i = 0; i < synopDivs.length; i++){
                    if(synopIdTest.test(synopDivs[i].id)){
                        if(state == "on"){                
                            self.IFrame1.document.getElementById(synopDivs[i].id).style.display = 'none';
                        }else if(state == "off"){
                            self.IFrame1.document.getElementById(synopDivs[i].id).style.display = "block";                
                        }
                    }                                                   
                }
								/*
								if(state == "on"){                
									hideDescriptions();
								}else if(state == "off"){
									showDescriptions();
								}*/
								
                headlinesState = state;                
                this.id = "layoutSet";
            }
            this.parentDiv.appendChild(this.layouts[this.icons[i]]);
        }
    }
    //Called from IFRAME
    this.toggle = function(toggle){
        var synopDivs = self.IFrame1.document.getElementsByTagName("div");
        var synopIdTest = /^video/;
        for (i = 0; i < synopDivs.length; i++){
            if(synopIdTest.test(synopDivs[i].id)){
                if(toggle == "on"){
                    self.IFrame1.document.getElementById(synopDivs[i].id).style.display = 'none';
                }else if(toggle == "off"){
                    self.IFrame1.document.getElementById(synopDivs[i].id).style.display = "block";
                }
            }
        }
			/*
			if(toggle == "on"){                
				hideDescriptions();
			}else if(toggle == "off"){
				showDescriptions();
			}
			*/
    }
    
}

// Creates a, b, or c for dart ad targetting:  cchamnberlain@cbs.com
//var adv = "";
var rNum = "";
var alph = new Array();
	alph[0] = 'a';
	alph[1] = 'b';
	alph[2] = 'c';

	
var bc = getCookieValue('buzzCookie');/*is the cookie created*/


/*creates a session based cookie*/
function set_this_Cookie(cookieName, cookieValue)
	{ 
	 if (cookieValue != null && cookieValue != ""){
		cookieValue = escape(cookieValue); 
		document.cookie=cookieName + "=" + cookieValue + "; " + cookiePath;
		cookieString = document.cookie;
		}
	}
	
if (!bc || bc == 'undefined' || bc == ' ')
{
	
	var rNum = Math.floor(Math.random() * 3);
	//adv = alph[rNum];/*dart ad code*/
	
	set_this_Cookie('buzzCookie', alph[rNum]);	/*creates a session cookie*/

}
else
{
	//var adv = bc;/*if cookie then value is passed to DART*/
}


//----------------------------------------------------------------------
// Descriptions
function executeFrameCommand(name, commandName) {
	var frame = document.getElementById(name);
	if (!frame) return;
	var doc = frame.contentWindow.document;
	if (!doc.forms.controlForm) { return; }
	var command = doc.forms.controlForm[commandName];
	if (command) {
		command.onclick();
	}
}	
function showDescriptions() {
	executeFrameCommand("IFrame1", "showDescriptions");
}
function hideDescriptions() {
	executeFrameCommand("IFrame1", "hideDescriptions");
}
function doHideDescriptions() {
	var again = false;
	var divs = document.getElementsByTagName("div");
	for (var i=0; i<divs.length; i++) {
		var div = divs[i];
		if (div.id.indexOf("video") == 0) {
			if (!div.originalHeight) {
				div.originalHeight = div.offsetHeight;
				div.style.height = div.offsetHeight;
				div.style.overflow = "hidden";
			}
			if (parseInt(div.style.height) > 0) {
				again = true;
				if (parseInt(div.style.height) < 5) {
					div.style.height = "0";
					div.style.display = "none";
				} else {
					div.style.height = parseInt(div.style.height) - 5;
				}
			}
		}
	}
	if (again) {
		window.setTimeout(doHideDescriptions, 20);
	}
}
function doShowDescriptions() {
	var again = false;
	var divs = document.getElementsByTagName("div");
	for (var i=0; i<divs.length; i++) {
		var div = divs[i];
		if (div.id.indexOf("video") == 0) {
			if (parseInt(div.style.height) < div.originalHeight) {
				again = true;
				if (parseInt(div.style.height) > div.originalHeight-5) {
					div.style.height = div.originalHeight;
				} else {
					div.style.height = parseInt(div.style.height) + 5;
				}
			}
			if (div.style.display == "none")
				div.style.display = "";
		}
	}
	if (again) {
		window.setTimeout(doShowDescriptions, 20);
	}
}


//----------------------------------------------------------------------
// Animate video
var videoAnimator = null;
function animateVideoPlay(id, img, x, y) {
	if (!videoAnimator) {
		videoAnimator = new Animator();
		videoAnimator.attachEvent("onAnimationDone", onVideoAnimationDone);
	}
	var image = document.getElementById("animationImage");
	image.style.display = "";
	videoAnimator.setImage(image, img, 630+x, 90+y, 100, 75, 0);
	var animation = videoAnimator.animate(image, 9, 77, 480, 360, 20, 10);
	animation.videoId = id;
}
function animateVideoAdd(id, img, x, y) {
	if (!videoAnimator) {
		videoAnimator = new Animator();
		videoAnimator.attachEvent("onAnimationDone", onVideoAnimationDone);
	}
	var image = document.getElementById("animationImage");
	image.style.display = "";
	videoAnimator.setImage(image, img, 630+x, 90+y, 100, 75, 0);
	animation = videoAnimator.animate(image, 270, 487, 10, 10, 20, 10);
}
function animateChannel(obj, url, adparams) {
	/*if (!videoAnimator) {
		videoAnimator = new Animator();
		videoAnimator.attachEvent("onAnimationDone", onVideoAnimationDone);
	}
	var pos = getElementPosition(obj);
	var image = document.getElementById("animationImage");
	image.style.display = "";
	image.style.borderColor = "white";
	videoAnimator.setImage(image, "http://www.cbsnews.com/common/vplayer2/images/newImages/transp.gif", pos.x, pos.y, 110, 17, "1 solid white");
	
	
	animation = videoAnimator.animate(image, 625, 100, 315, 545, 20, 10);
	animation.url = url;*/
	
	
	/*change made 11/27/2007: 14:26 pm ET by cchamberlain@cbs.com
	revision: simply uncomment the above block (lines 740 - 752 should be uncommented)
	remove lines 759 - 760
	*/
	var iframe = document.getElementById("IFrame1");
	iframe.src = url;
	/*change made 01/22/2007: 12:10 pm ET by cchamberlain@cbs.com*/
	dcTag = "http://ad.doubleclick.net/adj/sponsorships.cbsnews.com/video/fs/;"+adparams+";dcopt=;abr=!webtv;arena=video;adv="+adv+";sec=;tile=1;sz=150x25;ord=" + ord;
	printAd(dcTag);
}
function onVideoAnimationDone(type, animation) {
	hideVideoAnimation(animation);
	if (animation.videoId) {
		player.setImage(animation.object.src);
		window.setTimeout("playVideo('" + animation.videoId + "n');", 1);
	}
	if (animation.url) {
		var iframe = document.getElementById("IFrame1");
		iframe.src = animation.url;
	}
	//window.setTimeout("hideVideoAnimation(_objects[" + animation.objectId + "]);", 10);
	//playVideo(animation.videoId + 'n', 'wmv|rm');
}
function hideVideoAnimation(animation) {
	animation.object.style.display = "none";
}


function onLiveCommand(evt, type, param) {
	if (type == "livead") {
		var adDiv = document.getElementById("adDiv" + adController.objectId);
		if (adDiv) {
			if (param == "none") {
				adDiv.style.visibility = "hidden";
				adDiv.innerHTML = "";
			} else {
				var adUrl = "http://ad.doubleclick.net/adi/videos.cbsnews.com/cbsnews;adv=" + param + ";abr=!webtv;tile=1;dcopt=;pop=off;sz=300x60;ord=" + Math.random()*10000000;

				var html = adController.startHTML;
				html += '<IFRAME ID="adFrame" SRC="' + adUrl + '" FRAMEBORDER="0" SCROLLING="NO" width="300" height="60" BORDER="0"></IFRAME>';
				html += adController.endHTML;
				adDiv.innerHTML = html;
				adDiv.style.visibility = 'visible';
			}
		}
	}
}