/*
Version 0004 is the same as version 0001 that was in production with the
only change being the path to the images. The path was changed to accompany
the color changes for the site rebranding in August, 2007.

I am not sure what 0002 and 0003 are/were. They were not in use on production 
at the time of the rebranding.

JCG
*/

/********************************************
*   Search Legend                              
*   ---------------------------------------    
*   Original File               Search Tag     
*   ---------------------------------------    
*   Object.js                   fs001a         
*   Cookies.js                  fs002a         
*   XMLLoader.js                fs003a         
*   Video.js                    fs004a         
*   VideoPlaylist.js            fs005a         
*   VideoCache.js               fs006a         
*   VideoPlayer.js              fs007a         
*   VideoControls.js            fs008a         
*   VideoAdController.js        fs009a         
*   VideoTracker.js             fs010a         
********************************************/

/**************************************************************************************** ( fs001a )
*
*                          Original File: Object.js
*
****************************************************************************************/
_objects = new Array();

_currentObjectId = Math.floor(Math.random() * 1000) + 1000;
CBSObject.prototype.defaultLogLevel = "";
CBSObject.prototype.logBuffer = "";
CBSObject.prototype.logWin = null;

//---------------------------------------------------------------
// Create an object
function CBSObject()
{
	this.objectType = "Object";
  this.objectId = _currentObjectId;
  _currentObjectId = _currentObjectId + 1;
  _objects[this.objectId] = this;
	this.logLevel = this.defaultLogLevel;

  this._events = new Array();
}

//---------------------------------------------------------------
// Attached code to an event of an object
CBSObject.prototype.log = function(level, message) {
	//if (level == "error")
	//	alert(message);
	if ((this.logLevel == "all") || (this.logLevel.indexOf(level) != -1)) {
		var logDiv = document.getElementById("logDiv");
		if (logDiv) {
			if (this.logBuffer) {
				logDiv.innerHTML += this.logBuffer;
				this.logBuffer = null;
			}
			logDiv.innerHTML += this.objectType + this.objectId + ": " + level + ": " + message + "<br>";
		} else if (this.logWin) {
			this.logWin.log(this.objectType + this.objectId + ": " + level + ": " + message);
		} else {
			this.logBuffer += this.objectType + this.objectId + ": " + level + ": " + message + "<br>";
		}
	}
}


//---------------------------------------------------------------
// Attached code to an event of an object
CBSObject.prototype.attachEvent = function(e, c, o) {
  if (this._events[e] == null)
    this._events[e] = new Array();
	var callback = new Object();
	callback.event = e;
	callback.callback = c;
	callback.object = o;
  this._events[e][this._events[e].length] = callback;
}

//---------------------------------------------------------------
// Detach code to an event of an object
CBSObject.prototype.detachEvent = function(e, c, o) {
  if (this._events[e] != null) {
		for (var i=0; i<this._events[e].length; i++) {
			var callback = this._events[e][i];
			if ((callback.callback == c) && (callback.object == 0)) {
				this._events[e].splice(i, 1);
				return;
			}
		}
	}
}

//---------------------------------------------------------------
// Attached code to an event of an object
CBSObject.prototype.hasEvent = function(e) {
	return ((this._events[e]) && (this._events[e].length > 0));
}

//---------------------------------------------------------------
// Fire all code attached to the given event
CBSObject.prototype._fireEvent = function(e) {
  this.log("event", e);
	var result = false;
  if (this._events[e] != null) {
    for (var i=0; i<this._events[e].length; i++) {
			var callback = this._events[e][i];
      switch (typeof(callback.callback)) {
        case 'function':
					if (callback.object) {
	          if (callback.callback.apply(callback.object, arguments))
							result = true;
					} else {
	          if (callback.callback.apply(this, arguments))
							result = true;
					}
          break;
					
        case 'string':
          if (eval(this._events[e][i]))
						result = true;
          break;
					
        default:
          break;
      }
    }
  }
	return result;
}


/*****************************************************\
 * Global functions
\*****************************************************/

//-----------------------------------------------------
// Return the real position of an element
function openLogWin() {
	CBSObject.prototype.logWin = window.open("/common/vplayer2/log.html", "logWin");
}
function setGlobalLogLevel(level) {
	for (object in _objects) {
		object.logLevel = level;
	}
}

//-----------------------------------------------------
// Return the real position of an element
function getElementPosition(element, pos)
{
  if (pos == null) {
    pos = new Object();
    pos.x = pos.y = 0;
  }
  pos.x += element.offsetLeft;
  pos.y += element.offsetTop;
  if (element.offsetParent == null) {
    return pos;
  }
  return getElementPosition(element.offsetParent, pos);
}

function getScrollPositions(pos)
{
  if (pos == null) {
    pos = new Object();
    pos.x = pos.y = 0;
  }
	if (navigator.appName == "Microsoft Internet Explorer") {
		pos.x = document.body.scrollLeft;
		pos.y = document.body.scrollTop;
	} else {
		pos.x = window.pageXOffset;
		pos.y = window.pageYOffset;
	}
	return pos;
}
function setScrollPositions(x, y)
{
	if (typeof(x) == "object") {
		y = x.y;
		x = x.x;
	}
	if (navigator.appName == "Microsoft Internet Explorer") {
		document.body.scrollTop = x;
		document.body.scrollLeft = y;
	} else {
		window.scrollTo(x, y);
	}
}


/**************************************************************************************** ( fs002a )
*
*                          Original File: Cookies.js
*
****************************************************************************************/
var _cookies = null;

//-------------------------------------------------------------
// Load all cookies into _cookies array
function getCookies() {
	if (_cookies == null) {
		var _cookies = new Array();
		var args = document.cookie.split('; ');
		for (var i=0; i<args.length; i++) {
			var arg = args[i].split('=');
			_cookies[arg[0]] = unescape(arg[1]);
		}
	}
	return _cookies;
}
//-------------------------------------------------------------
// Get a value of a cookie
function getCookie(name) {
	var cookies = this.getCookies();
	return cookies[name];
}
//-------------------------------------------------------------
// Save a cookie
function setCookie(name, value, expires, path, domain, secure) {
	if (domain == 1) {
		domain = document.location.hostname;
	} else if (domain == 2) {
		var matches = document.location.hostname.match(/(\.\w+\.\w+)$/);
		if (matches)
			domain = matches[1];
	}
	document.cookie = name + "=" + escape (value) +
		((expires) ? "; expires=" + expires : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
}
//-------------------------------------------------------------
// Delete a cookie
function deleteCookie(name, path, domain) {
	if (domain == 1) {
		domain = document.location.hostname;
	} else if (domain == 2) {
		var matches = document.location.hostname.match(/(\.\w+\.\w+)$/);
		if (matches)
			domain = matches[1];
	}
	if (getCookie(name)) {
		document.cookie = name + "=" +
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}


/**************************************************************************************** ( fs003a )
*
*                          Original File: XMLLoader.js
*
****************************************************************************************/

//------------------------------------------------------
// The XML Loader Object
XMLLoader.prototype = new CBSObject();
XMLLoader.prototype.constructor = XMLLoader;
function XMLLoader() {
  this.superClass = CBSObject.prototype;
  this.superClass.constructor.call(this);
	this.objectType = "XMLLoader";
	_objects[this.objectId] = this;

	if (window.XMLHttpRequest) {
		this.load = this.mozLoad;
	} else {
		this.load = this.ieLoad;
	}
	
	this.requests = new Array();
	this.functions = new Array();
	this.objects = new Array();
	this.currentRequestId = 0;
}

//------------------------------------------------------
// Load for mozilla based browsers
XMLLoader.prototype.mozLoad = function(url, func, object) {
	var request = new XMLHttpRequest();
	this.requests[this.currentRequestId] = request;
	this.functions[this.currentRequestId] = func;
	this.objects[this.currentRequestId] = object;
	eval("request.onreadystatechange = function() { _objects['" + this.objectId + "'].onReadyStateChange(" + this.currentRequestId + "); } ");
	this.currentRequestId++;
	request.open("GET", url, true);
	request.send(null);
	return true;
}

//------------------------------------------------------
// Load for IE
XMLLoader.prototype.ieLoad = function(url, func, object) {
	var request = new ActiveXObject("Microsoft.XMLHTTP")
	if (!request)
		return false;
		
	this.requests[this.currentRequestId] = request;
	this.functions[this.currentRequestId] = func;
	this.objects[this.currentRequestId] = object;
	eval("request.onreadystatechange = function() { _objects['" + this.objectId + "'].onReadyStateChange(" + this.currentRequestId + "); } ");
	this.currentRequestId++;
	request.open("GET", url, true);
	request.send();
}

//------------------------------------------------------
// On ready state change
XMLLoader.prototype.onReadyStateChange = function(requestId) {
	var request = this.requests[requestId];
	if (!request) {
		this.log("error", "No request fround for requestId " + requestId);
		return;
	}
	if (request.readyState == 4) {
		if (this.objects[requestId]) {
			this.functions[requestId].call(this.objects[requestId], request);
		} else {
			this.functions[requestId].call(null, request);
		}
	}
}

//------------------------------------------------------
// Utils functons
XMLLoader.prototype.getElementText = function(element) {
	if (element.text) 
		return element.text;
	var text = "";
	for (var i=0; i<element.childNodes.length; i++) {
		text += element.childNodes[i].data;
		if (element.childNodes[i].length > 0) {
			text += this.getElementText(element.childNodes[i]);
		}
	}
	return text;
}
XMLLoader.prototype.getElementByTagName = function(element, tagname) {
	var elements = element.getElementsByTagName(tagname);
	if (elements) {
		return elements[0];
	}
	return null;
}
XMLLoader.prototype.getElementsByTagName = function(element, tagname) {
	return element.getElementsByTagName(tagname);
}
XMLLoader.prototype.getElementTextByTagName = function(element, tagname) {
	var element = this.getElementByTagName(element, tagname);
	if (element != null) {
		return this.getElementText(element);
	}
	return null;
}
XMLLoader.prototype.getAttributeValue = function(element, attribute) {
	var node = element.getAttributeNode("rank");
	if (node) {
		return node.value;
	}
	return null;
}


/**************************************************************************************** ( fs004a )
*
*                          Original File: Video.js
*
****************************************************************************************/
//------------------------------------------------------
// The Video Object
Video.prototype = new CBSObject();
Video.prototype.constructor = Video;
Video.prototype.numbers = "1234567890";
Video.prototype.xmlLoader = new XMLLoader();
function Video(videoPlayer, videoId, format, videoUrl, imageUrl, title, subtitle, caption, prop1, prop2) {
  this.superClass = CBSObject.prototype;
  this.superClass.constructor.call(this);
	this.objectType = "Video";
	_objects[this.objectId] = this;

	this.videoPlayer = videoPlayer;
	
	this.videoId = videoId;
	this.format = format;

	if (videoUrl) this.videoUrl = videoUrl;
	else if (videoPlayer) videoUrl = videoPlayer.videoRoot + videoId;
	if (imageUrl) this.imageUrl = imageUrl;
	else if (videoPlayer) imageUrl = videoPlayer.videoImageRoot + videoId;
	
	this.title = title;
	this.subtitle = subtitle;
	this.caption = caption;
	this.prop1 = prop1;
	this.prop2 = prop2;
	this.props = new Array();
	if (prop1) this.props[0] = prop1;
	if (prop2) this.props[1] = prop2;
	this.position = 0;
	this.maxPosition = 0;
	this.duration = 0;
	
	this.adSegment = null;
	this.segments = new Array();
	this.currentSegment = null;
	
	if ((this.videoId) && (!this.title) && (this.videoPlayer)) {
		this.loaded = false;
		this.log("video", "xmlLoad");
		this.xmlLoader.load(this.videoPlayer.playerRoot + this.videoPlayer.dynamicDir + "xml?id=" + this.videoId, this.onLoaded, this);
        //this.xmlLoader.load("http://www.cbsnews.com/common/vplayer3/php/xml.php?id=" + this.videoId, this.onLoaded, this);
	} else if (this.title) {
		this.loaded = true;
	}
}

//------------------------------------------------------
// Are these videos the same?
Video.prototype.equals = function(param1, param2, param3) {
	var videoId = null;
	var videoUrl = null;
	if (param1 == null) {
		return false;
	} else if (typeof(param1) == "object") {
		if (param1.videoId) {
			videoId = param1.videoId;
		} else {
			videoUrl = param1.videoUrl;
		}
	} else if (this.numbers.indexOf(param1.substring(0, 1)) == -1) {
		videoUrl = param1;
	} else {
		videoId = param1;
	}
	if (videoId != null) {
		return (this.videoId == videoId);
	} else {
		return (this.videoUrl == videoUrl);
	}
}

//------------------------------------------------------
// Clear a video for re-use
Video.prototype.clear = function() {
	this.removeAllSegments();
	this.startTracked = false;
	this.endTracked = false;
	this.startingTime = 0;
	this.startingSegment = 0;
}

//------------------------------------------------------
// Called when the video is loaded from XML
Video.prototype.onLoaded = function(request) {
	if (request.status == 200) {
		this.log("video", "onLoaded");
		var video = this.xmlLoader.getElementByTagName(request.responseXML, "video");
		if (video) {
			this.log("video", "onLoaded " + this.xmlLoader.getElementTextByTagName(video, "id"));
			if (this.videoId == this.xmlLoader.getElementTextByTagName(video, "id")) {
				this.title = this.xmlLoader.getElementTextByTagName(video, "title");
				this.subtitle = this.xmlLoader.getElementTextByTagName(video, "subtitle");
				this.caption = this.xmlLoader.getElementTextByTagName(video, "caption");
				this.duration = this.xmlLoader.getElementTextByTagName(video, "duration");
				this.sectionId = this.xmlLoader.getElementTextByTagName(video, "sectionId");
				this.sectionName = this.xmlLoader.getElementTextByTagName(video, "sectionName");
				this.watchTracking = this.xmlLoader.getElementTextByTagName(video, "watchTracking");
				this.numSegments = this.xmlLoader.getElementTextByTagName(video, "numSegments");
				var properties = video.getElementsByTagName("property");
				if (properties) {
					for (var i=0; i<properties.length; i++) {
						var rank = this.xmlLoader.getAttributeValue(properties[i], "rank");
						if (rank) {
							this["prop" + rank] = this.xmlLoader.getElementText(properties[i]);
							this.props[rank-1] = this.xmlLoader.getElementText(properties[i]);
						}
					}
				}
				this.loaded = true;
				this._fireEvent("onLoaded", this);
				if (this.videoPlayer) {
					this.videoPlayer.onVideoLoaded(this);
				}
			}
		}
	} else {
		//alert(request.statusText);
	}
}

//------------------------------------------------------
// URL to the video
Video.prototype.getVideoUrl = function() {
	if (!this.videoPlayer) {
		return this.videoUrl;
	} if (this.videoId) {
		return this.videoPlayer.getVideoUrl(this.videoId);
	} else {
		return this.videoPlayer.getVideoUrl(this.videoUrl);
	}
}
//------------------------------------------------------
// URL to the image
Video.prototype.getImageUrl = function() {
	if (!this.videoPlayer) {
		return this.imageUrl;
	} if (this.videoId) {
		return this.videoPlayer.getImageUrl(this.videoId);
	} else {
		return this.videoPlayer.getImageUrl(this.imageUrl);
	}
}

//------------------------------------------------------
// Get position
Video.prototype.getPosition = function() {
	var pos = 0;
	for (var i=0; i<this.segments.length; i++) {
		if (!this.segments[i].ad) {
			pos += parseInt(this.segments[i].position);
		}
	}
	return pos;
}
//------------------------------------------------------
// Get position
Video.prototype.getMaxPosition = function() {
	var pos = 0;
	for (var i=0; i<this.segments.length; i++) {
		if (!this.segments[i].ad) {
			pos += parseInt(this.segments[i].maxPosition);
		}
	}
	return pos;
}


//------------------------------------------------------
// Add a segment
Video.prototype.newSegment = function() {
	// Ad segment used for special non-script tracking
	if (this.adSegment) {
		var segment = this.adSegment;
		this.adSegment = null;
		this.log("status", "newSegment adSegment " + this.segments.length);
		this.currentSegment = segment;
		return segment;
	} else {
		var segment = new Segment(this);
		this.segments[this.segments.length] = segment;
		this.log("status", "newSegment " + this.segments.length);
		this.currentSegment = segment;
		return segment;
	}
}
Video.prototype.addSegment = function(segment) {
	this.segments[this.segments.length] = segment;
	this.log("status", "addSegment " + this.segments.length);
}
Video.prototype.removeAllSegments = function() {
	this.adSegment = null;
	this.segments.length = 0;
	this.currentSegment = null;
}
Video.prototype.getCurrentSegment = function() {
	this.log("status", "getCurrentSegment " + this.currentSegment);
	return this.currentSegment;
}
Video.prototype.getCurrentSegmentNum = function() {
	this.log("status", "getCurrentSegmentNum");
	for (var i=0; i<this.segments.length; i++) {
		if (this.segments[i] == this.currentSegment) {
			return i;
		}
	}
	return null;
}
Video.prototype.getCurrentContentSegmentNum = function() {
	this.log("status", "getCurrentContentSegmentNum");
	var j = 0;
	for (var i=0; i<this.segments.length; i++) {
		if (this.segments[i] == this.currentSegment) {
			return j + this.startingSegment;
		}
		if (!this.segments[i].ad) j++;
	}
	return j;
}
Video.prototype.getContentSegment = function() {
	for (var i=0; i<this.segments.length; i++) {
		if (!this.segments[i].ad) {
			return this.segments[i];
		}
	}
	return null;
}
Video.prototype.getNumSegments = function() {
	this.log("status", "getNumSegments " + this.segments.length);
	return this.segments.length;
}
Video.prototype.getNumContentSegments = function() {
	this.log("status", "getNumContentSegments " + this.numSegments);
	return this.numSegments;
}




//------------------------------------------------------
// The Segment Object
Segment.prototype = new CBSObject();
Segment.prototype.constructor = Segment;
function Segment(video) {
	this.adSegment = false;
	this.video = this;
	this.position = 0;
	this.maxPosition = 0;
	this.duration = 0;
	this.video = video;
}
//------------------------------------------------------
// Get position
Video.prototype.getPosition = function() {
	return this.position;
}
//------------------------------------------------------
// Get position
Segment.prototype.getMaxPosition = function() {
	return this.maxPosition;
}

/**************************************************************************************** ( fs005a )
*
*                          Original File: VideoPlaylist.js
*
****************************************************************************************/
//------------------------------------------------------
// The Video Playlist Object
VideoPlaylist.prototype = new CBSObject();
VideoPlaylist.prototype.constructor = VideoPlaylist;
VideoPlaylist.prototype.numbers = "1234567890";
function VideoPlaylist(videoPlayer) {
  this.superClass = CBSObject.prototype;
  this.superClass.constructor.call(this);
	this.objectType = "VideoPlaylist";
	_objects[this.objectId] = this;

	this.videoPlayer = videoPlayer;
	
	this.videos = new Array();
	this.pos = -1;
	
	this.allowDuplicates = false;
	this.removeWatched = true;
}


//------------------------------------------------------
// Get the location of a video in the list
VideoPlaylist.prototype.findVideo = function(param1, param2, param3) {
	this.log("playlist", "findVideo " + param1);
	var videoId = null;
	var videoUrl = null;
	if (param1 == null) {
		return -1;
	} else if (typeof(param1) == "object") {
		if (param1.videoId) {
			videoId = param1.videoId;
		} else {
			videoUrl = param1.videoUrl;
		}
	} else if (this.numbers.indexOf(param1.substring(0, 1)) == -1) {
		videoUrl = param1;
	} else {
		videoId = param1;
	}
	if (videoId != null) {
		for (var i=0; i<this.videos.length; i++) {
			if (videoId == this.videos[i].videoId) {
				return i;
			}
		}
	} else {
		for (var i=0; i<this.videos.length; i++) {
			if (videoUrl == this.videos[i].videoUrl) {
				return i;
			}
		}
	}
	return -1;
}


//------------------------------------------------------
// Check load status of videos
VideoPlaylist.prototype.areAllVideosLoaded = function() {
	for (var i=0; i<this.videos.length; i++) {
		if (!this.videos[i].loaded) {
			return false;
		}
	}
	return true;
}

/********************************************************************\
 * Inserting and removing
\********************************************************************/
//------------------------------------------------------
// Add a video to the end of the list
VideoPlaylist.prototype.addVideo = function(param1, param2, param3) {
	this.log("playlist", "addVideo " + param1);
	var video;
	if (!this.allowDuplicates) {
		var oldPos = this.findVideo(param1, param2, param3);
		if (oldPos != -1) {
			if (oldPos >= this.pos) {
				return false;
			}
			var videoArray = this.videos.splice(oldPos, 1);
			video = videoArray[0];
			this.pos = this.pos - 1;
		} else {
			video = this.videoPlayer.getVideo(param1, param2, param3);
		}
	} else {
		video = this.videoPlayer.getVideo(param1, param2, param3);
	}
    video.title = param3;
	this.videos[this.videos.length] = video;
	this.videoPlayer._fireEvent("onPlaylistChanged");
	return true;
}
//------------------------------------------------------
// Insert a video into the list at the given position
VideoPlaylist.prototype.insertVideo = function(pos, param1, param2, param3) {
	this.log("playlist", "insertVideo " + pos + " " + param1);
	if (pos < 0) this.pos = 0;
	if (pos > this.videos.length) pos = this.videos.length;
	if ((this.videos[pos]) && (this.videos[pos].equals(param1, param2, param3)))
		return false;
	var video = null;
	if (!this.allowDuplicates) {
		video = this.removeVideo(param1, param2, param3);
		if (video == null) {
			video = this.videoPlayer.getVideo(param1, param2, param3);
		}
	} else {
		video = this.videoPlayer.getVideo(param1, param2, param3);
	}
    video.title = param3;
	this.videos.splice(pos, 0, video);
	this.videoPlayer._fireEvent("onPlaylistChanged");
	return true;
}
//------------------------------------------------------
// Skips to the given video in the list
VideoPlaylist.prototype.skipToVideo = function(param1, param2, param3) {
	var pos = this.findVideo(param1, param2, param3);
	if (pos >= 0) {
		this.pos = pos;
	}
}

//------------------------------------------------------
// Insert a video into the list at the current position
VideoPlaylist.prototype.placeVideo = function(param1, param2, param3) {
	this.log("placeVideo " + this.pos);
	if (this.pos < 0) this.pos = 0;
	if (this.pos > this.videos.length) this.pos = this.videos.length;
	//if ((this.videos[this.pos]) && (this.videos[this.pos].equals(param1, param2, param3)))
	//	return false;
	if (this.videoPlayer.isStopped()) {
		return this.insertVideo(this.pos, param1, param2, param3);
	} else {
		return this.setVideo(this.pos, param1, param2, param3);
	}
}
//------------------------------------------------------
// Set the given position in the list to the given video
VideoPlaylist.prototype.setVideo = function(pos, param1, param2, param3) {
	this.log("playlist", "setVideo " + pos + " " + param1);
	if ((this.videos[pos]) && (this.videos[pos].equals(param1, param2, param3)))
		return false;
	var video;
	if (!this.allowDuplicates) {
		var oldPos = this.findVideo(param1, param2, param3);
		if (oldPos != -1) {
			var videoArray = this.videos.splice(oldPos, 1);
			video = videoArray[0];
			if (oldPos < pos) {
				pos = pos - 1;
			}
			if (oldPos < this.pos) {
				this.pos = this.pos - 1;
			}
		} else {
			video = this.videoPlayer.getVideo(param1, param2, param3);
		}
	} else {
		video = this.videoPlayer.getVideo(param1, param2, param3);
	}
    video.title = param3;
	this.videos[pos] = video;
	this.videoPlayer._fireEvent("onPlaylistChanged");
	return true;
}
//------------------------------------------------------
// Remove a video from the list
VideoPlaylist.prototype.removeVideo = function(param1, param2, param3) {
	this.log("playlist", "removeVideo " + param1);
	var oldPos = this.findVideo(param1, param2, param3);
	if (oldPos == -1) {
		return null;
	}
	if (oldPos < this.pos) {
		this.pos = this.pos - 1;
	}
	var videoArray = this.videos.splice(oldPos, 1);
	this.videoPlayer._fireEvent("onPlaylistChanged");
	return videoArray[0];
}
//------------------------------------------------------
// Remove a video from the list
VideoPlaylist.prototype.removeAllVideos = function() {
	this.videos.length = 0;
	this.pos = 0;
	this.videoPlayer._fireEvent("onPlaylistChanged");
}

//------------------------------------------------------
// Is this video in the playlist
VideoPlaylist.prototype.containsVideo = function(param1, param2, param3) {
	var pos = this.findVideo(param1, param2, param3);
	if (pos == -1)
		return false;
	return true;
}


/********************************************************************\
 * Moving
\********************************************************************/
VideoPlaylist.prototype.moveDown = function(pos) {
	var paused = this.videoPlayer.isPaused();
	if (pos >= this.videos.length-1) {
		return;
	}

	this.videos.splice(pos, 2, this.videos[pos+1], this.videos[pos]);
	if (pos == 0) {
		this.videoPlayer.setCurrentVideo(this.videos[0]);
		if (!this.videoPlayer.isStopped()) {
			this.videoPlayer.play(this.videos[0]);
			if (paused) {
				window.setTimeout("_objects[" + this.videoPlayer.objectId + "].pause()", 1000);
			}
		}
	}
	this.videoPlayer._fireEvent("onPlaylistChanged");
}
VideoPlaylist.prototype.moveUp = function(pos) {
	var paused = this.videoPlayer.isPaused();
	if (pos == 0) {
		return;
	}

	this.videos.splice(pos-1, 2, this.videos[pos], this.videos[pos-1]);
	if (pos == 1) {
		this.videoPlayer.setCurrentVideo(this.videos[0]);
		if (!this.videoPlayer.isStopped()) {
			this.videoPlayer.play(this.videos[0]);
			if (paused) {
				window.setTimeout("_objects[" + this.videoPlayer.objectId + "].pause()", 1000);
			}
		}
	}
	this.videoPlayer._fireEvent("onPlaylistChanged");  
}

/********************************************************************\
 * Access
\********************************************************************/
//---------------------------------------------------------
// Get current position
VideoPlaylist.prototype.getCurrentPosition = function() {
	if (this.pos < 0)
		return 0;
	return this.pos;
}
//---------------------------------------------------------
// Get length
VideoPlaylist.prototype.getLength = function() {
	return this.videos.length;
}
//---------------------------------------------------------
// Get a video at position
VideoPlaylist.prototype.getVideo = function(pos) {
	return this.videos[pos];
}


/********************************************************************\
 * Location in list
\********************************************************************/
//---------------------------------------------------------
// Get the current video	
VideoPlaylist.prototype.getCurrentVideo = function() {
	return this.videos[this.pos];
}
//---------------------------------------------------------
// Get the previous video	
VideoPlaylist.prototype.getPreviousVideo = function() {
	return this.videos[this.pos-1];
}
//---------------------------------------------------------
// Get the next  video	
VideoPlaylist.prototype.getNextVideo = function() {
	return this.videos[this.pos+1];
}
//---------------------------------------------------------
// Backup to previous video and return it
VideoPlaylist.prototype.previousVideo = function() {
	if (this.pos == 0)
		return null;
	this.pos = this.pos - 1;
	this.videoPlayer._fireEvent("onPlaylistPositionChanged");
	return this.videos[this.pos];
}
//---------------------------------------------------------
// Advance to next video and return it
VideoPlaylist.prototype.nextVideo = function() {
	if ((this.pos == this.videos.length) || (this.videos.length <= 1))
		return null;
	if (this.removeWatched) {
		this.videos.shift();
	} else {
		this.pos = this.pos + 1;
	}
	this.videoPlayer._fireEvent("onPlaylistPositionChanged");
	return this.videos[this.pos];
}
//---------------------------------------------------------
// Set the position in the list and return video in that position
VideoPlaylist.prototype.setPosition = function(pos) {
	if (pos >= this.videos.length-1)
		this.pos = this.videos.length-1;
	else if (pos <= 0)
		this.pos = 0;
	else
		this.pos = pos;
	this.videoPlayer._fireEvent("onPlaylistPositionChanged");
	return this.videos[this.pos];
}


/**************************************************************************************** ( fs006a )
*
*                          Original File: VideoCache.js
*
****************************************************************************************/
//------------------------------------------------------
// The Video Cache Object
VideoCache.prototype = new CBSObject();
VideoCache.prototype.constructor = VideoCache;
VideoCache.prototype.numbers = "1234567890";
function VideoCache(videoPlayer) {
  this.superClass = CBSObject.prototype;
  this.superClass.constructor.call(this);
	this.objectType = "VideoCache";
	_objects[this.objectId] = this;

	this.videoPlayer = videoPlayer;
	
	this.videos = new Array();
}


//------------------------------------------------------
// Get the video object from all possible param choices
VideoCache.prototype.createVideo = function(param1, param2, param3) {
	if (typeof(param1) == "object") {
		// Clone the video so object is local
		var video = new Video(this.videoPlayer);
		for (var prop in param1) {
			video[prop] = param1[prop];
		}
		return video;
	} else if (this.numbers.indexOf(param1.substring(0, 1)) == -1) {
		return new Video(this.videoPlayer, null, param3, param1, param2);
	} else {
		return new Video(this.videoPlayer, param1, param2);
	}
}

//------------------------------------------------------
// Get a video from the cache (or create it if not in cache)
VideoCache.prototype.getVideo = function(param1, param2, param3) {
	this.log("cache", "getVideo " + param1);
	var key = null;
	var format = null;
	if (param1 == null) {
		return -1;
	} else if (typeof(param1) == "object") {
		if (param1.videoId) {
			key = param1.videoId;
		} else {
			key = param1.videoUrl;
		}
	} else if (this.numbers.indexOf(param1.substring(0, 1)) == -1) {
		key = param1;
		format = param3;
	} else {
		key = param1;
		format = param2;
	}
	var video = this.videos[key];
	if (!video) {
		video = this.createVideo(param1, param2, param3);
		this.videos[key] = video;
	} else if (format) {
		video.format = format;
	}
	return video;
}
//------------------------------------------------------
// Add a video to the cache
VideoCache.prototype.addVideo = function(param1, param2, param3) {
	this.log("cache", "addVideo " + param1);
	return this.getVideo(param1, param2, param3);
}


/**************************************************************************************** ( fs007a )
*
*                          Original File: VideoPlayer.js
*
****************************************************************************************/
//------------------------------------------------------
// The VideoPlayer class
VideoPlayer.prototype = new CBSObject();
VideoPlayer.prototype.constructor = VideoPlayer;
VideoPlayer.prototype.numbers = "1234567890";
function VideoPlayer(playerRoot, display, width, height) {
  this.superClass = CBSObject.prototype;
  this.superClass.constructor.call(this);
	this.objectType = "VideoPlayer";
	_objects[this.objectId] = this;

	this.format = null;
	this.defaultFormat = null;
	this.possibleFormats = "";
	this.installedFormats = "";
	this.supportedFormats = "";

	if (width) this.width = width;
	else this.width = 320;
	if (height) this.height = height;
	else this.height = 240;
	if (display) this.display = display;
	else this.display = "";
		
	if (playerRoot) this.playerRoot = playerRoot;
	else this.playerRoot = "/video/vplayer3/";
	this.staticDir = ""; // "/html";
	this.dynamicDir = ""; // "/php";
	this.videoRoot = "http://video.cgi.cbsnews.com/vplayer3/play.pl";
	this.videoImageRoot = "http://video.cgi.cbsnews.com/vplayer3/image.pl";
	this.imageRoot = "http://images.sportsline.com/images/cbss/ui/vplayer3";
	this.videoUrl = null;
	this.videoImageUrl = null;
	
	this.defaultImage = null;
	
	this.redraw = false;
	
	this.params = new Array();
	this.params["feat"] = "vplayer";
	this.params["adtype"] = "pre";
	
	this.currentVideo = null;
	this.cache = new VideoCache(this);
	this.playlist = new VideoPlaylist(this);
	this.defaultPlaylist = new VideoPlaylist(this);
	this.skipToVideo = false;
	
	this.volume = 100;
	this.state = "stop";
	this.playState = "none";
	
	this.capabilities = null;
	
	this.siteName = 'CBSSports.com';
	this.bgcolor = "#003366";
	
	this.iFrame = null;
}


//--------------------------------------------------------
// Calls a command in the frame by getting button in frame and calling onclick
VideoPlayer.prototype._executeFrameCommand = function(command) {
	this.log("command", "_executeFrameCommand " + command);
	var iFrame = this.getIFrameDocument();
	if (iFrame == null) return false;
	var m = "_executeFrameCommand(" + command;
	if (!iFrame.forms.controlForm) return false;
	for (var i=1; i<arguments.length; i++) {
		var param = iFrame.forms.controlForm["param" + i];
		if (param) param.value = arguments[i];
		m += ", " + arguments[i];
	}
	this.log("command", m + ")");
	var playCommand = iFrame.forms.controlForm[command + 'Command'];
	if (playCommand) {
		this.log("command", "onclick");
		playCommand.onclick();
		return true;
	} else {
		return false;
	}
}



//--------------------------------------------------------
// Returns the play state
VideoPlayer.prototype.getPlayState = function() {
	return this.playState;
}
// Is a video playing?
VideoPlayer.prototype.isPlaying = function() {
	//if (this.state == "play") return true;
	return (this.playState == "playing");
}
// Is a video playing?
VideoPlayer.prototype.isStopped = function() {
	this.log("stopped", "isStopped " + this.state + " " + this.playState);
	if (this.state == "stop") return true;
	return ((this.playState == "none") || (this.playState == "stopped") || (this.playState == "ended"));
}
// Is a video paused?
VideoPlayer.prototype.isPaused = function() {
	this.log("status", "isPaused " + this.playState);
	if (this.state == "pause") return true;
	return (this.playState == "paused");
}
// Is a video buffering?
VideoPlayer.prototype.isBuffering = function() {
	this.log("status", "isBuffering " + this.playState);
	return (this.playState == "buffering");
}


//--------------------------------------------------------
// Ask user to choose format
VideoPlayer.prototype.chooseFormat = function(showImage, playVideo) {
	this.log("format", "chooseFormat " + showImage + " " + playVideo);
	this.stop();
	this.format = null;
	if (!showImage) showImage = "";
	if (!playVideo) playVideo = "";
	var iFrame = this.getIFrameDocument();
	iFrame.src = this.playerRoot + this.staticDir + "choose_iframe?id=" + this.objectId + "&showImage=" + showImage + "&playVideo=" + playVideo;
	iFrame.location.href = this.playerRoot + this.staticDir + "choose_iframe?id=" + this.objectId + "&showImage=" + showImage + "&playVideo=" + playVideo;
}
//--------------------------------------------------------
// Ask user to choose format
VideoPlayer.prototype.uninstalledFormat = function(showImage, playVideo) {
	this.log("format", "uninstalledFormat " + showImage + " " + playVideo);
	this.stop();
	this.format = null;
	if (!showImage) showImage = "";
	if (!playVideo) playVideo = "";
	var iFrame = this.getIFrameDocument();
	iFrame.src = this.playerRoot + this.staticDir + "uninstalled_iframe?id=" + this.objectId + "&showImage=" + showImage + "&playVideo=" + playVideo;
	iFrame.location.href = this.playerRoot + this.staticDir + "uninstalled_iframe?id=" + this.objectId + "&showImage=" + showImage + "&playVideo=" + playVideo;
}
//--------------------------------------------------------
// Ask user to choose format
VideoPlayer.prototype.unsupportedFormat = function(showImage, playVideo) {
	this.log("format", "unsupportedFormat " + showImage + " " + playVideo);
	this.stop();
	this.format = null;
	if (!showImage) showImage = "";
	if (!playVideo) playVideo = "";
	var iFrame = this.getIFrameDocument();
	iFrame.src = this.playerRoot + this.staticDir + "unsupported_iframe?id=" + this.objectId + "&showImage=" + showImage + "&playVideo=" + playVideo;
	iFrame.location.href = this.playerRoot + this.staticDir + "unsupported_iframe?id=" + this.objectId + "&showImage=" + showImage + "&playVideo=" + playVideo;
}

//--------------------------------------------------------
// Format for playing videos
VideoPlayer.prototype.setFormat = function(format, play) {
	this.log("format", "set Format " + format + " " + play);
	this.videoUrl = null;
	this.format = format;
	if ((!play) || ((!this.hasEvent("beforePlay")) || (this._fireEvent("beforePlay")))) {
		var iFrame = this.getIFrameDocument();
		if (iFrame) {
			var url = this.playerRoot + this.staticDir + format + "_iframe?id=" + this.objectId + "&ord=" + Math.random() * 100000;
			if (play) {
				url += "&play=1";
				this.state = "play";
			}
			iFrame.src = url;
			iFrame.location.href = url;
			this.log("format", "setFormat " + url);
		}
	}
	this._fireEvent("onFormatChanged", format);
}
VideoPlayer.prototype.getFormat = function() {
	return this.format;
}

//--------------------------------------------------------
// Default format
VideoPlayer.prototype.setDefaultFormat = function(format) {
	this.log("format", "set DefaultFormat " + format);
	setCookie("vp_format", format, "Fri, 01-Jan-2010 00:00:01 GMT", '/', 2);
	this.defaultFormat = format;
	this._fireEvent("onDefaultFormatChanged", format);
}
VideoPlayer.prototype.getDefaultFormat = function() {
	return this.defaultFormat;
}



//------------------------------------------------------
// Get the video object from all possible param choices
VideoPlayer.prototype.newVideo = function() {
	return new Video(this);
}

//------------------------------------------------------
// Get the video object from all possible param choices
VideoPlayer.prototype.getVideo = function(param1, param2, param3) {
	if (this.cache) {
		return this.cache.getVideo(param1, param2, param3);
	} else {
		if (typeof(param1) == "object") {
			return param1;
		} else if (this.numbers.indexOf(param1.substring(0, 1)) == -1) {
			return new Video(this.videoPlayer, null, param3, param1, param2);
		} else {
			return new Video(this.videoPlayer, param1, param2);
		}
	}
}

//--------------------------------------------------------
// Adds a param to the video url
VideoPlayer.prototype.setParam = function(name, value) {
	this.params[name] = value;
	this.videoUrl = null;
}
//--------------------------------------------------------
// Returns a param on the video url
VideoPlayer.prototype.getParam = function(name) {
	return this.params[name];
}

//--------------------------------------------------------
// Returns a video url 
VideoPlayer.prototype.getVideoUrl = function(param) {
    if (this.videoUrl == null) {
		this.videoUrl = this.videoRoot + ((this.videoRoot.indexOf('?') == -1) ? '?' : '&');
        
        if (this.videoRoot == "http://video.cgi.cbsnews.com/vplayer/spln_play.pl"){
            if (this.format == "rm"){ this.videoUrl += "type=ram"; }
            else{ this.videoUrl += "type=wmv"; }
        } else {
            this.videoUrl += "type=" + this.format;
        }
        
		this.videoUrl += "&width=" + this.width;
		this.videoUrl += "&height=" + this.height;
		for (var paramName in this.params) {
			this.videoUrl += "&" + paramName + "=" + this.params[paramName];
		}
		if (this.startSegment) {
			this.videoUrl += "&sgmt=" + this.startSegment;
			this.startSegment = null;
		}
		if (this.startTime) {
			this.videoUrl += "&time=" + this.startTime;
			this.startTime = null;
		}
	}
    
	if (this.numbers.indexOf(param.substring(0, 1)) == -1) {
		return this.videoUrl + "&url=" + escape(param) + "&ord=" + Math.random() * 100000;
	} else {
		return this.videoUrl + "&id=" + param + "&ord=" + Math.random() * 100000;;
	}
}
//--------------------------------------------------------
// Returns a video image url 
VideoPlayer.prototype.getImageUrl = function(param) {
    if (this.defaultImage != null){
        return this.defaultImage;
    }
    if (param == null) {
        this.defaultImage = "http://www.cbsnews.com/images/2006/08/28/image1939838.jpg";
	    return this.defaultImage;
    } else if (this.videoImageUrl == null) {
		this.videoImageUrl = this.videoImageRoot + ((this.videoImageRoot.indexOf('?') == -1) ? '?' : '&');
		this.videoImageUrl += "size=" + this.width + 'x' + this.height;
    }
    if (this.numbers.indexOf(param.substring(0, 1)) == -1) {
		return param;
	} else {
		return this.videoImageUrl + "&id=" + param;
	}
}


//--------------------------------------------------------
// Play Video Video
// Calls can be
// play()
// play(video)
// play(videoUrl, imageUrl, format)
// play(videoId, format)
VideoPlayer.prototype.play = function(param1, param2, param3, segment, time) {
	this.log("command", "play " + this.format + " " + param1);
	this.state = "play";

	if (segment) {
		this.startSegment = segment;
		this.videoUrl = null;
	}
	if (time) {
		this.startTime = time;
		this.videoUrl = null;
	}

	var video;
	if (param1 == null) {
		if (this.getCurrentVideo() == null) {
			this.log("command", "No current video");
			return;
		}
		if (this.isPaused()) {
			this.log("command", "paused");
			return this._executeFrameCommand("play");
		}
		video = this.getCurrentVideo();
	} else { 
		video = this.getVideo(param1, param2, param3);
	}
	this.log("command", "play " + video.videoId);
	this.log("format", "play " + video.format);
	
	// Set the current video
	video.clear();
	this.setCurrentVideo(video);

	// Does video exist in multiple formats?
	var playFormat;
	if (video.format.indexOf('|') >= 0) {
		if (this.format == null) {
			return this.chooseFormat(false, true);
		} else if (video.format.indexOf(this.defaultFormat) != -1) {
			playFormat = this.defaultFormat;
		} else if (video.format.indexOf(this.format) != -1) {
			playFormat = this.format;
		} else {
			return this.chooseFormat(false, true);
		}
	} else { 
		if (this.installedFormats.indexOf(video.format) >= 0) {
			playFormat = video.format;
		} else {
			return this.uninstalledFormat(false, true);
		}
	}
	this.log("format", "play " + playFormat + " " + this.format);

	video.playFormat = playFormat;
	this.playState = "loading";
	//this.onVideoOpened(video);
	
	if ((!this.hasEvent("beforePlay")) || (this._fireEvent("beforePlay"))) {
		if ((playFormat != this.format) || (this.redraw)) {
			this.redraw = false;
			this.setFormat(playFormat, true);
		} else {
			return this._executeFrameCommand("play", video.getVideoUrl(), video.getImageUrl());
		}
	}
}


//--------------------------------------------------------
// Stop 
VideoPlayer.prototype.stop = function() {
	this.log("command", "stop");
	this.state = "stop";
	// Clear the current video
	this.setCurrentVideo(null);
	return this._executeFrameCommand("stop");
}

//--------------------------------------------------------
// Pause
VideoPlayer.prototype.pause = function() {
	this.log("command", "pause");
	this.state = "pause";
	// Clear the current video
	return this._executeFrameCommand("pause");
}
//--------------------------------------------------------
// Rewind
VideoPlayer.prototype.rewind = function() {
	this.log("command", "rewind");
	var video = this.getCurrentVideo();
	if (!this.capabilities.scripting[this.format]) {
		this.stop();
		this.play(video);
	} else if ((this.isPlaying()) && (video) && (video.position > 2)) {
		return this._executeFrameCommand("restart");
	} else {
		if (this.playlist.getPreviousVideo()) {
			this.play(this.playlist.previousVideo());
		} else if (this.defaultPlaylist.getPreviousVideo()) {
			this.play(this.defaultPlaylist.previousVideo());
		} else {
			return this._executeFrameCommand("restart");
		}
	}
}
//--------------------------------------------------------
// Forward
VideoPlayer.prototype.forward = function() {
	this.log("command", "forward");
	var video = this.playlist.nextVideo();
	if (video) {
		return this.play(video);
	}
	video = this.defaultPlaylist.nextVideo();
	if (video) {
		return this.play(video);
	}
	return this.stop();
}

//--------------------------------------------------------
// Volume
VideoPlayer.prototype.setVolume = function(volume) {
	this.log("command", "setVolume");
	this.volume = volume;
	return this._executeFrameCommand("setVolume", volume);
	this._fireEvent("onVolumeChanged", volume);
}
VideoPlayer.prototype.getVolume = function() {
	return this.volume;
}


//--------------------------------------------------------
// Position
VideoPlayer.prototype.setPosition = function(position) {
	this.log("command", "setPosition " + position);
	if ((typeof(position) != "number") && (position.substring(position.length-1) == "%")) {
		var video = this.getCurrentVideo();
        var segment = video.getCurrentSegment();
		if ((video == null) || (!segment.duration)) return;
		var percent = position.substring(0, position.length-1);
		position = percent * segment.duration / 100;
	}
	return this._executeFrameCommand("setPosition", position);
	this._fireEvent("setPosition", position);
}
VideoPlayer.prototype.getPosition = function() {
	var video = this.getCurrentVideo();
	if (!video) return 0;
	if (video.segments.length == 0) return 0;
	var pos = video.segments[video.segments.length-1].position;
	if (!pos) return 0;
	return pos;
}



//--------------------------------------------------------
// Full screen
VideoPlayer.prototype.setFullscreen = function(fullscreen) {
    if (arguments.length == 0) fullscreen = true;
    return this._executeFrameCommand("fullscreen", fullscreen);
}


//---------------------------------------------------------------
// Callbacks
// Video opened
VideoPlayer.prototype.onVideoOpened = function(video) {
	this.log("videoCallback", "onVideoOpened ");
	video.state = "opened";
	this._fireEvent("onVideoOpened", video);

	// If loaded from XML, then already set
	if (video.loaded) {
		this.onVideoSet(video);
	}
}
// Video set
VideoPlayer.prototype.onVideoSet = function(video) {
	this.log("videoCallback", "onVideoSet ");
	video.state = "set";
	video.loaded = true;
	this._fireEvent("onVideoSet", video);

	if (!this.capabilities.scripting[this.format]) {
		this.onVideoStarted(video);
		var segment = video.newSegment();
		segment.format = "wmv";
		segment.title = video.title;
		segment.subtitle = video.subtitle;
		segment.caption = video.caption;
		segment.props = video.props;
		segment.loaded = true;
		this.onSegmentOpened(segment);
	}
}
// Video started
VideoPlayer.prototype.onVideoStarted = function(video) {
	this.log("videoCallback", "onVideoStarted ");
	video.state = "started";
	this._fireEvent("onVideoStarted", video);
}
// Video closed
VideoPlayer.prototype.onVideoClosed = function(video) {
	this.log("videoCallback", "onVideoClosed ");
	video.state = "closed";
	this._fireEvent("onVideoClosed", video);
	video.state = null;
	if (video == this.getCurrentVideo()) {
		if (this.state != "stop") {
			var segment = video.getCurrentSegment();
			if ((segment) && (segment.maxPosition > segment.duration - 2)) {
				this.forward();
			} else {
				if (segment) {
					this.log("videoCallback", "segment not done " + segment.maxPosition + " " + segment.duration);
				} else {
					this.log("videoCallback", "no segment");
				}
			}
		} else {
			this.log("videoCallback", "stop " + this.state);
		}	
	} else {
		this.log("videoCallback", "not current");
	}
}
// Video loaded from XML
VideoPlayer.prototype.onVideoLoaded = function(video) {
	this._fireEvent("onVideoPropertyChanged", video);  // Legacy
	this._fireEvent("onVideoLoaded", video);

	// If in open state, 
	if (video.state == "opened") {
		this.onVideoSet(video);
	}
}

// Segment opened
VideoPlayer.prototype.onSegmentOpened = function(segment) {
	this.log("segmentCallback", "onSegmentOpened ");
	segment.state = "opened";
	this._fireEvent("onSegmentOpened", segment);

	// If loaded from XML, then already set
	if (segment.loaded) {
		this.onSegmentSet(segment);
	}
}
// Segment set
VideoPlayer.prototype.onSegmentSet = function(segment) {
	this.log("segmentCallback", "onSegmentSet ");
	segment.state = "set";
	this._fireEvent("onSegmentSet", segment);

	if (!this.capabilities.scripting[this.format]) {
		this.onSegmentStarted(segment);
	}
}
// Segment started
VideoPlayer.prototype.onSegmentStarted = function(segment) {
	this.log("segmentCallback", "onSegmentStarted ");
	segment.state = "started";
	this._fireEvent("onSegmentStarted", segment);
}
// Segment closed
VideoPlayer.prototype.onSegmentClosed = function(segment) {
	this.log("segmentCallback", "onSegmentClosed ");
	segment.state = "closed";
	this._fireEvent("onSegmentClosed", segment);
	segment.state = null;
}

// State changed
VideoPlayer.prototype.onPlayStateChanged = function(state) {
	this.log("stateCallback", "onPlayStateChanged " + state);
	if (this.playState != state) {
		this.playState = state;
		this._fireEvent("onPlayStateChanged", state);
	}
}
// Position changed
VideoPlayer.prototype.onPositionChanged = function(pos, dur) {
	this.log("positionCallback", "onPositionChanged " + pos + "/" + dur);
	if (this.currentVideo)
		this._fireEvent("onPositionChanged", pos, dur);
}
// Buffering 
VideoPlayer.prototype.onBuffering = function(percent) {
	this.log("bufferingCallback", "onBuffering " + percent);
	this._fireEvent("onBuffering", percent);
}
// Command
VideoPlayer.prototype.onCommand = function(type, param) {
	this.log("bufferingCallback", "onCommand " + type + " " + param);
	this._fireEvent("onCommand", type, param);
}






//--------------------------------------------------------------------
// Detect installed players
var detectResult = false; 
VideoPlayer.prototype.detectIEPlugin = function(classID) { 
	document.write('<SCRIPT LANGUAGE=VBScript>\n on error resume next \n detectResult = IsObject(CreateObject("' + classID + '"))</SCRIPT>\n'); 
	return detectResult; 
}
VideoPlayer.prototype.detectNSPlugin = function(classID) { 
	try {
		return ((navigator.mimeTypes != null) && (navigator.mimeTypes[classID]) && (navigator.mimeTypes[classID].enabledPlugin != null));
	} catch (e) {
		return false;
	}
}
VideoPlayer.prototype.detectCapabilities = function() {
	this.log("detect", "detectCapabilities");
	try {
		// Default to false
		this.capabilities = new Object();
		this.capabilities.formats = new Array();
		this.capabilities.formats["rm"] = false;
		this.capabilities.formats["wmv"] = false;
		this.capabilities.scripting = new Array();
		this.capabilities.scripting["rm"] = false;
		this.capabilities.scripting["wmv"] = false;

		// Detect browser
		var ua = navigator.userAgent.toLowerCase();
		if (ua.indexOf("msie") != -1) this.capabilities.browser = "ie";
		else if (ua.indexOf("safari") != -1) this.capabilities.browser = "safari";
		else if (ua.indexOf("firefox") != -1) this.capabilities.browser = "firefox";
		else if (navigator.appName.indexOf("Netscape") != -1) this.capabilities.browser = "netscape";

		if ((ua.indexOf("win") != -1) || (ua.indexOf("32bit") != -1)) this.capabilities.os = "windows";
		else if (ua.indexOf("mac") != -1) this.capabilities.os =  "mac";
		if (this.capabilities.browser == "ie") {
			var start = ua.indexOf("msie ") + 5;
			var end = ua.indexOf(";", start);
			this.capabilities.browserVersion = parseFloat(ua.substring(start, end));
		} else {
			this.capabilities.browserVersion = -1;
		}
	
		// Detect players
		if (this.capabilities.browser == "ie") {
			this.capabilities.formats["rm"] = this.capabilities.scripting["rm"] = this.detectIEPlugin("rmocx.RealPlayer G2 Control.1");
			this.capabilities.formats["wmv"] = this.capabilities.scripting["wmv"] = this.detectIEPlugin("MediaPlayer.MediaPlayer.1");
			if ((this.capabilities.os == "mac") || (this.capabilities.browserVersion < 5)) {
				this.capabilities.scripting["wmv"] = false;
			}
		} else {
			this.capabilities.formats["rm"] = this.capabilities.scripting["rm"] = this.detectNSPlugin("audio/x-pn-realaudio-plugin");
			this.capabilities.formats["wmv"] = this.detectNSPlugin("application/x-mplayer2");
			this.capabilities.scripting["wmv"] = false;
		}
		
		// Get install formats
		if (this.capabilities.formats["rm"] && this.capabilities.formats["wmv"])
			this.installedFormats = "rm|wmv";
		else if (this.capabilities.formats["rm"])
			this.installedFormats = "rm";
		else if (this.capabilities.formats["wmv"])
			this.installedFormats = "wmv";
		else 
			this.installedFormats = "";

		// Get supported formats
		if (this.capabilities.os == "mac") {
			this.supportedFormats = "rm";
		} else if (this.capabilities.browser == "ie") {
			this.supportedFormats = "wmv|rm";
		} else if (this.capabilities.browser == "firefox") {
			this.supportedFormats = "wmv|rm";
		} else {
			this.supportedFormats = "rm";
		}

		// Possible format is intersection of installed and supported
		this.possibleFormats = "";
		if ((this.installedFormats.indexOf("wmv") >= 0) && (this.supportedFormats.indexOf("wmv") >= 0)) {
			if (this.possibleFormats != "") this.possibleFormats = this.possibleFormats  + "|";
			this.possibleFormats = this.possibleFormats  + "wmv";
		}
		if ((this.installedFormats.indexOf("rm") >= 0) && (this.supportedFormats.indexOf("rm") >= 0)) {
			if (this.possibleFormats != "") this.possibleFormats = this.possibleFormats  + "|";
			this.possibleFormats = this.possibleFormats  + "rm";
		}
	} catch (e) {
		this.log("error", "detectCapabilities " + e);
	}
	this._fireEvent("onCapabilitiesChanged", this.capabilities);
}
//--------------------------------------------------------------------
// Disable the ability to script a format
VideoPlayer.prototype.disableScripting = function(format) {
	this.log("capabilites", 'disableScripting ' + format);
	this.capabilities.scripting[format] = false;
	this._fireEvent("onCapabilitiesChanged", this.capabilities);
}

//--------------------------------------------------------------------
// Detect startup format
VideoPlayer.prototype.detectFormat = function() {
	this.log("detect", "detectFormat");
	if (!this.capabilities)
		this.detectCapabilities();
	
	var format = getCookie("vp_format");
	//format = null;
	if (!format) {
		if (this.possibleFormats == "")
			format = null;
		else if (this.possibleFormats.indexOf("|") >= 0)
			format = null;
		else
			format = this.possibleFormats;
	}
	this.format = format;
	this.defaultFormat = format;
	return format;
}



//--------------------------------------------------------------------
// Inserts the iframe into the document
VideoPlayer.prototype.print = function(width, height, div) {
	this.log("display", "printIFrame");
	if (width) this.width = width;
	if (height) this.height = height;
	if (div) {
		div.innerHTML = '<iframe id="videoPlayerIFrame' + this.objectId + '" height="' + this.height + '" width="' + this.width + '" scrolling="no" frameborder="0"></iframe>';
	} else {
		document.write('<iframe id="videoPlayerIFrame' + this.objectId + '" height="' + this.height + '" width="' + this.width + '" scrolling="no" frameborder="0"></iframe>');
	}
	if (this.format)
		this.setFormat(this.format);
	else
		this.chooseFormat(true, true);
}
// Returns the iframe
VideoPlayer.prototype.getIFrame = function() {
	if (this.iFrame == null) {
		this.iFrame = document.getElementById("videoPlayerIFrame" + this.objectId);
	}
	return this.iFrame;
}
// Returns the document for the iframe
VideoPlayer.prototype.getIFrameDocument = function() {
	var iFrame = this.getIFrame();
	if (iFrame == null) {
		return null;
	}
	return iFrame.contentWindow.document;
}



//--------------------------------------------------------
// Sets the image in the iframe
VideoPlayer.prototype.setImage = function(imageUrl) {
	this._executeFrameCommand("setImage", imageUrl);
}

//--------------------------------------------------------
// Gets the current video
VideoPlayer.prototype.getCurrentVideo = function() {
	if (this.currentVideo == null) {
		this.setCurrentVideo(this.playlist.getCurrentVideo());
		if (this.currentVideo == null) {
			this.setCurrentVideo(this.defaultPlaylist.getCurrentVideo());
		}
	}
	return this.currentVideo;
}
//--------------------------------------------------------
// Sets the current video
VideoPlayer.prototype.setCurrentVideo = function(param1, param2, param3) {
	var old = this.currentVideo;
	if (param1 == null) {
		this.currentVideo = null;
	} else {
		this.currentVideo = this.getVideo(param1, param2, param3);
	}
	if (this.currentVideo != null) {
		if (!this.currentVideo.equals(old)) {
			this.log("video", "current video changed " + (old ? old.videoId : 0) + " " + (this.currentVideo ? this.currentVideo.videoId : 0));
			var video = this.playlist.getCurrentVideo();
			if ((!video) || (!video.equals(this.currentVideo))) {
				if (this.skipToVideo) {
					this.playlist.skipToVideo(this.currentVideo);
				} else {
					this.playlist.placeVideo(this.currentVideo);
				}
			}
			this.setImage(this.currentVideo.getImageUrl());
			this.defaultPlaylist.removeVideo(this.currentVideo);
			this._fireEvent("onCurrentVideoChanged", this.currentVideo);
		}
	} else if (old != null) {
		this.setImage(this.defaultImage);
		this.defaultPlaylist.removeVideo(this.currentVideo);
		this._fireEvent("onCurrentVideoChanged", this.currentVideo);
	}
}
//--------------------------------------------------------
// Adds a video to the playlist
VideoPlayer.prototype.addVideo = function(param1, param2, param3) {
	if ((this.format) && (!this.capabilities.scripting[this.format])) {
		return false;
	}
	this.playlist.addVideo(param1, param2, param3);
	this.defaultPlaylist.removeVideo(param1, param2, param3);
	if ((!this.skipToVideo) && (this.playlist.pos == -1)) {
		this.playlist.pos = 0;
	}
	return true;
}
//--------------------------------------------------------
// Adds a video to the default playlist
VideoPlayer.prototype.addDefaultVideo = function(param1, param2, param3) {
	if (!this.findVideo(param1, param2, param3)) {
		this.defaultPlaylist.addVideo(param1, param2, param3);
	}
}
//--------------------------------------------------------
// Removes the video from the playlist
VideoPlayer.prototype.removeVideo = function(param1, param2, param3) {
	this.playlist.removeVideo(param1, param2, param3);
	this.defaultPlaylist.removeVideo(param1, param2, param3);
}
//--------------------------------------------------------
// Returns the next video in the playlist
VideoPlayer.prototype.getNextVideo = function() {
	var video = this.playlist.getNextVideo();
	if (video == null) {
		return this.defaultPlaylist.getNextVideo();
	}
	return video;
}


/**************************************************************************************** ( fs008a )
*
*                          Original File: VideoControls.js
*
****************************************************************************************/
//---------------------------------------------------------------
// Video Controls object
VideoControls.prototype = new CBSObject();
VideoControls.prototype.constructor = VideoControls;
function VideoControls(videoPlayer, imageRoot) {
  this.superClass = CBSObject.prototype;
  this.superClass.constructor.call(this);
	this.objectType = "VideoControls";
	_objects[this.objectId] = this;
	
	if (imageRoot) this.imageRoot = imageRoot;
	else this.imageRoot = videoPlayer.imageRoot;
	
	this.videoPlayer = videoPlayer;
	this.videoPlayer.attachEvent("onSegmentSet", this.onSegmentSet, this);
	this.videoPlayer.attachEvent("onPlayStateChanged", this.onPlayStateChanged, this);
	this.videoPlayer.attachEvent("onPositionChanged", this.onPositionChanged, this);
	this.videoPlayer.attachEvent("onFormatChanged", this.onFormatChanged, this);
	this.videoPlayer.attachEvent("onDefaultFormatChanged", this.onFormatChanged, this);
	this.videoPlayer.attachEvent("onCapabilitiesChanged", this.onCapabilitiesChanged, this);
	this.videoPlayer.attachEvent("onBuffering", this.onBuffering, this);
	
	this.hasRewind = true;
	this.hasForward = true;
	this.hasCommands = true;
	
	this.thumbStart = null;
	this.thumbImage = null;
	this.thumbDiv = null;
	this.thumbImagePos = null;
	
	this.thumbOffsetX = 0;
	this.thumbOffsetY = 6;

	this.state = "play";
	this.muted = false;
	this.lastVolume = videoPlayer.getVolume();
	
	this.skipEnabled = true;
}

//---------------------------------------------------------------
// Called when video changes state
VideoControls.prototype.onPlayStateChanged = function(event, state) {
	this.log("state",  "onPlayStateChanged " + state);
	if ((state == "none") || (state == "stopped") || (state == "paused") || (state == "ended") || (state == "seeking")) {
		this.showPlay();
	} else if (this.videoPlayer.capabilities.scripting[this.videoPlayer.format]) {
		this.showPause();
	} else {
		this.showStop();
	}
	if ((state == "stopped") || (state == "ended")) {
		this.hideThumb();
	}
	var video = this.videoPlayer.getCurrentVideo();
	if (state) {
		if ((state == "playing") && (video)) {
			var segment = video.getCurrentSegment();
			if (segment) {
				this.setStatusText("Playing (" + this.getTimeString(segment.position) + " / " + this.getTimeString(segment.duration) + ")");
			} else {
				this.setStatusText("Playing");
			}
		} else {
			this.setStatusText(state.substring(0, 1).toUpperCase() + state.substring(1));
		}
	}
}

//---------------------------------------------------------------
// Called when video buffers
VideoControls.prototype.onBuffering = function(event, percent) {
	this.log("buffering",  "onBuffering " + percent);
	this.setStatusText("Buffering (" + percent + "%)");
}
//---------------------------------------------------------------
// Called when video position changes
VideoControls.prototype.onPositionChanged = function(event, pos, len) {
	if (len == 0) return;
	if (this.thumbStart != null) return;
	
	var thumbPos = (pos * (175-55) / len) + 28;
	this.log("position", "pos " + pos + "/" + len + " " + thumbPos);
	this.setThumbPosition(thumbPos);
	if (this.videoPlayer.isPlaying()) {
			this.setStatusText("Playing (" + this.getTimeString(pos) + " / " + this.getTimeString(len) + ")");
	}
}
//---------------------------------------------------------------
// Called when video format changes
VideoControls.prototype.onFormatChanged = function(event, format) {
	this.log("format", "onFormatChanged " + format);
	var controlsTD = document.getElementById("controlsTD" + this.objectId);
	if (controlsTD) {
		controlsTD.innerHTML = this._getControlsHtml(format);
	}
	var commandsTD = document.getElementById("commandsTD" + this.objectId);
	if (commandsTD) {
		commandsTD.innerHTML = this._getCommandsHtml(format);
	}
	var mainTable = document.getElementById(this.objectId + "_table");
	if (mainTable) {
		this.log("format", this.videoPlayer.capabilities.scripting[format]);
		this.log("format", this.imageRoot + "/bg.gif");
		if (this.videoPlayer.capabilities.scripting[format]) {
			mainTable.background = this.imageRoot + "/bg.gif";
			mainTable.style.backgroundImage = "url(" + this.imageRoot + "/bg.gif)";
		} else {
			mainTable.background = this.imageRoot + "/bg.gif";
			mainTable.style.backgroundImage = "url(" + this.imageRoot + "/bg.gif)";
		}
	}
}
//---------------------------------------------------------------
// Called when video format changes
VideoControls.prototype.onCapabilitiesChanged = function(event, capabilities) {
	this.log("format", "onCapabilitiesChanged");
	var controlsTD = document.getElementById("controlsTD" + this.objectId);
	if (controlsTD) {
		controlsTD.innerHTML = this._getControlsHtml();
	}
	var commandsTD = document.getElementById("commandsTD" + this.objectId);
	if (commandsTD) {
		commandsTD.innerHTML = this._getCommandsHtml();
	}
	var mainTable = document.getElementById(this.objectId + "_table");
	if (mainTable) {
		if (this.videoPlayer.capabilities.scripting[this.videoPlayer.format]) {
			mainTable.background = this.imageRoot + "/bg.gif";
			mainTable.style.backgroundImage = "url(" + this.imageRoot + "/bg.gif)";
		} else {
			mainTable.background = this.imageRoot + "/bg.gif";
			mainTable.style.backgroundImage = "url(" + this.imageRoot + "/bg.gif)";
		}
	}
}
//---------------------------------------------------------------
// Called when segment params have been set
VideoControls.prototype.onSegmentSet = function(event, segment) {
	if (segment.ad) this.skipEnabled = false;
	else this.skipEnabled = true;
	//this.skipEnabled = true;
	this.log("ads", "skip " + this.skipEnabled);
}

//---------------------------------------------------------------
// Returns a time string in MM:SS format
VideoControls.prototype.getTimeString = function(seconds) {
	var secs = seconds % 60;
	var mins = Math.floor(seconds / 60);
	if (secs < 10) {
		return mins + ":0" + secs;
	} else { 
		return mins + ":" + secs;
	}
}

//---------------------------------------------------------------
// Sets the status text
VideoControls.prototype.setStatusText = function(text) {
	this.log("controls", "setStatusText " + text);
	this.statusTextSpan = document.getElementById("statusTextSpan");
	if (this.statusTextSpan)
		this.statusTextSpan.innerHTML = text;
}
//---------------------------------------------------------------
// Show pause button
VideoControls.prototype.showPause = function() {
	this.log("controls", "showPause");
	//if (this.state == "pause") return;
	this.log("controls", "showPause2");
	this.state = "pause";
	//if (this.playPauseStopTD == null)
		this.playPauseStopTD = document.getElementById("playPauseStopTD" + this.objectId);
	this.playPauseStopTD.innerHTML = "<a name=\"none\" onclick=\"_objects['" + this.objectId + "'].pause();\"><img id=\"pauseImage\" src=\"" + this.imageRoot + "/pause.gif\" onmousedown=\"_objects['" + this.objectId + "'].controlDown(this);\" onmouseout=\"_objects['" + this.objectId + "'].controlUp(this);\" onmouseup=\"_objects['" + this.objectId + "'].controlUp(this);\" border=\"0\" width=\"18\" height=\"17\" style=\"cursor:pointer;\"></a>";
}

//---------------------------------------------------------------
// Show play button
VideoControls.prototype.showPlay = function() {
	this.log("controls", "showPlay");
	//if (this.state == "play") return;
	this.log("controls", "showPlay2");
	this.state = "play";
	//if (this.playPauseStopTD == null)
		this.playPauseStopTD = document.getElementById("playPauseStopTD" + this.objectId);
	this.playPauseStopTD.innerHTML = "<a name=\"none\" onclick=\"_objects['" + this.objectId + "'].play();\"><img id=\"playImage\" src=\"" + this.imageRoot + "/play.gif\" onmousedown=\"_objects['" + this.objectId + "'].controlDown(this);\" onmouseout=\"_objects['" + this.objectId + "'].controlUp(this);\" onmouseup=\"_objects['" + this.objectId + "'].controlUp(this);\" border=\"0\" width=\"18\" height=\"17\" style=\"cursor:pointer;\"></a>";
}

//---------------------------------------------------------------
// Show stop button
VideoControls.prototype.showStop = function() {
	this.log("controls", "showStop");
	//if (this.state == "stop") return;
	this.log("controls", "showStop2");
	this.state = "stop";
	//if (this.playPauseStopTD == null)
		this.playPauseStopTD = document.getElementById("playPauseStopTD" + this.objectId);
	this.playPauseStopTD.innerHTML = "<a name=\"none\" onclick=\"_objects['" + this.objectId + "'].stop();\"><img id=\"stopImage\" src=\"" + this.imageRoot + "/stop.gif\" onmousedown=\"_objects['" + this.objectId + "'].controlDown(this);\" onmouseout=\"_objects['" + this.objectId + "'].controlUp(this);\" onmouseup=\"_objects['" + this.objectId + "'].controlUp(this);\" border=\"0\" width=\"18\" height=\"17\" style=\"cursor:pointer;\"></a>";
}
//---------------------------------------------------------------
// Sets a image to the given state
VideoControls.prototype.setImageState = function(name, state) {
	var img = document.getElementById(name + "Image");
	if (img) {
		this.setImgState(img, state);
	}
}
VideoControls.prototype.setImgState = function(img, state) {
	var p = img.src.lastIndexOf("_");
	if (p == -1) {
		p = img.src.lastIndexOf(".");
	}
	if (state) {
		img.src = img.src.substring(0, p) + "_" + state + ".gif";
	} else {
		img.src = img.src.substring(0, p) + ".gif";
	}
}

//---------------------------------------------------------------
// When a user presses a button
VideoControls.prototype.controlDown = function(img) {
	this.setImgState(img, "down");
}
//---------------------------------------------------------------
// When a user releases a button
VideoControls.prototype.controlUp = function(img) {
	this.setImgState(img);
}
//---------------------------------------------------------------
// When a user mouses over a command
VideoControls.prototype.commandEnter = function(a) {
	a.style.textDecoration = 'underline';
}
//---------------------------------------------------------------
// When a user mouses out of command
VideoControls.prototype.commandOut = function(a) {
	a.style.textDecoration = '';
}

VideoControls.prototype.test = function() {
	alert('k');
}
//---------------------------------------------------------------
// When a user presses the thumb
VideoControls.prototype.thumbDown = function(event) {
	if (!event) event = window.event;
	this.log("thumb", "down");
	if (this.thumbImage == null)
		this.thumbImage = document.getElementById("thumbImage" + this.objectId);
	if (this.thumbDiv == null)
		this.thumbDiv = document.getElementById("thumbDiv" + this.objectId);

	if ((this.thumbDiv) && (this.thumbImage)) {
		if (this.thumbImagePos == null)
			this.thumbImagePos = getElementPosition(this.thumbImage);
		this.thumbStart = this.thumbImagePos.x;
		this.setThumbPosition(event.clientX - this.thumbStart);
		eval("document.onmousemove = function(e) { _objects['" + this.objectId + "'].thumbMove(e); }");
		eval("document.onmouseup = function(e) { _objects['" + this.objectId + "'].thumbUp(e); }");
		eval("document.onmousedown = function(e) { return false; }");
	}
}
//---------------------------------------------------------------
// When a user moves the thumb
VideoControls.prototype.thumbMove = function(event) {
	if (!event) event = window.event;
	this.log("thumb", "move" + event.button);
	if (this.thumbStart != null) {
		this.setThumbPosition(event.clientX - this.thumbStart);
	}
}
//---------------------------------------------------------------
// When a user releases the thumb
VideoControls.prototype.thumbUp = function(event) {
	if (!event) event = window.event;
	this.log("thumb", "up");

	var loc = this.setThumbPosition(event.clientX - this.thumbStart);
	this.setPosition(Math.round(100 * loc / (175-55)) + "%");

	if (this.thumbDiv == null)
		this.thumbDiv = document.getElementById("thumbDiv" + this.objectId);
	if (this.thumbDiv) {
		document.onmousemove = null;
		document.onmouseup = null;
		document.onmousedown = null;
	}
	this.thumbStart = null;
}
//---------------------------------------------------------------
// Moves the thumb
VideoControls.prototype.thumbPosition = function(event) {
	if (!event) event = window.event;

	if (this.thumbImage == null)
		this.thumbImage = document.getElementById("thumbImage" + this.objectId);
	if (this.thumbImagePos == null)
		this.thumbImagePos = getElementPosition(this.thumbImage);

	this.log("thumb", "pos " + (event.clientX - this.thumbImagePos.x));
	var loc = this.setThumbPosition(event.clientX - this.thumbImagePos.x);
	this.setPosition(Math.round(100 * loc / (175-55)) + "%");
}

//---------------------------------------------------------------
// Moves the thumb
VideoControls.prototype.setThumbPosition = function(offset) {
	this.log("thumb", "setThumbPosition " + offset);
	if (this.thumbImage == null)
		this.thumbImage = document.getElementById("thumbImage" + this.objectId);
	if (this.thumbDiv == null)
		this.thumbDiv = document.getElementById("thumbDiv" + this.objectId);

	if ((this.thumbDiv) && (this.thumbImage)) {
		if (this.thumbImagePos == null)
			this.thumbImagePos = getElementPosition(this.thumbImage);
		var loc = offset - 28;
		if (loc < 0) {
			loc = 0;
		} else if (loc > 175-55) {
			loc = 175-55;
		}
		this.thumbDiv.style.left = this.thumbImagePos.x + this.thumbOffsetX + loc;
		this.thumbDiv.style.top = this.thumbImagePos.y + this.thumbOffsetY;
		this.thumbDiv.style.visibility = "visible";
		return loc;
	}
	return 0;
}
//---------------------------------------------------------------
// Hide the thumb
VideoControls.prototype.hideThumb = function() {
	if (this.thumbDiv == null)
		this.thumbDiv = document.getElementById("thumbDiv" + this.objectId);
	this.thumbDiv.style.visibility = "hidden";
}

//---------------------------------------------------------------
// prints on the controls
VideoControls.prototype._getControlsHtml = function(format) {
	this.log("controls", "_getControlsHtml");
	if (!format) format = this.videoPlayer.format;
	var scripting = this.videoPlayer.capabilities.scripting[format];
	var html = '<table cellspacing=0 cellpadding=0 border=0 width="' + this.videoPlayer.width + '">';
	html += '	<tr valign="top">';
	html += '		<td><img src="' + this.imageRoot + '/spacer.gif" border="0" width="5" height="17"></td>';
	if (this.hasRewind) {
		html += "		<td width=18><a name=\"none\" onclick=\"_objects['" + this.objectId + "'].rewind();\"><img id=\"rewindImage\" src=\"" + this.imageRoot + "/rewind.gif\" onmousedown=\"_objects['" + this.objectId + "'].controlDown(this);\" onmouseout=\"_objects['" + this.objectId + "'].controlUp(this);\" onmouseup=\"_objects['" + this.objectId + "'].controlUp(this);\" border=\"0\" width=\"18\" height=\"17\" style=\"cursor:pointer;\"></a></td>";
	} else {
		html += "		<td width=18><img src=\"" + this.imageRoot + "/spacer.gif\" border=\"0\" width=\"18\" height=\"17\"></td>";
	}
	html += '		<td><img src="' + this.imageRoot + '/spacer.gif" border="0" width="3" height="17"></td>';
	if (this.videoPlayer.isStopped() || this.videoPlayer.isPaused()) {
		this.state = "play";
		html += "		<td width=18 id=\"playPauseStopTD" + this.objectId + "\"><a name=\"none\" onclick=\"_objects['" + this.objectId + "'].play();\"><img id=\"playImage\" src=\"" + this.imageRoot + "/play.gif\" onmousedown=\"_objects['" + this.objectId + "'].controlDown(this);\" onmouseout=\"_objects['" + this.objectId + "'].controlUp(this);\" onmouseup=\"_objects['" + this.objectId + "'].controlUp(this);\" border=\"0\" width=\"18\" height=\"17\" style=\"cursor:pointer;\"></a></td>";
	} else {
		if (scripting) {
			this.state = "pause";
			html += "		<td width=18 id=\"playPauseStopTD" + this.objectId + "\"><a name=\"none\" onclick=\"_objects['" + this.objectId + "'].pause();\"><img id=\"pauseImage\" src=\"" + this.imageRoot + "/pause.gif\" onmousedown=\"_objects['" + this.objectId + "'].controlDown(this);\" onmouseout=\"_objects['" + this.objectId + "'].controlUp(this);\" onmouseup=\"_objects['" + this.objectId + "'].controlUp(this);\" border=\"0\" width=\"18\" height=\"17\" style=\"cursor:pointer;\"></a></td>";
		} else {
			this.state = "stop";
			html += "		<td width=18 id=\"playPauseStopTD" + this.objectId + "\"><a name=\"none\" onclick=\"_objects['" + this.objectId + "'].stop();\"><img id=\"stopImage\" src=\"" + this.imageRoot + "/stop.gif\" onmousedown=\"_objects['" + this.objectId + "'].controlDown(this);\" onmouseout=\"_objects['" + this.objectId + "'].controlUp(this);\" onmouseup=\"_objects['" + this.objectId + "'].controlUp(this);\" border=\"0\" width=\"18\" height=\"17\" style=\"cursor:pointer;\"></a></td>";
		}
	}
	html += '		<td><img src="' + this.imageRoot + '/spacer.gif" border="0" width="3" height="17"></td>';
	if ((scripting) && (this.hasForward)) {
		html += "		<td width=18><a name=\"none\" onclick=\"_objects['" + this.objectId + "'].forward();\"><img id=\"fowardImage\" src=\"" + this.imageRoot + "/forward.gif\" onmousedown=\"_objects['" + this.objectId + "'].controlDown(this);\" onmouseout=\"_objects['" + this.objectId + "'].controlUp(this);\" onmouseup=\"_objects['" + this.objectId + "'].controlUp(this);\" border=\"0\" width=\"18\" height=\"17\" style=\"cursor:pointer;\"></a></td>";
	} else {
		html += "		<td width=18><img src=\"" + this.imageRoot + "/spacer.gif\" border=\"0\" width=\"18\" height=\"17\"></td>";
	}
	html += '		<td><img src="' + this.imageRoot + '/spacer.gif" border="0" width="10" height="17"></td>';
	if (scripting) {
		html += "		<td valign=\"bottom\"><table cellspacing=0 cellpadding=0 border=0><tr height=\"17\"><td width=175 nowrap valign=\"bottom\" onclick=\"_objects['" + this.objectId + "'].thumbPosition(event)\" style=\"color:#FFFFFF; background: url(" + this.imageRoot + "/slider.gif) no-repeat; font-family:Arial; font-size:7pt;cursor:pointer;\"><img id=\"thumbImage" + this.objectId + "\" src=\"" + this.imageRoot + "/spacer.gif\" border=\"0\" width=\"1\" height=\"21\"><span id=\"statusTextSpan\">Ready</span></td></tr></table></td>";
	} else {
		html += "		<td><img id=\"thumbImage" + this.objectId + "\" src=\"" + this.imageRoot + "/spacer.gif\" border=\"0\" width=\"175\" height=\"17\"></td>";
	}
	html += '		<td><img src="' + this.imageRoot + '/spacer.gif" border="0" width="9" height="17"></td>';
	if (scripting) {
		html += "		<td width=18><a name=\"none\" id=\"muteHref\" onclick=\"_objects['" + this.objectId + "'].toggleMute();\"><img id=\"muteImage\" src=\"" + this.imageRoot + "/mute.gif\" onmousedown=\"_objects['" + this.objectId + "'].controlDown(this);\" onmouseout=\"_objects['" + this.objectId + "'].controlUp(this);\" onmouseup=\"_objects['" + this.objectId + "'].controlUp(this);\" border=\"0\" width=\"18\" height=\"17\" style=\"cursor:pointer;\"></a></td>";
		html += '		<td><img src="' + this.imageRoot + '/spacer.gif" border="0" width="4" height="17"></td>';
		html += "		<td width=6><a name=\"none\" onclick=\"_objects['" + this.objectId + "'].setVolume(20);\"><img id=\"volume1Image\" src=\"" + this.imageRoot + "/volume1_on.gif\" border=\"0\" width=\"6\" height=\"17\" style=\"cursor:pointer;\"></a></td>";
		html += "		<td width=6><a name=\"none\" onclick=\"_objects['" + this.objectId + "'].setVolume(40);\"><img id=\"volume2Image\" src=\"" + this.imageRoot + "/volume2_on.gif\" border=\"0\" width=\"6\" height=\"17\" style=\"cursor:pointer;\"></a></td>";
		html += "		<td width=6><a name=\"none\" onclick=\"_objects['" + this.objectId + "'].setVolume(60);\"><img id=\"volume3Image\" src=\"" + this.imageRoot + "/volume3_on.gif\" border=\"0\" width=\"6\" height=\"17\" style=\"cursor:pointer;\"></a></td>";
		html += "		<td width=6><a name=\"none\" onclick=\"_objects['" + this.objectId + "'].setVolume(80);\"><img id=\"volume4Image\" src=\"" + this.imageRoot + "/volume4_on.gif\" border=\"0\" width=\"6\" height=\"17\" style=\"cursor:pointer;\"></a></td>";
		html += "		<td width=6><a name=\"none\" onclick=\"_objects['" + this.objectId + "'].setVolume(100);\"><img id=\"volume5Image\" src=\"" + this.imageRoot + "/volume5_on.gif\" border=\"0\" width=\"6\" height=\"17\" style=\"cursor:pointer;\"></a></td>";
	}
    html += '		<td><img src="' + this.imageRoot + '/spacer.gif" border="0" width="5" height="17"></td>';
	html += '	</tr>';
	html += '</table>';
	return html;
}
VideoControls.prototype._getCommandsHtml = function(format) {
    if(this.hasCommands){
	    this.log("print", "_getCommandsHtml");
	    if (!format) format = this.videoPlayer.format;
	    var scripting = this.videoPlayer.capabilities.scripting[format];
	    var html = '<table cellspacing=0 cellpadding=0 border=0 id="commandsTbl">';
	    html += '	<tr valign="top">';
	    html += '		<td width="100%"></td>';
	    html += '		<td align="right" nowrap style="color:#FFFFFF; font-family:Arial; font-size:8pt; visited:#FFFFFF; cursor:pointer;">';
	    if (scripting) 
		    html += "			<a name=\"none\" onmouseenter=\"_objects['" + this.objectId + "'].commandEnter(this);\" onmouseout=\"_objects['" + this.objectId + "'].commandOut(this);\" onclick=\"_objects['" + this.objectId + "'].setFullscreen();\">Fullscreen</a> | ";
	    if ((this.videoPlayer.capabilities.scripting["rm"]) && (this.videoPlayer.capabilities.scripting["wmv"])) {
		    html += "			<a name=\"none\" onmouseenter=\"_objects['" + this.objectId + "'].commandEnter(this);\" onmouseout=\"_objects['" + this.objectId + "'].commandOut(this);\" onclick=\"_objects['" + this.objectId + "'].showSettings();\">Settings</a> | ";
	    }
	    html += "			<a name=\"none\" onmouseenter=\"_objects['" + this.objectId + "'].commandEnter(this);\" onmouseout=\"_objects['" + this.objectId + "'].commandOut(this);\" onclick=\"_objects['" + this.objectId + "'].showHelp();\">Help</a>";
	    html += '		</td>';
	    html += '		<td><img src="' + this.imageRoot + '/spacer.gif" border="0" width="5" height="1"></td>';
	    html += '	</tr>';
	    html += '</table>';
    } else {
        var html = "";
    }
	return html;
}
VideoControls.prototype.print = function() {
	document.write('<table id="' + this.objectId + '_table" cellspacing=0 cellpadding=0 border=0 bgcolor="#11265F" width="' + this.videoPlayer.width + '" height="45" style="background-image:url(' + this.imageRoot + '/bg.gif); repeat: y;">');
	document.write('	<tr height="5"><td><img src="' + this.imageRoot + '/spacer.gif" border="0" width="1" height="5"></td></tr>');
	document.write('	<tr height="17">');
	document.write('		<td id="controlsTD' + this.objectId + '">');
	document.write(this._getControlsHtml());
	document.write('		</td>');
	document.write('	</tr>');
	document.write('	<tr>');
	document.write('		<td id="commandsTD' + this.objectId + '" valign="top">');
    document.write(this._getCommandsHtml());
	document.write('		</td>');
	document.write('	</tr>');
	document.write('</table>');
	document.write("<div id=\"thumbDiv" + this.objectId + "\" ondragstart=\"event.returnValue=false; return false;\" onmousedown=\"_objects['" + this.objectId + "'].thumbDown(event);\" onmousemove=\"_objects['" + this.objectId + "'].thumbMove(event);\" onmouseUp=\"_objects['" + this.objectId + "'].thumbUp(event)\" style=\"visibility:hidden; position:absolute; cursor:pointer;\" border=\"0\"><img src=\"" + this.imageRoot + "/thumb.gif\" border=\"0\" width=\"55\" height=\"5\"></div>");
	
	this.setVolume(this.videoPlayer.getVolume());
}

/***************************************************************\
 * Commands
\***************************************************************/

//---------------------------------------------------------------
// Play
VideoControls.prototype.play = function() {
	this.log("command", "play");
	if (this.videoPlayer) this.videoPlayer.play();
	this._fireEvent("onPlay");
}
//---------------------------------------------------------------
// Pause
VideoControls.prototype.pause = function() {
	this.log("command", "pause");
	if (this.videoPlayer) this.videoPlayer.pause();
	this._fireEvent("onPause");
}
//---------------------------------------------------------------
// Stop
VideoControls.prototype.stop = function() {
	this.log("command", "stop");
	if (this.videoPlayer) this.videoPlayer.stop();
	this._fireEvent("onStop");
}
//---------------------------------------------------------------
// Rewind
VideoControls.prototype.rewind = function() {
	this.log("command", "rewind");
	if ((this.skipEnabled) && (this.videoPlayer)) this.videoPlayer.rewind();
	this._fireEvent("onRewind");
}
//---------------------------------------------------------------
// Forward
VideoControls.prototype.forward = function() {
	this.log("command", "forward");
	if ((this.skipEnabled) && (this.videoPlayer)) this.videoPlayer.forward();
	this._fireEvent("onForward");
}

//---------------------------------------------------------------
// Mute / unmute
VideoControls.prototype.toggleMute = function() {
	this.videoPlayer.log("command", "toggleMute");
	if (this.muted) {
		this.setVolume(this.lastVolume);
	} else {
		this.setVolume(0);
	}
}

//---------------------------------------------------------------
// Set volume
VideoControls.prototype.setVolume = function(volume) {
	this.videoPlayer.log("command", "setVolume " + volume);
	if (volume == 0) {
		var muteImg = document.getElementById("muteImage");
		if (muteImg) muteImg.src = this.imageRoot + "/muted.gif";
		this.muted = true;
	} else {
		var muteImg = document.getElementById("muteImage");
		if (muteImg) muteImg.src = this.imageRoot + "/mute.gif";
		this.muted = false;
		this.lastVolume = volume;
	}
  var i = 1;
	for ( ; i<=volume/20; i++) {
		this.setImageState("volume" + i, "on");
	}
	for ( ; i<=5; i++) {
		this.setImageState("volume" + i, "off");
	}
	if (this.videoPlayer) this.videoPlayer.setVolume(volume);
	this._fireEvent("onVolumeChanged", this.videoPlayer.getVolume());
}
//---------------------------------------------------------------
// Set position
VideoControls.prototype.setPosition = function(pos) {
	this.log("command", "setPosition");
	if ((this.skipEnabled) && (this.videoPlayer)) this.videoPlayer.setPosition(pos);
	this._fireEvent("onPositionChanged", pos);
}
//---------------------------------------------------------------
// Set fullscreen
VideoControls.prototype.setFullscreen = function() {
	this.log("command", "setFullScreen");
	if (this.videoPlayer) this.videoPlayer.setFullscreen();
	this._fireEvent("onFullscreen");
}
//---------------------------------------------------------------
// Show settings
VideoControls.prototype.showSettings = function() {
	this.log("command", "showSettings");
	if (this.videoPlayer) this.videoPlayer.chooseFormat();
	this._fireEvent("onSettings");
}
//---------------------------------------------------------------
// Show Help
VideoControls.prototype.showHelp = function() {
	this.log("command", "showHelp");
	this._fireEvent("onHelp");
    window.open('http://www.sportsline.com' + this.videoPlayer.playerRoot + 'help','help','width=759,height=545,menubar=no,locationbar=no,status=no,resizable=yes,scrollbars=yes');
}


/**************************************************************************************** ( fs009a )
*
*                          Original File: VideoAdController.js
*
****************************************************************************************/
//------------------------------------------------------
// The Video Ad Controller Object
VideoAdController.prototype = new CBSObject();
VideoAdController.prototype.constructor = VideoAdController;
function VideoAdController(videoPlayer, width, height) {
  this.superClass = CBSObject.prototype;
  this.superClass.constructor.call(this);
	this.objectType = "VideoAdController";
	_objects[this.objectId] = this;

	this.videoPlayer = videoPlayer;
	this.videoPlayer.attachEvent("onSegmentSet", this.onSegmentSet, this);
	this.videoPlayer.attachEvent("onSegmentClosed", this.onSegmentClosed, this);
	
	this.width = width;
	this.height = height;
	
	this.startHTML = "";
	this.endHTML = "";
}


//---------------------------------------------------------------
// Called when segment params have been set
VideoAdController.prototype.onSegmentSet = function(event, segment) {
	this.log("ad", "onSegmentSet " + segment.title + " " + segment.ad);
	if (segment.ad) {
		this.log("ad", "onSegmentSet adUrl" + this.width + "x" + this.height + " = " + segment["adUrl" + this.width + "x" + this.height]);
		this.log("ad", "onSegmentSet adImg" + this.width + "x" + this.height + " = " + segment["adImg" + this.width + "x" + this.height]);
		if (segment["adUrl" + this.width + "x" + this.height]) {
			var adUrl = segment["adUrl" + this.width + "x" + this.height];
			var adDiv = document.getElementById("adDiv" + this.objectId);
			if (adDiv) {
				var html = this.startHTML;
				html += '<IFRAME ID="adFrame" SRC="' + adUrl + '" FRAMEBORDER="0" SCROLLING="NO" width="' + this.width + '" height="' + this.height + '" BORDER="0"></IFRAME>';
				html += this.endHTML;
				adDiv.innerHTML = html;
				adDiv.style.visibility = 'visible';
			}
		} else if (segment["adImg" + this.width + "x" + this.height]) {
			var adImg = segment["adImg" + this.width + "x" + this.height];
			var adClk = segment["adClk" + this.width + "x" + this.height];
			var adDiv = document.getElementById("adDiv" + this.objectId);
			if (adDiv) {
				var html = this.startHTML;
				html += '<IFRAME ID="adFrame" SRC="img_ad_frame?adImg=' + escape(adImg) + '&adClk=' + escape(adClk) + '" FRAMEBORDER="0" SCROLLING="NO" width="' + this.width + '" height="' + this.height + '" BORDER="0"></IFRAME>';
				html += this.endHTML;
				adDiv.innerHTML = html;
				adDiv.style.visibility = 'visible';
			}
		} else {
			var adDiv = document.getElementById("adDiv" + this.objectId);
			if (adDiv) {
				adDiv.innerHTML = "";
				adDiv.style.visibility = 'hidden'; 
			}
		}	
		if (segment.startImg) {
			var img = new Image;
			img.src = segment.startImg;
		}
		if (segment.startUrl) {
			var codeDiv = document.getElementById("codeDiv" + this.objectId);
			if (codeDiv) {
				var html = '<IFRAME ID="codeFrame" SRC="' + segment.startUrl + '" FRAMEBORDER="0" SCROLLING="NO" width="0" height="0" BORDER="0"></IFRAME>';
				codeDiv.innerHTML = html;
			}
		}
	}
}

//---------------------------------------------------------------
// Called when segment is closed
VideoAdController.prototype.onSegmentClosed = function(event, segment) {
	this.log("ad", "onSegmentClosed " + segment.title + " " + segment.ad);
	if (segment.ad) {
		if (segment.endImg) {
			var img = new Image;
			img.src = segment.endImg;
		}
		if (segment.endUrl) {
			var codeDiv = document.getElementById("codeDiv" + this.objectId);
			if (codeDiv) {
				var html = '<IFRAME ID="codeFrame" SRC="' + segment.endUrl + '" FRAMEBORDER="0" SCROLLING="NO" width="0" height="0" BORDER="0"></IFRAME>';
				codeDiv.innerHTML = html;
			}
		}
	}
}

//---------------------------------------------------------------
// Show the ad
VideoAdController.prototype.showAd = function(width, height) {
	var adDiv = document.getElementById("adDiv" + this.objectId);
	if (adDiv) {
		adDiv.style.visibility = 'visible';
	}
}
//---------------------------------------------------------------
// Hide the ad
VideoAdController.prototype.hideAd = function(width, height) {
	var adDiv = document.getElementById("adDiv" + this.objectId);
	if (adDiv) {
		adDiv.style.visibility = 'hidden';
	}
}

//---------------------------------------------------------------
// Print out the div to the page
VideoAdController.prototype.print = function(width, height) {
	if (width) this.width = width;
	if (height) this.height = height;
	
	document.write("<span id='adDiv" + this.objectId + "' style='visibility:hidden;'></span>");
	document.write("<span id='codeDiv" + this.objectId + "'></span>");
}


/**************************************************************************************** ( fs010a )
*
*                          Original File: VideoTracker.js
*
****************************************************************************************/
//------------------------------------------------------
// The Video Tracker Object
VideoTracker.prototype = new CBSObject();
VideoTracker.prototype.constructor = VideoTracker;
VideoTracker.prototype.months = new Array();
VideoTracker.prototype.months["Jan"] = 1;
VideoTracker.prototype.months["Feb"] = 2;
VideoTracker.prototype.months["Mar"] = 3;
VideoTracker.prototype.months["Apr"] = 4;
VideoTracker.prototype.months["May"] = 5;
VideoTracker.prototype.months["Jun"] = 6;
VideoTracker.prototype.months["Jul"] = 7;
VideoTracker.prototype.months["Aug"] = 8;
VideoTracker.prototype.months["Sep"] = 9;
VideoTracker.prototype.months["Oct"] = 10;
VideoTracker.prototype.months["Nov"] = 11;
VideoTracker.prototype.months["Dec"] = 12;
function VideoTracker(videoPlayer, time) {
  this.superClass = CBSObject.prototype;
  this.superClass.constructor.call(this);
	this.objectType = "VideoTracker";
	_objects[this.objectId] = this;
	
	this.segmentTracking = false;	
	
	this.watchTracking = false;
	
	this.send = true;
	this.check = false;
	this.debug = "";
	
	this.pausing = false;
	this.closing = false;

	this.initialized = false;
	this.trackingVars = new Array();

	this.videoPlayer = videoPlayer;
	this.videoPlayer.attachEvent("onSegmentOpened", this.onSegmentOpened, this);
	this.videoPlayer.attachEvent("onSegmentSet", this.onSegmentSet, this);
	this.videoPlayer.attachEvent("onSegmentClosed", this.onSegmentClosed, this);
	this.videoPlayer.attachEvent("onVideoOpened", this.onVideoOpened, this);
	this.videoPlayer.attachEvent("onVideoSet", this.onVideoSet, this);
	this.videoPlayer.attachEvent("onVideoClosed", this.onVideoClosed, this);
	
	this.initOmniture();
	if (time != null) {
		this.initTime(time);
	}
}

//--------------------------------------------------------
// Creates an omniture tracking var
VideoTracker.prototype.createTrackingVar = function(account) {
	var omni = s_gi(account)
	omni.wds();
	omni.ca();
	omni.currencyCode="USD"
	/* Link Tracking Config */
	omni.trackDownloadLinks=true
	omni.trackExternalLinks=true
	omni.trackInlineStats=true
	omni.linkDownloadFileTypes="exe,zip,wav,mp3,mov,mpg,avi,wmv,doc,pdf,xls"
	omni.linkInternalFilters="javascript:,cbs"
	omni.linkLeaveQueryString=false
	omni.linkTrackVars="eVar1,eVar2,eVar3,eVar4,eVar5,eVar6,eVar7,eVar8,eVar9,eVar10,eVar11,eVar12,eVar13,eVar14,eVar15,eVar16,eVar17,eVar18,eVar19,eVar20,prop24,prop25,prop26,prop27,prop28,prop29,events"
	omni.linkTrackEvents="event1,event2,event3,event4,event5,event6,event7,event8,event9,event10,event11"
	
	/* WARNING: Changing the visitor namespace will cause drastic changes
	to how your visitor data is collected.  Changes should only be made
	when instructed to do so by your account manager.*/
	omni.visitorNamespace="cbs"

	return omni;
}

//--------------------------------------------------------
// Initializes omniture vars
VideoTracker.prototype.initOmniture = function() {
	if (this.initializing)
		return false;
		
	if (this.initialized)
		return true;
		
	this.initializing = true;
	if (typeof(s_v_account) == "undefined") {
		this.initializing = false;
		this.initialized = false;
		return false;
	}
	
	/*this.trackingVars["event1"] = this.createTrackingVar(s_v_account);
	this.trackingVars["event2"] = this.createTrackingVar(s_v_account);
	this.trackingVars["event3"] = this.createTrackingVar(s_v_account);
	this.trackingVars["event4"] = this.createTrackingVar(s_v_account);
	this.trackingVars["event5"] = this.createTrackingVar(s_v_account);
	this.trackingVars["event6"] = this.createTrackingVar(s_v_account);
	this.trackingVars["event7"] = this.createTrackingVar(s_v_account);
	this.trackingVars["event8"] = this.createTrackingVar(s_v_account);
	this.trackingVars["event9"] = this.createTrackingVar(s_v_account);
	this.trackingVars["event10"] = this.createTrackingVar(s_v_account);
	this.trackingVars["event11"] = this.createTrackingVar(s_v_account);*/
	
	this.initialized = true;
	this.initializing = false;
	return true;
}

//--------------------------------------------------------
// Calls a omniture from sub HTML page
VideoTracker.prototype.callOmniture = function(events, eVars, props) {
	this.log("track", "callOmniture");
	
	if (!this.initialized) {
		if (!this.initOmniture()) {
			return;
		}
	}
	/*
	var iFrame = this.getIFrameDocument();
	if (!iFrame.forms.controlForm) {
		this.log("track", "callOmniture no form");
		return;
	}
	*/

	var omni = this.trackingVars[events];
	if (!omni) {
		omni = s_v;
	}
	
	// Setup omni
	omni.events = events;
	for (var i=1; i<20; i++) {
		omni["eVar" + i] = eVars[i];
	}
	for (var i=24; i<30; i++) {
		omni["prop" + i] = props[i];
	}
	
	// Call omniture
	if (this.send) {
		omni.tl(true, 'o', 'Video');
		if (this.check) {
			var url = "http://dev.cbs.com/Common/images/steve.gif?events=" + events;
			for (var i=1; i<20; i++) {
				url += "&eVar" + i + "=" + escape(eVars[i]);
			}
			var img = new Image();
			img.src = url;
		}
		if (this.closing) {
			var now = new Date();
			var then = new Date();
			while (now.getTime() > then.getTime() - 500) {
				then = new Date();
			}
		}
	}

	var path = events + ": " + omni.eVar11 + "/" + omni.eVar12 + "/" + omni.eVar13 + "/" + omni.eVar14 + "/" + omni.eVar15 + "/" + omni.eVar16;	
	this.log("track", path);
	
	// Debugging
	if (this.debug) {
		var string = "acct = " + s_v_account + "\n";
		string += "ev = " + omni.events + "\n";
		string += "v1 = " + omni.eVar1 + "\n";
		string += "v2 = " + omni.eVar2 + "\n";
		string += "v3 = " + omni.eVar3 + "\n";
		string += "v4 = " + omni.eVar4 + "\n";
		string += "v5 = " + omni.eVar5 + "\n";
		string += "v6 = " + omni.eVar6 + "\n";
		string += "v7 = " + omni.eVar7 + "\n";
		string += "v8 = " + omni.eVar8 + "\n";
		string += "v9 = " + omni.eVar9 + "\n";
		string += "v10 = " + omni.eVar10 + "\n";
		string += "v11 = " + omni.eVar11 + "\n";
		string += "v12 = " + omni.eVar12 + "\n";
		string += "v13 = " + omni.eVar13 + "\n";
		string += "v14 = " + omni.eVar14 + "\n";
		string += "v15 = " + omni.eVar15 + "\n";
		string += "v16 = " + omni.eVar16 + "\n";
		string += "v17 = " + omni.eVar17 + "\n";
		string += "v18 = " + omni.eVar18 + "\n";
		string += "v19 = " + omni.eVar19 + "\n";
		string += "p24 = " + omni.prop24 + "\n";
		string += "p25 = " + omni.prop25 + "\n";
		string += "p26 = " + omni.prop26 + "\n";
		string += "p27 = " + omni.prop27 + "\n";
		string += "p28 = " + omni.prop28 + "\n";
		string += "p29 = " + omni.prop29 + "\n";
		
		if (this.debug.indexOf("alertAll") >= 0) {
			alert(string);
		}
		if (this.debug.indexOf("alertPath") >= 0) {
			alert(path);
		}
		
		if (this.debug.indexOf("divAll") >= 0) {
			var div;
			if ((events == "event1") || (events == "event2")) {
				div = document.getElementById("clipDiv");
			} else if ((events == "event4") || (events == "event5")) {
				div = document.getElementById("videoDiv");
			} else if ((events == "event6") || (events == "event7")) {
				div = document.getElementById("adDiv");
			}
			if (!div) {
				div = document.getElementById("trackerDiv");
			}
			if (div) {
				div.innerHTML = "<pre>" + string + "</pre>";
			}
		}
		
		if (this.debug.indexOf("divPath") >= 0) {
			var div;
			if ((events == "event1") || (events == "event2")) {
				div = document.getElementById("clipDiv");
			} else if ((events == "event4") || (events == "event5")) {
				div = document.getElementById("videoDiv");
			} else if ((events == "event6") || (events == "event7")) {
				div = document.getElementById("adDiv");
			}
			if (!div) {
				div = document.getElementById("trackerDiv");
			}
			if (div) {
				div.innerHTML = path;
			}
		}

		if (this.debug.indexOf("pathLog") >= 0) {
			var div = document.getElementById("trackerPathDiv");
			if (div) {
				div.innerHTML += path + "<br>";
			}
		}
	}
	/*
	var omnitureCommand = iFrame.forms.controlForm['omnitureCommand'];
	if (omnitureCommand) {
		this.log("track", "callOmniture onclick");
		omnitureCommand.onclick();
		return true;
	} else {
		this.log("track", "callOmniture error");
		return false;
	}
	*/
}



//--------------------------------------------------------------------
// Inserts the iframe into the document
VideoTracker.prototype.print = function(div) {
	this.log("track", "print");
	/*
	if (div) {
		div.innerHTML = '<iframe id="videoTrackerIFrame' + this.objectId + '" height="0" width="0" scrolling="no" frameborder="0" src="' + this.videoPlayer.playerRoot + this.staticDir + '/omni_iframe.html?id=' + this.videoPlayer.objectId + '"></iframe>';
	} else {
		document.write('<iframe id="videoTrackerIFrame' + this.objectId + '" height="0" width="0" scrolling="no" frameborder="0" src="' + this.videoPlayer.playerRoot + this.staticDir + '/omni_iframe.html?id=' + this.videoPlayer.objectId + '"></iframe>');
	}
	*/
}
// Returns the document for the iframe
VideoTracker.prototype.getIFrameDocument = function() {
	//if (this.iFrame == null) {
		this.iFrame = document.getElementById("videoTrackerIFrame" + this.objectId);
	//}
	return this.iFrame.contentWindow.document;
}



//---------------------------------------------------------------
// Initializes minute by minute tracking
VideoTracker.prototype.initTime = function(serverDateString) {
	this.log("track", "initTime " + serverDateString);
  var serverDate = new Date(serverDateString);
  var clientDate = new Date();
  this.dateOffset = clientDate.getTime() - serverDate.getTime();
}

//---------------------------------------------------------------
// Initializes minute by minute tracking
VideoTracker.prototype.initWatchTracking = function(serverDateString) {
	this.initTime(serverDateString);
}
//---------------------------------------------------------------
// Turns on minute by minute tracking
VideoTracker.prototype.enableWatchTracking = function(serverDateString) {
	this.log("track", "enableWatchTracking " + serverDateString);
	this.initWatchTracking(serverDateString);
	this.watchTracking = true;
}

//---------------------------------------------------------------
// Called when video has opened a connect to the server
VideoTracker.prototype.onVideoOpened = function(event, video) {
	// Redundancy checking
	video.startTracked = false;
	video.endTracked = false;

	var adtype;
	if (this.videoPlayer.getParam) {
		adtype = this.videoPlayer.getParam("adtype");
	} else {
		adtype = this.videoPlayer.adType;
	}
	this.log("track", "onVideoOpened " + adtype + " " + video.playFormat + " " + this.videoPlayer.capabilities.scripting[video.playFormat] + " " + this.segmentTracking);
	/*
	if ((adtype.indexOf("pre") >= 0) && (!this.videoPlayer.capabilities.scripting[video.playFormat]) && (!this.segmentTracking)) {
		this.log("track", "adSegment");
		video.adSegment = video.newSegment();
		video.adSegment.adSegment = true;
		video.adSegment.ad = true;
		video.adSegment.id = "ad";
		video.adSegment.title = "Unknown";
		this.onSegmentOpened("onSegmentOpened", video.adSegment);
		this.onSegmentSet("onSegmentSet", video.adSegment);
	}
	*/
}

//---------------------------------------------------------------
// Called when video has it's properties set
VideoTracker.prototype.onVideoSet = function(event, video) {
	// Redundancy checking
	if (video.startTracked) return;
	if (video.endTracked) return;
	video.startTracked = true;
	
	var now = new Date();
	video.durationString = this.getTimeString(video.duration);
	video.startTime = now.getTime();
	video.endTime = null;
	
	var events = "event4";
	if (video.startingTime) events = "event10";
	var eVars = this.getEVars(video, video);
	var props = new Array();
	props[29] = video.videoId;
	this.callOmniture(events, eVars, props);

	video.endTracked = false;

	// If no scripting, call closed immediately
	if ((!this.videoPlayer.capabilities.scripting[this.videoPlayer.format]) && (!video.live)) {
		this.onVideoClosed("onVideoClosed", video);
	}
	
	// Start watch tracking
	if ((this.watchTracking) || (video.watchTracking)) {
		eval("_objects['" + this.objectId + "'].onVideoWatch('onVideoWatch', _objects['" + video.objectId + "'])");
		video.watchId = window.setInterval("_objects['" + this.objectId + "'].onVideoWatch('onVideoWatch', _objects['" + video.objectId + "'])", 60*1000);
	}
}

//---------------------------------------------------------------
// Called when video is closed
VideoTracker.prototype.onVideoClosed = function(event, video) {
	// Check for redundancy
	if (video.endTracked) return;
	video.endTracked = true;
	video.startTracked = false;

	// Ending
	var now = new Date();
	video.endTime = now.getTime();
	
	// Omniture
	var events = "event5";
	if (this.pausing) events = "event11";
	var eVars = this.getEVars(video, video);
	var props = new Array();
	props[24] = eVars[12];
	props[25] = eVars[14];
	props[26] = eVars[16];
	props[27] = eVars[2];
	props[28] = eVars[8];
	this.callOmniture(events, eVars, props);

	// Stop watch tracking	
	if (video.watchId) {
		window.clearInterval(video.watchId);
	}
}

//---------------------------------------------------------------
// Called every minute while a video is being watched
VideoTracker.prototype.onVideoWatch = function(event, video) {
	this.log("track", "onVideoWatch " + this.dateOffset);
	var now = new Date();																 
	var real = new Date(now.getTime() - this.dateOffset - 4*60*60*1000); // WHY 4 ??????
	var gmt = real.toGMTString();
	var values = gmt.split(' ');
	var year = values[3];
	var month = this.months[values[2]];
	if (parseInt(month) < 10) month = "0" + parseInt(month);
	var day = values[1];
	if (parseInt(day) < 10) day = "0" + parseInt(day);
	var time = values[4];
	values = time.split(':');
	var hour = values[0];
	var min = values[1];
	var sec = values[2];
	var dateString = month + '/' + day + '/' + year + ' ' + hour + ':' + min;

	video.durationString = this.getTimeString(video.duration);

	var events = "event3";
	var eVars = this.getEVars(video, video);
	eVars[4] = dateString;
	var props = new Array();
	this.callOmniture(events, eVars, props);
}

//---------------------------------------------------------------
// Called when segment has opened a connect to the server
VideoTracker.prototype.onSegmentOpened = function(event, segment) {
	// Redundancy checking
	segment.startTracked = false;
	segment.endTracked = false;
}

//---------------------------------------------------------------
// Called when segment params have been set
VideoTracker.prototype.onSegmentSet = function(event, segment) {
	// Redundancy checking
	if (segment.endTracked) return;
	if (segment.startTracked) return;
	segment.startTracked = true;
	segment.endTracked = false;

	// Timing
	var now = new Date();
	segment.startTime = now.getTime();
	segment.endTime = null;
	segment.durationString = this.getTimeString(segment.duration);

	// Omniture
	var events = "event1";
	if (segment.video.startingTime) {
		for (var i=0; i<segment.video.segments.length; i++) {
			if (segment.video.segments[i].ad) 
				continue;
			else if (segment.video.segments[i] == segment)
				events = "event8";
			else
				break;
		}
	}
	var eVars = this.getEVars(segment, segment.video);
	var props = new Array();
	props[29] = segment.id || segment.video.videoId;
	if (segment.ad) {
		events = "event6";
		var current = segment.video.getCurrentContentSegmentNum();
		var num = segment.video.getNumContentSegments();
		if (current == 0) {
			eVars[7] = "pre";
		} else if (current < num) {
			eVars[7] = "mid";
		} else {
			eVars[7] = "post";
		}
	}
	this.callOmniture(events, eVars, props);

	// If no scripting, call closed immediately
	if ((!this.videoPlayer.capabilities.scripting[this.videoPlayer.format]) && (!segment.live)) {
		this.onSegmentClosed("onSegmentClosed", segment);
	}
}

//---------------------------------------------------------------
// Called when segment is closed
VideoTracker.prototype.onSegmentClosed = function(event, segment) {
	// Redundancy checking
	if (segment.endTracked) return;
	segment.endTracked = true;
	segment.startTracked = false;
	
	// Timing
	var now = new Date();
	segment.endTime = now.getTime();

	// Omniture		
	var events = "event2";
	if (this.pausing) events = "event9";
	var eVars = this.getEVars(segment, segment.video);
	var props = new Array();
	props[24] = eVars[12];
	props[25] = eVars[14];
	props[26] = eVars[16];
	props[27] = eVars[2];
	props[28] = eVars[8];
	if (segment.ad) {
		events = "event7";
		var current = segment.video.getCurrentContentSegmentNum();
		var num = segment.video.getNumContentSegments();
		if (current == 0) {
			eVars[7] = "pre";
		} else if (current < num) {
			eVars[7] = "mid";
		} else {
			eVars[7] = "post";
		}
	}
	this.callOmniture(events, eVars, props);
}


//---------------------------------------------------------------
// Returns a time string in MM:SS format
VideoTracker.prototype.getTimeString = function(time) {
	var secs = time % 60;
	var mins = Math.floor(time / 60);
	if (secs < 10) {
		return mins + ":0" + secs;
	} else { 
		return mins + ":" + secs;
	}
}

//---------------------------------------------------------------
// Returns a time range string in MM:SS - MM:SS format
VideoTracker.prototype.getTimeRangeString = function(time) {
	if (time < 15) {
		var t = 5*Math.floor(time / 5);
		return t + 5;
		//return this.getTimeString(t) + " - " + this.getTimeString(t+5);
	} else if (time < 300) {
		var t = 15*Math.floor(time / 15);
		return t + 15;
		//return this.getTimeString(t) + " - " + this.getTimeString(t+15);
	} else {
		var t = 60*Math.floor(time / 60);
		return t + 60;
		//return this.getTimeString(t) + " - " + this.getTimeString(t+60);
	}
}

//--------------------------------------------------------------
// Sets all the eVars
VideoTracker.prototype.getEVars = function(content, video) {
	var eVars = new Array();
	
	var id;
	if (content.videoId) 
		id = content.videoId;
	else if (content.id) 
		id = content.id;
	else 
		id = video.videoId;

	// 1 is id and title
	eVars[1] = id + " - " + content.title + " (" + content.durationString + ")";

	// 2 and 3 are duration
	if (content.endTime) {
		if (!this.videoPlayer.capabilities.scripting[this.videoPlayer.format]) {
			eVars[2] = "Unknown";
			eVars[3] = "Unknown";
		} else {
			content.elapsedTime = Math.floor((content.endTime - content.startTime) / 1000);
			var timeWatched;
			if (content.elapsedTime < content.getMaxPosition()) 
				timeWatched = content.elapsedTime;
			else 
				timeWatched = content.getMaxPosition();
	
			eVars[2] = this.getTimeRangeString(timeWatched);
			if ((!content.duration) || (content.duration == 0)) {
				eVars[3] = "0%";
			} else {
				var tenth = Math.round(timeWatched*10 / content.duration);
				if (tenth == 0) {
					eVars[3] = "0%";
				} else {
					eVars[3] = tenth + "0%";
				}
			}
		}
		eVars[5] = this.getTimeRangeString(content.getMaxPosition());
	}
	// 6 is format
	if (content.videoId) {
		eVars[6] = this.videoPlayer.format;
	} else {
		eVars[6] = content.format;
	}
	// 7 is ad type
	
	// 8 is page
	eVars[8] = document.location.pathname;
	if (eVars[8].charAt(eVars[8].length - 1) == '/') {
		eVars[8] += "index";
	} else {
		var p = eVars[8].lastIndexOf('.');
		if (p > 0) {
			eVars[8] = eVars[8].substring(0, p);
		}
	}

	// 9 is hour of day
	if (typeof(this.dateOffset) != "undefined") {
		var now = new Date();																 
		var real = new Date(now.getTime() - this.dateOffset - 4*60*60*1000); // WHY 4 ??????
		var gmt = real.toGMTString();
		var values = gmt.split(' ');
		var time = values[4];
		values = time.split(':');
		var hour = values[0];
		eVars[9] = hour + ':00';
	}
	
	// 11 -> 15 are props
	if (video.props) {
		var propNum = 11;
		for (var i=0; i<video.props.length; i++) {
			eVars[propNum++] = video.props[i];
		}
		var lastProp = eVars[propNum-1];
		while (propNum < 16) {
			eVars[propNum++] = lastProp;
		}
	}
	
	// 16 is title
	eVars[16] = content.title;
	
	return eVars;
}

