//var flashVersions = Math.floor(Math.random()*999999);
var flashVersions = "200910151149";

var DayPortUtils = new Object();

header = new Object();
header.settings = new Object();

//header.settings.controlLink = "/mmp_rci/Controller.aspx";           


header.embedHeader = function()
{

	var settings_string = new String();

	for(var type in header.settings)
	{
		if(header.settings[type] != null)
			settings_string += "&"+type+"=" + escape(header.settings[type]);
	}

	settings_string = settings_string.slice(1);

	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="800" height="50" id="flashHeader" align="middle">\n');
	document.write('<param name="allowScriptAccess" value="always" />\n');
	document.write('<param name="movie" value="/header.swf?v='+flashVersions+'" />\n');
	document.write('<param name="quality" value="high" />\n');
	document.write('<param name="wmode" value="transparent" />\n');
	document.write('<param name="bgcolor" value="#ffffff" />\n');

	document.write('<param name="flashvars" value="'+settings_string+'" />\n');

	document.write('<embed src="/header.swf?v='+flashVersions+'" quality="high" flashvars="'+settings_string+'" wmode="transparent" bgcolor="#ffffff" width="800" height="50" name="header" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n');
	document.write('</object>\n');
	
}
	
	
	
dayportLogo = new Object();
dayportLogo.settings = new Object();        


dayportLogo.embedHeader = function()
{

	var settings_string = new String();

	for(var type in dayportLogo.settings)
	{
		if(dayportLogo.settings[type] != null)
			settings_string += "&"+type+"=" + escape(dayportLogo.settings[type]);
	}

	settings_string = settings_string.slice(1);

	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="140" height="43" id="dayportLogo" align="middle">\n');
	document.write('<param name="allowScriptAccess" value="always" />\n');
	document.write('<param name="movie" value="/logo.swf?v='+flashVersions+'" />\n');
	document.write('<param name="quality" value="high" />\n');
	document.write('<param name="wmode" value="transparent" />\n');
	document.write('<param name="bgcolor" value="#ffffff" />\n');

	document.write('<param name="flashvars" value="'+settings_string+'" />\n');

	document.write('<embed src="/logo.swf?v='+flashVersions+'" quality="high" flashvars="'+settings_string+'" wmode="transparent" bgcolor="#ffffff" width="140" height="43" name="dayportLogo" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n');
	document.write('</object>\n');
	
}



dayportLoader = new Object();
dayportLoader.settings = new Object();        

dayportLoader.embedHeader = function(container,width,height)
{
	if(width == "" || typeof width == "undefined") width="210";
	if(height == "" || typeof height == "undefined") height="250";
	
	var objectPrint;

	objectPrint = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width+'" height="'+height+'" id="dayportLogo" align="middle">\n';
	objectPrint += '<param name="allowScriptAccess" value="always" />\n';
	objectPrint += '<param name="movie" value="/img/designImages/loader.swf?v='+flashVersions+'" />\n';
	objectPrint += '<param name="quality" value="high" />\n';
	objectPrint += '<param name="wmode" value="transparent" />\n';
	objectPrint += '<embed src="/img/designImages/loader.swf?v='+flashVersions+'" quality="high" wmode="transparent" bgcolor="#ffffff" width="'+width+'" height="'+height+'" name="dayportLogo" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n';
	objectPrint += '</object>\n';
	
	document.getElementById(container).innerHTML = objectPrint;
	
}






dayportThumbView = new Object();
dayportThumbView.settings = new Object();        
dayportThumbView.settings.expandPath = "";
dayportThumbView.settings.currentCategory = "";

dayportThumbView.embedHeader = function(container)
{

	var settings_string = new String();

	for(var type in dayportThumbView.settings)
	{
		if(dayportThumbView.settings[type] != null)
			settings_string += "&"+type+"=" + escape(dayportThumbView.settings[type]);
	}

	settings_string = settings_string.slice(1);
	
	var objectDisplay = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="TreeAndThumbnailViewer" width="100%" height="100%" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">';
	objectDisplay += '						<param name="movie" value="/flash/ThumbnailView.swf?rndm='+flashVersions+'" />';
	objectDisplay += '						<param name="quality" value="high" />';
	objectDisplay += '						<param name="bgcolor" value="#ffffff" />';
	objectDisplay += '						<param name="wmode" value="transparent" />';
	objectDisplay += '						<param name="allowScriptAccess" value="sameDomain" />';
	objectDisplay += '						<param name="flashvars" value="'+settings_string+'" />';
	objectDisplay += '						<embed src="/flash/ThumbnailView.swf?rndm='+flashVersions+'" quality="high" bgcolor="#ffffff"';
	objectDisplay += '							width="100%" height="100%" name="thumbviewswf" align="middle"';
	objectDisplay += '							play="true"  wmode="transparent"';
	objectDisplay += '							loop="false"';
	objectDisplay += '							quality="high"';
	objectDisplay += '							flashvars="'+settings_string+'"';
	objectDisplay += '							allowScriptAccess="sameDomain"';
	objectDisplay += '							type="application/x-shockwave-flash"';
	objectDisplay += '							pluginspage="http://www.adobe.com/go/getflashplayer">';
	objectDisplay += '						</embed>';
	objectDisplay += '				</object>';
	
	document.getElementById(container).innerHTML = objectDisplay;
	
}


MRSSFeedDisplay = new Object();
MRSSFeedDisplay.settings = new Object();        


MRSSFeedDisplay.embed = function(container)
{
	var settings_string = new String();

	for(var type in MRSSFeedDisplay.settings)
	{
		if(MRSSFeedDisplay.settings[type] != null)
			settings_string += "&"+type+"=" + escape(MRSSFeedDisplay.settings[type]);
	}

	settings_string = settings_string.slice(1);

	var objectDisplay = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="MRSSFeedAppwfObject" width="100%" height="100%" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">';
	objectDisplay += '<param name="movie" value="/flash/MRSSFeedApplication.swf?rndm='+flashVersions+'" />';
	objectDisplay += '<param name="quality" value="high" />';
	objectDisplay += '<param name="bgcolor" value="#ffffff" />';
	objectDisplay += '<param name="wmode" value="transparent" />';
	objectDisplay += '<param name="allowScriptAccess" value="always" />';
	objectDisplay += '<param name="flashvars" value="'+settings_string+'" />';
	objectDisplay += '<embed src="/flash/MRSSFeedApplication.swf?rndm='+flashVersions+'" quality="high" bgcolor="#ffffff"';
	objectDisplay += ' id="MRSSFeedAppswfObject" width="100%" height="100%" name="" align="middle"';
	objectDisplay += ' play="true"  wmode="transparent"';
	objectDisplay += ' loop="false"';
	objectDisplay += ' quality="high"';
	objectDisplay += ' flashvars="'+settings_string+'"';
	objectDisplay += ' allowScriptAccess="always"';
	objectDisplay += ' type="application/x-shockwave-flash"';
	objectDisplay += ' pluginspage="http://www.adobe.com/go/getflashplayer">';
	objectDisplay += '</embed>';
	objectDisplay += '</object>';
	
	document.getElementById(container).innerHTML = objectDisplay;
}



DPMWizard = new Object();
DPMWizard.settings = new Object();

DPMWizard.embedHeader = function(container)
{

	var settings_string = new String();

	for(var type in DPMWizard.settings)
	{
		if(DPMWizard.settings[type] != null)
			settings_string += "&"+type+"=" + escape(DPMWizard.settings[type]);
	}

	settings_string = settings_string.slice(1);
	
	var objectDisplay = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="DPMWizardswfObject" width="100%" height="100%" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">';
	objectDisplay += '						<param name="movie" value="/DPM.swf?rndm='+flashVersions+'" />';
	objectDisplay += '						<param name="quality" value="high" />';
	objectDisplay += '						<param name="bgcolor" value="#ffffff" />';
	objectDisplay += '						<param name="wmode" value="transparent" />';
	objectDisplay += '						<param name="allowScriptAccess" value="always" />';
	objectDisplay += '						<param name="flashvars" value="'+settings_string+'" />';
	objectDisplay += '						<embed src="/DPM.swf?rndm='+flashVersions+'" quality="high" bgcolor="#ffffff"';
	objectDisplay += '							width="100%" height="100%" name="" align="middle"';
	objectDisplay += '							play="true"  wmode="transparent"';
	objectDisplay += '							loop="false"';
	objectDisplay += '							quality="high"';
	objectDisplay += '							flashvars="'+settings_string+'"';
	objectDisplay += '							allowScriptAccess="always"';
	objectDisplay += '							type="application/x-shockwave-flash"';
	objectDisplay += '							pluginspage="http://www.adobe.com/go/getflashplayer">';
	objectDisplay += '						</embed>';
	objectDisplay += '				</object>';
	
	document.getElementById(container).innerHTML = objectDisplay;
	
}

DayPortSiteTab = new Object();
DayPortSiteTab.settings = new Object();

DayPortSiteTab.embedHeader = function(container)
{

	var settings_string = new String();

	for(var type in DayPortSiteTab.settings)
	{
		if(DayPortSiteTab.settings[type] != null)
			settings_string += "&"+type+"=" + escape(DayPortSiteTab.settings[type]);
	}

	settings_string = settings_string.slice(1);
	
	var objectDisplay = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="DayPortSiteTabswfObject" width="100%" height="100%" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">';
	objectDisplay += '						<param name="movie" value="/DayPortSiteTab.swf?rndm='+flashVersions+'" />';
	objectDisplay += '						<param name="quality" value="high" />';
	objectDisplay += '						<param name="bgcolor" value="#ffffff" />';
	objectDisplay += '						<param name="wmode" value="transparent" />';
	objectDisplay += '						<param name="allowScriptAccess" value="always" />';
	objectDisplay += '						<param name="flashvars" value="'+settings_string+'" />';
	objectDisplay += '						<embed src="/DayPortSiteTab.swf?rndm='+flashVersions+'" quality="high" bgcolor="#ffffff"';
	objectDisplay += '							width="100%" height="100%" name="" align="middle"';
	objectDisplay += '							play="true"  wmode="transparent"';
	objectDisplay += '							loop="false"';
	objectDisplay += '							quality="high"';
	objectDisplay += '							flashvars="'+settings_string+'"';
	objectDisplay += '							allowScriptAccess="always"';
	objectDisplay += '							type="application/x-shockwave-flash"';
	objectDisplay += '							pluginspage="http://www.adobe.com/go/getflashplayer">';
	objectDisplay += '						</embed>';
	objectDisplay += '				</object>';
	
	document.getElementById(container).innerHTML = objectDisplay;
	
}


CustomArticleEdit = new Object();
CustomArticleEdit.videoPlayers = new Object();
CustomArticleEdit.container = "";
CustomArticleEdit.settings = new Object();
CustomArticleEdit.videoPlayerDispatchInterval = 250;
CustomArticleEdit.offsetPos = 0;

CustomArticleEdit.embedHeader = function(container)
{
	this.container = container;
	var settings_string = new String();

	for(var type in CustomArticleEdit.settings)
	{
		if(CustomArticleEdit.settings[type] != null)
			settings_string += "&"+type+"=" + escape(CustomArticleEdit.settings[type]);
	}

	settings_string = settings_string.slice(1);
	
	var objectDisplay = '<div id="CustomArticleEditContainer" style="z-index:1;position:relative;top:0;left:0;width:100%;height:100%;"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="CustomArticleEditswfObject" width="100%" height="100%" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">';
	objectDisplay += '<param name="movie" value="/flash/CustomArticleEdit.swf?rndm='+flashVersions+'" />';
	objectDisplay += '<param name="quality" value="high" />';
	objectDisplay += '<param name="bgcolor" value="#ffffff" />';
	objectDisplay += '<param name="wmode" value="transparent" />';
	objectDisplay += '<param name="allowScriptAccess" value="always" />';
	objectDisplay += '<param name="flashvars" value="'+settings_string+'" />';
	objectDisplay += '<embed src="/flash/CustomArticleEdit.swf?rndm='+flashVersions+'" quality="high" bgcolor="#ffffff"';
	objectDisplay += ' width="100%" height="100%" name="" align="middle"';
	objectDisplay += ' play="true"  wmode="transparent"';
	objectDisplay += ' loop="false"';
	objectDisplay += ' quality="high"';
	objectDisplay += ' flashvars="'+settings_string+'"';
	objectDisplay += ' allowScriptAccess="always"';
	objectDisplay += ' type="application/x-shockwave-flash"';
	objectDisplay += ' pluginspage="http://www.adobe.com/go/getflashplayer">';
	objectDisplay += '</embed>';
	objectDisplay += '</object></div>';
	
	document.getElementById(container).innerHTML = objectDisplay;
	
}

CustomArticleEdit.createVideoPlayer = function(player_x,player_y,videoWidth,videoHeight,autoPlay)
{
	var playerID = Math.floor(Math.random()*99999999999);
	var id = "CustomArticleEditVideoPlayer_"+playerID;
	
	var width = videoWidth;
	var height = videoHeight + 80;

	var tmpObj = document.createElement("object");
	tmpObj.codebase = "http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0";
	tmpObj.width = width;
	tmpObj.height = height;
	tmpObj.id = id;
	
	var paramObj = document.createElement("param");
	paramObj.name = "AutoStart";
	paramObj.value =  autoPlay;
	tmpObj.appendChild(paramObj);
	
	var paramObj = document.createElement("param");
	paramObj.name = "AutoSize";
	paramObj.value =  false;
	tmpObj.appendChild(paramObj);
	
	var paramObj = document.createElement("param");
	paramObj.name = "AllowChangeDisplaySize";
	paramObj.value =  false;
	tmpObj.appendChild(paramObj);
		
	var paramObj = document.createElement("param");
	paramObj.name = "enableContextMenu";
	paramObj.value =  false;
	tmpObj.appendChild(paramObj);
	
	var paramObj = document.createElement("param");
	paramObj.name = "windowlessVideo";
	paramObj.value =  true;
	tmpObj.appendChild(paramObj);
	
	var paramObj = document.createElement("param");
	paramObj.name = "ShowControls";
	paramObj.value =  true;
	tmpObj.appendChild(paramObj);
	
	//external interface fix for IE
	window[tmpObj.id] = tmpObj;
	
	//let browser create object
	tmpObj.classid = "clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6";
	
	var newdiv = document.createElement('div');
	newdiv.setAttribute('id', "CustomArticleEditVideoPlayerContainer_"+playerID);

	newdiv.style.position = "absolute";
	newdiv.style.left = player_x + document.getElementById(this.container).offsetLeft;
	newdiv.style.top = player_y + document.getElementById(this.container).offsetTop + 65; //65 for header height since we are not using iframes
	newdiv.style.zIndex = 0;
	newdiv.style.width = width;
	newdiv.style.height = height;
	newdiv.style.overflow = "hidden";
	
	document.getElementById(this.container).appendChild(newdiv);
	newdiv.appendChild(tmpObj);
	
	var playerObject = new Object();
	playerObject.player = document.getElementById(id);
	playerObject.intervalID = -1;
	playerObject.intervalStopped = false;
	
	this.videoPlayers[id] = playerObject;
	
	//set event listeners to player here
	var scriptObj = document.createElement("script");
	scriptObj.setAttribute("language", "JScript");
	scriptObj.htmlFor = id;
	scriptObj.setAttribute("event", "playStateChange(NewState)");
	scriptObj.text = "CustomArticleEdit.playerListenerPlayStateChange(NewState, '" + id + "');";
	
	newdiv.appendChild(scriptObj);
	
	var scriptObj2 = document.createElement("script");
	scriptObj2.setAttribute("language", "JScript");
	scriptObj2.htmlFor = id;
	scriptObj2.setAttribute("event", "positionChange(oldPosition, newPosition)");
	scriptObj2.text = "CustomArticleEdit.playerListenerPositionChange(oldPosition, newPosition, '" + id + "');";
	
	newdiv.appendChild(scriptObj2);
	
	return playerID;
}

CustomArticleEdit.moveVideoPlayer = function (playerID, player_x, player_y, videoWidth, videoHeight)
{
	var playerIn = document.getElementById("CustomArticleEditVideoPlayerContainer_"+playerID);
	
	var width = videoWidth;
	var height = videoHeight + 80;
	
	playerIn.style.left = player_x + document.getElementById(this.container).offsetLeft;
	playerIn.style.top = player_y + document.getElementById(this.container).offsetTop + 65; //65 for header height since we are not using iframes
	playerIn.style.zIndex = 0;
	playerIn.style.width = width;
	playerIn.style.height = height;
}

CustomArticleEdit.playVideo = function(playerID,videoURL)
{
	var playerIn = document.getElementById("CustomArticleEditVideoPlayer_"+playerID);
	
	if(videoURL == "null" || videoURL == null)
	{
		playerIn.URL = playerIn.URL;
		playerIn.controls.stop();	
		playerIn.enabled = false;
		CustomArticleEdit.offsetPos = 0;
	}else{
		playerIn.enabled = true;
		playerIn.URL = videoURL;
		var timeInIndex = videoURL.indexOf("TimeIn=");
		
		if(timeInIndex > -1)
		{
			try
			{
				var offsetString = videoURL.substring(timeInIndex+7, timeInIndex+15);
				
				var timecodearray = offsetString.split(":");
				offsettimesec = (((parseInt(timecodearray[0]) * 60) + parseInt(timecodearray[1])) * 60) + parseInt(timecodearray[2]);
				CustomArticleEdit.offsetPos = parseInt(offsettimesec);
			}
			catch(e)
			{
				CustomArticleEdit.offsetPos = 0;
			}
		}
		else
		{
			CustomArticleEdit.offsetPos = 0;
		}		
	}
}

CustomArticleEdit.playNow = function(playerID)
{
	var playerIn = document.getElementById("CustomArticleEditVideoPlayer_"+playerID);
	
	playerIn.controls.play();
}

CustomArticleEdit.stopNow = function(playerID)
{
	var playerIn = document.getElementById("CustomArticleEditVideoPlayer_"+playerID);
	
	playerIn.controls.stop();
}

CustomArticleEdit.pauseNow = function(playerID)
{
	var playerIn = document.getElementById("CustomArticleEditVideoPlayer_"+playerID);
	
	playerIn.controls.pause();
}

CustomArticleEdit.seek = function(playerID, position)
{
	var playerIn = document.getElementById("CustomArticleEditVideoPlayer_"+playerID);
	
	if(position != null && position > -1)
	{
		playerIn.controls.currentPosition = position - CustomArticleEdit.offsetPos;
	}
}

CustomArticleEdit.showPlayer = function(playerID)
{
	var playerCT = document.getElementById("CustomArticleEditVideoPlayerContainer_"+playerID);
	var playerObj = document.getElementById("CustomArticleEditVideoPlayer_"+playerID);
	
	playerObj.style.visibility = "visible";
}

CustomArticleEdit.hidePlayer = function(playerID)
{
	var playerCT = document.getElementById("CustomArticleEditVideoPlayerContainer_"+playerID);
	var playerObj = document.getElementById("CustomArticleEditVideoPlayer_"+playerID);
	
	playerObj.style.visibility = "hidden";
}

CustomArticleEdit.removePlayer = function(playerID)
{
	var playerCT = document.getElementById("CustomArticleEditVideoPlayerContainer_"+playerID);
	var playerObj = document.getElementById("CustomArticleEditVideoPlayer_"+playerID);
	var maincontainer = document.getElementById(this.container);
	
	playerObj.controls.stop();
	
	playerCT.innerHTML = "";
	//remove player
	playerCT.removeChild(playerObj);
	//remove player div container
	maincontainer.removeChild(playerCT);	
}

CustomArticleEdit.getPosition = function(playerID)
{
	var playerIn = document.getElementById("CustomArticleEditVideoPlayer_"+playerID);
	var currentPos = playerIn.controls.currentPosition;
	currentPos += CustomArticleEdit.offsetPos;
	return currentPos;
}

CustomArticleEdit.priorityPlayer = function(playerID)
{	
	var playerCT = document.getElementById("CustomArticleEditVideoPlayerContainer_"+playerID);
	var playerObj = document.getElementById("CustomArticleEditVideoPlayer_"+playerID);
	var flashCT = document.getElementById("CustomArticleEditContainer");
	var flashObj = document.getElementById("CustomArticleEditswfObject");
	
	playerCT.style.zIndex = flashCT.style.zIndex + 1;
	playerObj.style.zIndex = playerCT.style.zIndex;
}

CustomArticleEdit.priorityFlash = function(playerID)
{
	var playerCT = document.getElementById("CustomArticleEditVideoPlayerContainer_"+playerID);
	var playerObj = document.getElementById("CustomArticleEditVideoPlayer_"+playerID);
	var flashCT = document.getElementById("CustomArticleEditContainer");
	var flashObj = document.getElementById("CustomArticleEditswfObject");

	playerCT.style.zIndex = 0;
	flashCT.style.zIndex = playerCT.style.zIndex + 1000;
	flashObj.style.zIndex = flashCT.style.zIndex;
}

CustomArticleEdit.startEventDispatcherTimer = function(playerID)
{
	//need to set timer on player
	var playerObject = this.videoPlayers[playerID];
	
	//check to see if timer is already going
	if(!playerObject.intervalStopped)
	{
		return false;
	}
	
	playerObject.intervalStopped = false;
	
	playerObject.intervalID = window.setInterval(
													function()
													{
														CustomArticleEdit.dispatchPositionChangeEvent(playerID);
													},
													CustomArticleEdit.videoPlayerDispatchInterval
												);
}

CustomArticleEdit.stopEventDispatcherTimer = function(playerID)
{
	//need to set timer on player
	var playerObject = this.videoPlayers[playerID];
	
	playerObject.intervalStopped = true;
	
	window.clearInterval(playerObject.intervalID);
	
	playerObject.intervalID = null;
}

CustomArticleEdit.dispatchPositionChangeEvent = function(playerID)
{
	//var playerIn = document.getElementById("CustomArticleEditVideoPlayer_"+playerID);
	var playerIn = document.getElementById(playerID);
	
	if(playerIn !== null && playerIn !== undefined)
	{
		if(playerIn.controls !== null && playerIn.controls !== undefined)
		{
			if(playerIn.controls.currentPosition !== null && playerIn.controls.currentPosition !== undefined)
			{
				var paramData = new Object();
				paramData.position = playerIn.controls.currentPosition;
				
				//dispatch event and pass along new position value in a generic data object
				var flashObj = document.getElementById("CustomArticleEditswfObject");
				flashObj.sendVideoPlayerEvent("PositionChange", paramData);
			}
		}
	}
}

CustomArticleEdit.playerListenerPlayStateChange = function(newState, playerID)
{
	// Handle PlayState change
	switch (newState)
	{
		case 0:
		// Undefined (Windows Media Player is in an undefined state.)
		break;
		
		case 1:
		// Stopped (Playback of the current media item is stopped.)
		// Raise OnStopped event
		CustomArticleEdit.stopEventDispatcherTimer(playerID);
		break;
		
		case 2:
		// Paused (Playback of the current media item is paused. When a media item is paused, resuming playback begins from the same location.)
		// Raise OnPaused event
		CustomArticleEdit.stopEventDispatcherTimer(playerID);
		break;
		
		case 3:
		// Playing (The current media item is playing.)
		// Raise OnPlaying event
		CustomArticleEdit.startEventDispatcherTimer(playerID);
		break;
		
		case 4:
		// ScanForward (The current media item is fast forwarding.)
		// Raise OnFastForwarding event
		CustomArticleEdit.startEventDispatcherTimer(playerID);
		break;
		
		case 5:
		// ScanReverse (The current media item is fast rewinding.)
		// Raise OnFastReversing event
		CustomArticleEdit.startEventDispatcherTimer(playerID);
		break;
		
		case 6:
		// Buffering (The current media item is getting additional data from the server.)
		break;
		
		case 7:
		// Waiting (Connection is established, but the server is not sending data. Waiting for session to begin.)
		break;
		
		case 8:
		// MediaEnded (Media item has completed playback.)
		// Raise OnMediaEnded event
		CustomArticleEdit.stopEventDispatcherTimer(playerID);
		break;
		
		case 9:
		// Transitioning (Preparing new media item.)
		// Raise OnTransitioning event
		break;
		
		case 10:
		
		// Ready (Ready to begin playing.)
		CustomArticleEdit.stopEventDispatcherTimer(playerID);
		break;
		
		case 11:
		// Reconnecting (Reconnecting to stream.)
		break;
		
		default:
	}
}

CustomArticleEdit.playerListenerPositionChange = function(oldPosition, newPosition, playerID)
{
	CustomArticleEdit.dispatchPositionChangeEvent(playerID);
}

CustomArticleEdit.playState = function(playerID, code)
{
	var playerIn = document.getElementById("CustomArticleEditVideoPlayer_"+playerID);
	
	if(code == "true")
	{
		return playerIn.playState;
	}
	else
	{
		switch (playerIn.playState)
		{
			case 0:
				// New in wmp7.0
				return "undefined";
				break;
			case 1:
				// wmp 6.4 was 0
				// wmp 7.0 is now 1
				return "stopped";
				break;
			case 2:
				// wmp 6.4 was 1
				// wmp 7.0 is now 2
				return "paused";
				break;
			case 3:
				// wmp 6.4 was 2
				// wmp 7.0 is now 3
				return "playing";
				break;
			case 4:
				// wmp 6.4 was 4
				// wmp 7.0 is now 4
				return "scanforward";
				break;
			case 5:
				// wmp 6.4 was 5
				// wmp 7.0 is now 5
				return "scanreverse";
				break;
			case 6:
				// New to wmp 7.0
				return "buffering";
				break;
			case 7:
				// wmp 6.4 was 3
				// wmp 7.0 is now 7
				return "waiting";
				break;
			case 8:
				// new to wmp7.0
				return "mediaended";
				break;
			case 9:
				// new to wmp7.0
				return "transitioning";
				break;
			case 10:
				// new to wmp7.0
				return "ready";
				break;
			case 11:
				// new to wmp7.0
				return "reconnecting";
				break;		
		}
	}
	
	return -1;
}

CustomArticleEdit.articlePreview = function(title, htmlContents, width, height)
{
	if(typeof(width) == "undefined" || width == "" || width < 0)
	{
		width = 400;
	}
	
	if(typeof(height) == "undefined" || height == "" || height < 0)
	{
		height = 600;
	}
	
	//previewWindow = window.open('',title,'menubar=yes,titlebar=no,resizable=yes,scrollbars=yes,fullscreen=no,height=600,width=400');
	previewWindow = window.open('','ArticleReport','menubar=yes,titlebar=no,resizable=yes,scrollbars=yes,fullscreen=no,height='+height+',width='+width);
	previewWindow.document.write(htmlContents);
	previewWindow.focus();
	
	return true;
}
/*
CustomArticleEdit = new Object();
CustomArticleEdit.videoPlayers = new Array();
CustomArticleEdit.container = "";
CustomArticleEdit.dummyMov = "http://img.dayport.com/video/dummy.mov";
CustomArticleEdit.settings = new Object();

CustomArticleEdit.embedHeader = function(container)
{
	this.container = container;
	var settings_string = new String();

	for(var type in CustomArticleEdit.settings)
	{
		if(CustomArticleEdit.settings[type] != null)
			settings_string += "&"+type+"=" + escape(CustomArticleEdit.settings[type]);
	}

	settings_string = settings_string.slice(1);
	
	var objectDisplay = '<div id="CustomArticleEditContainer" style="z-index:1;position:relative;top:0;left:0;width:100%;height:100%;"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="CustomArticleEditswfObject" width="100%" height="100%" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">';
	objectDisplay += '<param name="movie" value="/CustomArticleEdit.swf?rndm='+flashVersions+'" />';
	objectDisplay += '<param name="quality" value="high" />';
	objectDisplay += '<param name="bgcolor" value="#ffffff" />';
	objectDisplay += '<param name="wmode" value="transparent" />';
	objectDisplay += '<param name="allowScriptAccess" value="always" />';
	objectDisplay += '<param name="flashvars" value="'+settings_string+'" />';
	objectDisplay += '<embed src="/CustomArticleEdit.swf?rndm='+flashVersions+'" quality="high" bgcolor="#ffffff"';
	objectDisplay += ' width="100%" height="100%" name="" align="middle"';
	objectDisplay += ' play="true"  wmode="transparent"';
	objectDisplay += ' loop="false"';
	objectDisplay += ' quality="high"';
	objectDisplay += ' flashvars="'+settings_string+'"';
	objectDisplay += ' allowScriptAccess="always"';
	objectDisplay += ' type="application/x-shockwave-flash"';
	objectDisplay += ' pluginspage="http://www.adobe.com/go/getflashplayer">';
	objectDisplay += '</embed>';
	objectDisplay += '</object></div>';
	
	document.getElementById(container).innerHTML = objectDisplay;
	
}

CustomArticleEdit.createVideoPlayer = function(player_x,player_y,videoWidth,videoHeight,autoPlay)
{
	var playerID = Math.floor(Math.random()*99999999999);
	var id = "CustomArticleEditVideoPlayer_"+playerID;
	
	var width = videoWidth;
	var height = videoHeight;
	
	//padding for controls
	if(DayPortUtils.system.browser == "Internet Explorer")
	{
		height += 80;
	}
	
	var newdiv = document.createElement('div');
	newdiv.setAttribute('id', "CustomArticleEditVideoPlayerContainer_"+playerID);

	newdiv.style.position = "absolute";
	newdiv.style.left = player_x + document.getElementById(this.container).offsetLeft;
	newdiv.style.top = player_y + document.getElementById(this.container).offsetTop + 65; //65 for header height since we are not using iframes
	
	if(DayPortUtils.system.browser == "Safari")
	{
		newdiv.style.top = player_y + document.getElementById(this.container).offsetTop + 150; //85 for header height since we are not using iframes
	}
	
	newdiv.style.zIndex = 0;
	newdiv.style.width = width;
	newdiv.style.height = height;
	newdiv.style.overflow = "hidden";
	//newdiv.style.border = "1px solid #000000";
	
	if(DayPortUtils.system.browser == "Internet Explorer")
	{

		var tmpObj = document.createElement("object");
		tmpObj.codebase = "http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0";
		tmpObj.width = width;
		tmpObj.height = height;
		tmpObj.id = id;
		
		var paramObj = document.createElement("param");
		paramObj.name = "AutoStart";
		paramObj.value =  autoPlay;
		tmpObj.appendChild(paramObj);
	
		var paramObj = document.createElement("param");
		paramObj.name = "enableContextMenu";
		paramObj.value =  false;
		tmpObj.appendChild(paramObj);
		
		var paramObj = document.createElement("param");
		paramObj.name = "windowlessVideo";
		paramObj.value =  true;
		tmpObj.appendChild(paramObj);
		
		var paramObj = document.createElement("param");
		paramObj.name = "strechToFit";
		paramObj.value =  true;
		tmpObj.appendChild(paramObj);
						
		//external interface fix for IE
		window[tmpObj.id] = tmpObj;
		
		//let browser create object
		tmpObj.classid = "clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6";
		
		
		document.getElementById(this.container).appendChild(newdiv);
		
		newdiv.appendChild(tmpObj);
	}
	else
	{
		var embedString = '<EMBED type="video/quicktime" '+
		'pluginspage = "http://www.apple.com/quicktime/download/" '+
		'EnableJavaScript="true" '+
		'SRC="'+CustomArticleEdit.dummyMov+'" '+
		'id="'+id+'" '+
		'height="'+height+'" width="'+width+'" '+
		'enablejavascript="true" ' +
		'controller="true" '+
		'saveembedtags="true" '+
		'scale="Aspect"> '+
		'</EMBED>';
		/*var tmpObj = document.createElement("embed");
		tmpObj.type = "application/x-mplayer2";
		tmpObj.URL="mms://10.0.0.45/0001/20090115154000_12567.wmv"
		tmpObj.width = width;
		tmpObj.AutoStart = autoPlay;
		tmpObj.AutoSize = false;
		tmpObj.AllowChangeDisplaySize = false;
		tmpObj.enableContextMenu = false;
		tmpObj.windowlessVideo = true;
		tmpObj.ShowControls = true;	* /
		
		newdiv.innerHTML = embedString;
		
		document.getElementById(this.container).appendChild(newdiv);
	}
	
	
	
	
	this.videoPlayers[this.videoPlayers.length] = document.getElementById(id);
	
	return playerID;
}

CustomArticleEdit.playVideo = function(playerID,videoURL)
{
	var playerIn = document.getElementById("CustomArticleEditVideoPlayer_"+playerID);
	
	if(videoURL == "null" || videoURL == null)
	{
		if(DayPortUtils.system.browser == "Internet Explorer")
		{
			playerIn.URL = playerIn.URL;
			playerIn.controls.stop();	
			playerIn.enabled = false;
		}
		else
		{
			playerIn.SetURL(CustomArticleEdit.dummyMov);
			playerIn.Stop();
		}
	}else{
		
		if(DayPortUtils.system.browser == "Internet Explorer")
		{
			playerIn.enabled = true;
			playerIn.URL = videoURL;
		}
		else
		{		
			playerIn.SetURL(videoURL);
			playerIn.SetAutoPlay(false);
		}
	}
}

CustomArticleEdit.playNow = function(playerID)
{
	var playerIn = document.getElementById("CustomArticleEditVideoPlayer_"+playerID);
	
	playerIn.controls.play();
}

CustomArticleEdit.stopNow = function(playerID)
{
	var playerIn = document.getElementById("CustomArticleEditVideoPlayer_"+playerID);
	
	playerIn.controls.stop();
}

CustomArticleEdit.pauseNow = function(playerID)
{
	var playerIn = document.getElementById("CustomArticleEditVideoPlayer_"+playerID);
	
	playerIn.controls.pause();
}

CustomArticleEdit.seek = function(playerID,position)
{
	var playerIn = document.getElementById("CustomArticleEditVideoPlayer_"+playerID);
	
	if(position != null && position > -1)
	{
		playerIn.controls.currentPosition = position;
	}
}

CustomArticleEdit.removePlayer = function(playerID)
{
	var playerCT = document.getElementById("CustomArticleEditVideoPlayerContainer_"+playerID);
	var playerObj = document.getElementById("CustomArticleEditVideoPlayer_"+playerID);
	var playerIn = document.getElementById("CustomArticleEditVideoPlayer_"+playerID);
	var maincontainer = document.getElementById(this.container);
	
	if(DayPortUtils.system.browser == "Safari")
	{
		playerIn.style.display = 'none';
		playerIn.SetURL(null);
	}
	else
	{
		playerObj.controls.stop();
	}
	
	//remove player
	playerCT.removeChild(playerObj);
	playerCT.innerHTML = "";
	
	//remove player div container
	maincontainer.removeChild(playerCT);
	
	playerCT.innerHTML = "";	
}

CustomArticleEdit.getPosition = function(playerID)
{
	var playerIn = document.getElementById("CustomArticleEditVideoPlayer_"+playerID);
	
	var returnTime = 0;
	if(DayPortUtils.system.browser == "Safari")
	{
		returnTime = playerIn.GetTime() / playerIn.GetTimeScale();	
	}
	else
	{
		returnTime = playerIn.controls.currentPosition;
	}
	
	return returnTime;
}

CustomArticleEdit.priorityPlayer = function(playerID)
{	
	var playerCT = document.getElementById("CustomArticleEditVideoPlayerContainer_"+playerID);
	var playerObj = document.getElementById("CustomArticleEditVideoPlayer_"+playerID);
	var flashCT = document.getElementById("CustomArticleEditContainer");
	var flashObj = document.getElementById("CustomArticleEditswfObject");
	
	playerCT.style.zIndex = flashCT.style.zIndex + 1;
	playerObj.style.zIndex = playerCT.style.zIndex;
}

CustomArticleEdit.priorityFlash = function(playerID)
{
	var playerCT = document.getElementById("CustomArticleEditVideoPlayerContainer_"+playerID);
	var playerObj = document.getElementById("CustomArticleEditVideoPlayer_"+playerID);
	var flashCT = document.getElementById("CustomArticleEditContainer");
	var flashObj = document.getElementById("CustomArticleEditswfObject");

	playerCT.style.zIndex = 0;
	flashCT.style.zIndex = playerCT.style.zIndex + 1000;
	flashObj.style.zIndex = flashCT.style.zIndex;
}

CustomArticleEdit.playState = function(playerID, code)
{
	var playerIn = document.getElementById("CustomArticleEditVideoPlayer_"+playerID);
	
	if(code == "true")
	{
		return playerIn.playState;
	}
	else
	{
		switch (playerIn.playState)
		{
			case 0:
				// New in wmp7.0
				return "undefined";
				break;
			case 1:
				// wmp 6.4 was 0
				// wmp 7.0 is now 1
				return "stopped";
				break;
			case 2:
				// wmp 6.4 was 1
				// wmp 7.0 is now 2
				return "paused";
				break;
			case 3:
				// wmp 6.4 was 2
				// wmp 7.0 is now 3
				return "playing";
				break;
			case 4:
				// wmp 6.4 was 4
				// wmp 7.0 is now 4
				return "scanforward";
				break;
			case 5:
				// wmp 6.4 was 5
				// wmp 7.0 is now 5
				return "scanreverse";
				break;
			case 6:
				// New to wmp 7.0
				return "buffering";
				break;
			case 7:
				// wmp 6.4 was 3
				// wmp 7.0 is now 7
				return "waiting";
				break;
			case 8:
				// new to wmp7.0
				return "mediaended";
				break;
			case 9:
				// new to wmp7.0
				return "transitioning";
				break;
			case 10:
				// new to wmp7.0
				return "ready";
				break;
			case 11:
				// new to wmp7.0
				return "reconnecting";
				break;		
		}
	}
	
	return -1;
}
*/
CustomArticleEditAdmin = new Object();
CustomArticleEditAdmin.settings = new Object();

CustomArticleEditAdmin.embedHeader = function(container)
{

	var settings_string = new String();

	for(var type in CustomArticleEditAdmin.settings)
	{
		if(CustomArticleEditAdmin.settings[type] != null)
			settings_string += "&"+type+"=" + escape(CustomArticleEditAdmin.settings[type]);
	}

	settings_string = settings_string.slice(1);
	
	var objectDisplay = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="DPMWizardswfObject" width="100%" height="100%" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">';
	objectDisplay += '						<param name="movie" value="/ArticleEditAdministration.swf?rndm='+flashVersions+'" />';
	objectDisplay += '						<param name="quality" value="high" />';
	objectDisplay += '						<param name="bgcolor" value="#ffffff" />';
	objectDisplay += '						<param name="wmode" value="transparent" />';
	objectDisplay += '						<param name="allowScriptAccess" value="always" />';
	objectDisplay += '						<param name="flashvars" value="'+settings_string+'" />';
	objectDisplay += '						<embed src="/ArticleEditAdministration.swf?rndm='+flashVersions+'" quality="high" bgcolor="#ffffff"';
	objectDisplay += '							width="100%" height="100%" name="" align="middle"';
	objectDisplay += '							play="true"  wmode="transparent"';
	objectDisplay += '							loop="false"';
	objectDisplay += '							quality="high"';
	objectDisplay += '							flashvars="'+settings_string+'"';
	objectDisplay += '							allowScriptAccess="always"';
	objectDisplay += '							type="application/x-shockwave-flash"';
	objectDisplay += '							pluginspage="http://www.adobe.com/go/getflashplayer">';
	objectDisplay += '						</embed>';
	objectDisplay += '				</object>';
	
	document.getElementById(container).innerHTML = objectDisplay;
	
}



XMLUserDef = new Object();
XMLUserDef.settings = new Object();

XMLUserDef.embedHeader = function(container)
{

	var settings_string = new String();

	for(var type in XMLUserDef.settings)
	{
		if(XMLUserDef.settings[type] != null)
			settings_string += "&"+type+"=" + escape(XMLUserDef.settings[type]);
	}

	settings_string = settings_string.slice(1);
	
	var objectDisplay = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="XMLUserDefswfObject" width="100%" height="100%" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">';
	objectDisplay += '						<param name="movie" value="/XMLUserDef.swf?rndm='+flashVersions+'" />';
	objectDisplay += '						<param name="quality" value="high" />';
	objectDisplay += '						<param name="bgcolor" value="#ffffff" />';
	objectDisplay += '						<param name="wmode" value="transparent" />';
	objectDisplay += '						<param name="allowScriptAccess" value="always" />';
	objectDisplay += '						<param name="flashvars" value="'+settings_string+'" />';
	objectDisplay += '						<embed src="/XMLUserDef.swf?rndm='+flashVersions+'" quality="high" bgcolor="#ffffff"';
	objectDisplay += '							width="100%" height="100%" name="" align="middle"';
	objectDisplay += '							play="true"  wmode="transparent"';
	objectDisplay += '							loop="false"';
	objectDisplay += '							quality="high"';
	objectDisplay += '							flashvars="'+settings_string+'"';
	objectDisplay += '							allowScriptAccess="always"';
	objectDisplay += '							type="application/x-shockwave-flash"';
	objectDisplay += '							pluginspage="http://www.adobe.com/go/getflashplayer">';
	objectDisplay += '						</embed>';
	objectDisplay += '				</object>';
	
	document.getElementById(container).innerHTML = objectDisplay;
	
}

dayportAssetThumbViewer = new Object();
dayportAssetThumbViewer.settings = new Object();        

dayportAssetThumbViewer.embedHeader = function(container)
{

	var settings_string = new String();

	for(var type in dayportAssetThumbViewer.settings)
	{
		if(dayportAssetThumbViewer.settings[type] != null)
			settings_string += "&"+type+"=" + escape(dayportAssetThumbViewer.settings[type]);
	}

	settings_string = settings_string.slice(1);
	
	var objectDisplay = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="TreeAndThumbnailViewer" width="100%" height="100%" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">';
	objectDisplay += '						<param name="movie" value="/article/thumbnails.swf?rndm='+flashVersions+'" />';
	objectDisplay += '						<param name="quality" value="high" />';
	objectDisplay += '						<param name="bgcolor" value="#ffffff" />';
	objectDisplay += '						<param name="wmode" value="transparent" />';
	objectDisplay += '						<param name="allowScriptAccess" value="sameDomain" />';
	objectDisplay += '						<param name="flashvars" value="'+settings_string+'" />';
	objectDisplay += '						<embed src="/article/thumbnails?rndm='+flashVersions+'" quality="high" bgcolor="#ffffff"';
	objectDisplay += '							width="100%" height="100%" name="AssetThumbViewerswf" align="middle" wmode="transparent"';
	objectDisplay += '							play="true"';
	objectDisplay += '							loop="false"';
	objectDisplay += '							quality="high"';
	objectDisplay += '							flashvars="'+settings_string+'"';
	objectDisplay += '							allowScriptAccess="sameDomain"';
	objectDisplay += '							type="application/x-shockwave-flash"';
	objectDisplay += '							pluginspage="http://www.adobe.com/go/getflashplayer">';
	objectDisplay += '						</embed>';
	objectDisplay += '				</object>';
	
	document.getElementById(container).innerHTML = objectDisplay;
	
}

PolicyMgr = new Object();
PolicyMgr.settings = new Object();

PolicyMgr.embedHeader = function(container)
{

	var settings_string = new String();

	for(var type in PolicyMgr.settings)
	{
		if(PolicyMgr.settings[type] != null)
			settings_string += "&"+type+"=" + escape(PolicyMgr.settings[type]);
	}

	settings_string = settings_string.slice(1);
	
	var objectDisplay = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="DPMWizardswfObject" width="100%" height="100%" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">';
	objectDisplay += '						<param name="movie" value="/policymgr/PolicyGroupEditor.swf?rndm='+flashVersions+'" />';
	objectDisplay += '						<param name="quality" value="high" />';
	objectDisplay += '						<param name="bgcolor" value="#ffffff" />';
	objectDisplay += '						<param name="wmode" value="transparent" />';
	objectDisplay += '						<param name="allowScriptAccess" value="always" />';
	objectDisplay += '						<param name="flashvars" value="'+settings_string+'" />';
	objectDisplay += '						<embed src="/policymgr/PolicyGroupEditor.swf?rndm='+flashVersions+'" quality="high" bgcolor="#ffffff"';
	objectDisplay += '							width="100%" height="100%" name="" align="middle"';
	objectDisplay += '							play="true"  wmode="transparent"';
	objectDisplay += '							loop="false"';
	objectDisplay += '							quality="high"';
	objectDisplay += '							flashvars="'+settings_string+'"';
	objectDisplay += '							allowScriptAccess="always"';
	objectDisplay += '							type="application/x-shockwave-flash"';
	objectDisplay += '							pluginspage="http://www.adobe.com/go/getflashplayer">';
	objectDisplay += '						</embed>';
	objectDisplay += '				</object>';
	
	document.getElementById(container).innerHTML = objectDisplay;
	
}


DayPortUtils.system = new Object();
DayPortUtils.system.osPlatform = null;
DayPortUtils.system.osVersion = null;
DayPortUtils.system.browser = null;
DayPortUtils.system.browserVersion = null;

DayPortUtils.systemCheck = function()
{
  //document.getElementById("debugTA").value += "\nDayPortUtils.systemCheck() called.";

  var osPlatform = "unknown";
  var osVersion = "unknown";
  var browser = "unknown";
  var browserVersion;

  // convert all characters to lowercase to simplify testing
  var agt=navigator.userAgent.toLowerCase();
  var appVer = navigator.appVersion.toLowerCase();

  // *** BROWSER VERSION ***

  var is_minor = parseFloat(appVer);
  var is_major = parseInt(is_minor);

  var is_opera = (agt.indexOf("opera") != -1);
  var is_opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
  var is_opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
  var is_opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
  var is_opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
  var is_opera6 = (agt.indexOf("opera 6") != -1 || agt.indexOf("opera/6") != -1); // new 020128- abk
  var is_opera7 = (agt.indexOf("opera 7") != -1 || agt.indexOf("opera/7") != -1); // new 021205- dmr
  var is_opera5up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4);
  var is_opera6up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4 && !is_opera5); // new020128
  var is_opera7up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4 && !is_opera5 && !is_opera6); // new021205 -- dmr

  // Note: On IE, start of appVersion return 3 or 4
  // which supposedly is the version of Netscape it is compatible with.
  // So we look for the real version further on in the string
  // And on Mac IE5+, we look for is_minor in the ua; since
  // it appears to be more accurate than appVersion - 06/17/2004

  var is_mac = (agt.indexOf("mac")!=-1);
  var iePos  = appVer.indexOf('msie');
  if (iePos !=-1) {
     if(is_mac) {
         var iePos = agt.indexOf('msie');
         is_minor = parseFloat(agt.substring(iePos+5,agt.indexOf(';',iePos)));
     }
     else is_minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)));
     is_major = parseInt(is_minor);
  }

  // ditto Konqueror

  var is_konq = false;
  var kqPos   = agt.indexOf('konqueror');
  if (kqPos !=-1) {
     is_konq  = true;
     is_minor = parseFloat(agt.substring(kqPos+10,agt.indexOf(';',kqPos)));
     is_major = parseInt(is_minor);
  }

  var is_safari = ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1))?true:false;
  var is_khtml  = (is_safari || is_konq);

  var is_gecko = ((!is_khtml)&&(navigator.product)&&(navigator.product.toLowerCase()=="gecko"))?true:false;
  var is_gver  = 0;
  if (is_gecko) is_gver=navigator.productSub;

  var is_moz   = ((agt.indexOf('mozilla/5')!=-1) && (agt.indexOf('spoofer')==-1) &&
                  (agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1)  &&
                  (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)     &&
                  (is_gecko) &&
                  ((navigator.vendor=="")||(navigator.vendor=="Mozilla")||(navigator.vendor=="Debian")));
  var is_fb = ((agt.indexOf('mozilla/5')!=-1) && (agt.indexOf('spoofer')==-1) &&
               (agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1)  &&
               (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)     &&
               (is_gecko) && (navigator.vendor=="Firebird"));
  var is_fx = ((agt.indexOf('mozilla/5')!=-1) && (agt.indexOf('spoofer')==-1) &&
               (agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1)  &&
               (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)     &&
               (is_gecko) && (navigator.vendor=="Firefox"));
  if ((is_moz)||(is_fb)||(is_fx)) {  // 032504 - dmr
     var is_moz_ver = (navigator.vendorSub)?navigator.vendorSub:0;
     if(!(is_moz_ver)) {
         is_moz_ver = agt.indexOf('rv:');
         is_moz_ver = agt.substring(is_moz_ver+3);
         is_paren   = is_moz_ver.indexOf(')');
         is_moz_ver = is_moz_ver.substring(0,is_paren);
     }
     is_minor = is_moz_ver;
     is_major = parseInt(is_moz_ver);
  }
  var is_fb_ver = is_moz_ver;
  var is_fx_ver = is_moz_ver;

  var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
              && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
              && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)
              && (!is_khtml) && (!(is_moz)) && (!is_fb) && (!is_fx));

  // Netscape6 is mozilla/5 + Netscape6/6.0!!!
  // Mozilla/5.0 (Windows; U; Win98; en-US; m18) Gecko/20001108 Netscape6/6.0
  // Changed this to use navigator.vendor/vendorSub - dmr 060502
  // var nav6Pos = agt.indexOf('netscape6');
  // if (nav6Pos !=-1) {
  if ((navigator.vendor)&&
      ((navigator.vendor=="Netscape6")||(navigator.vendor=="Netscape"))&&
      (is_nav)) {
     is_major = parseInt(navigator.vendorSub);
     // here we need is_minor as a valid float for testing. We'll
     // revert to the actual content before printing the result.
     is_minor = parseFloat(navigator.vendorSub);
  }

  var is_nav2 = (is_nav && (is_major == 2));
  var is_nav3 = (is_nav && (is_major == 3));
  var is_nav4 = (is_nav && (is_major == 4));
  var is_nav4up = (is_nav && is_minor >= 4);  // changed to is_minor for
                                              // consistency - dmr, 011001
  var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) ||
                        (agt.indexOf("; nav") != -1)) );

  var is_nav6   = (is_nav && is_major==6);    // new 010118 mhp
  var is_nav6up = (is_nav && is_minor >= 6); // new 010118 mhp

  var is_nav5   = (is_nav && is_major == 5 && !is_nav6); // checked for ns6
  var is_nav5up = (is_nav && is_minor >= 5);

  var is_nav7   = (is_nav && is_major == 7);
  var is_nav7up = (is_nav && is_minor >= 7);

  var is_ie   = ((iePos!=-1) && (!is_opera) && (!is_khtml));
  var is_ie3  = (is_ie && (is_major < 4));

  var is_ie4   = (is_ie && is_major == 4);
  var is_ie4up = (is_ie && is_minor >= 4);
  var is_ie5   = (is_ie && is_major == 5);
  var is_ie5up = (is_ie && is_minor >= 5);

  var is_ie5_5  = (is_ie && (agt.indexOf("msie 5.5") !=-1)); // 020128 new - abk
  var is_ie5_5up =(is_ie && is_minor >= 5.5);                // 020128 new - abk

  var is_ie6   = (is_ie && is_major == 6);
  var is_ie6up = (is_ie && is_minor >= 6);

  // KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
  // or if this is the first browser window opened.  Thus the
  // variables is_aol, is_aol3, and is_aol4 aren't 100% reliable.

  var is_aol   = (agt.indexOf("aol") != -1);
  var is_aol3  = (is_aol && is_ie3);
  var is_aol4  = (is_aol && is_ie4);
  var is_aol5  = (agt.indexOf("aol 5") != -1);
  var is_aol6  = (agt.indexOf("aol 6") != -1);
  var is_aol7  = ((agt.indexOf("aol 7")!=-1) || (agt.indexOf("aol7")!=-1));
  var is_aol8  = ((agt.indexOf("aol 8")!=-1) || (agt.indexOf("aol8")!=-1));

  var is_webtv = (agt.indexOf("webtv") != -1);

  // new 020128 - abk

  var is_TVNavigator = ((agt.indexOf("navio") != -1) || (agt.indexOf("navio_aoltv") != -1));
  var is_AOLTV = is_TVNavigator;

  var is_hotjava = (agt.indexOf("hotjava") != -1);
  var is_hotjava3 = (is_hotjava && (is_major == 3));
  var is_hotjava3up = (is_hotjava && (is_major >= 3));

  // end new

  // Done with is_minor testing; revert to real for N6/7
  if (is_nav6up) {
     is_minor = navigator.vendorSub;
  }

  // *** PLATFORM ***
  var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
  // NOTE: On Opera 3.0, the userAgent string includes "Windows 95/NT4" on all
  //        Win32, so you can't distinguish between Win95 and WinNT.
  var is_win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));

  // is this a 16 bit compiled version?
  var is_win16 = ((agt.indexOf("win16")!=-1) ||
             (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) ||
             (agt.indexOf("windows 16-bit")!=-1) );

  var is_win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) ||
                  (agt.indexOf("windows 16-bit")!=-1));

  var is_winme = ((agt.indexOf("win 9x 4.90")!=-1));    // new 020128 - abk
  var is_win2k = ((agt.indexOf("windows nt 5.0")!=-1) || (agt.indexOf("windows 2000")!=-1)); // 020214 - dmr
  var is_winxp = ((agt.indexOf("windows nt 5.1")!=-1) || (agt.indexOf("windows xp")!=-1)); // 020214 - dmr

  // NOTE: Reliable detection of Win98 may not be possible. It appears that:
  //       - On Nav 4.x and before you'll get plain "Windows" in userAgent.
  //       - On Mercury client, the 32-bit version will return "Win98", but
  //         the 16-bit version running on Win98 will still return "Win95".
  var is_win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
  var is_winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));
  var is_win32 = (is_win95 || is_winnt || is_win98 ||
                  ((is_major >= 4) && (navigator.platform == "Win32")) ||
                  (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1));

  var is_os2   = ((agt.indexOf("os/2")!=-1) ||
                  (navigator.appVersion.indexOf("OS/2")!=-1) ||
                  (agt.indexOf("ibm-webexplorer")!=-1));

  var is_mac    = (agt.indexOf("mac")!=-1);
  if (is_mac) { is_win = !is_mac; } // dmr - 06/20/2002
  var is_mac68k = (is_mac && ((agt.indexOf("68k")!=-1) ||
                             (agt.indexOf("68000")!=-1)));
  var is_macppc = (is_mac && ((agt.indexOf("ppc")!=-1) ||
                              (agt.indexOf("powerpc")!=-1)));

  var is_sun   = (agt.indexOf("sunos")!=-1);
  var is_sun4  = (agt.indexOf("sunos 4")!=-1);
  var is_sun5  = (agt.indexOf("sunos 5")!=-1);
  var is_suni86= (is_sun && (agt.indexOf("i86")!=-1));
  var is_irix  = (agt.indexOf("irix") !=-1);    // SGI
  var is_irix5 = (agt.indexOf("irix 5") !=-1);
  var is_irix6 = ((agt.indexOf("irix 6") !=-1) || (agt.indexOf("irix6") !=-1));
  var is_hpux  = (agt.indexOf("hp-ux")!=-1);
  var is_hpux9 = (is_hpux && (agt.indexOf("09.")!=-1));
  var is_hpux10= (is_hpux && (agt.indexOf("10.")!=-1));
  var is_aix   = (agt.indexOf("aix") !=-1);      // IBM
  var is_aix1  = (agt.indexOf("aix 1") !=-1);
  var is_aix2  = (agt.indexOf("aix 2") !=-1);
  var is_aix3  = (agt.indexOf("aix 3") !=-1);
  var is_aix4  = (agt.indexOf("aix 4") !=-1);
  var is_linux = (agt.indexOf("inux")!=-1);
  var is_sco   = (agt.indexOf("sco")!=-1) || (agt.indexOf("unix_sv")!=-1);
  var is_unixware = (agt.indexOf("unix_system_v")!=-1);
  var is_mpras    = (agt.indexOf("ncr")!=-1);
  var is_reliant  = (agt.indexOf("reliantunix")!=-1);
  var is_dec   = ((agt.indexOf("dec")!=-1) || (agt.indexOf("osf1")!=-1) ||
         (agt.indexOf("dec_alpha")!=-1) || (agt.indexOf("alphaserver")!=-1) ||
         (agt.indexOf("ultrix")!=-1) || (agt.indexOf("alphastation")!=-1));
  var is_sinix = (agt.indexOf("sinix")!=-1);
  var is_freebsd = (agt.indexOf("freebsd")!=-1);
  var is_bsd = (agt.indexOf("bsd")!=-1);
  var is_unix  = ((agt.indexOf("x11")!=-1) || is_sun || is_irix || is_hpux ||
               is_sco ||is_unixware || is_mpras || is_reliant ||
               is_dec || is_sinix || is_aix || is_linux || is_bsd || is_freebsd);

  var is_vms   = ((agt.indexOf("vax")!=-1) || (agt.indexOf("openvms")!=-1));


  // Define browser and version
  if (is_ie)
    browser = "Internet Explorer";
  else if (is_nav)
    browser = "Netscape";
  else if (is_fx)
    browser = "Firefox";
  else if (is_moz)
    browser = "Mozilla";
  else if (is_opera)
    browser = "Opera";
  else if (is_konq)
    browser = "Konqueror";
  else if (is_safari)
    browser = "Safari";
  else if (is_aol)
    browser = "AOL";

  browserVersion = is_minor;

  // Define OS and version
  if (is_win)
  {
    osPlatform = "Windows";
    if (is_winxp)
      osVersion = "Windows XP";
    else if (is_win2k)
      osVersion = "Windows 2000";
    else if (is_winnt)
      osVersion = "Windows NT";
    else if (is_winme)
      osVersion = "Windows ME";
    else if (is_win98)
      osVersion = "Windows 98";
    else if (is_win95)
      osVersion = "Windows 95";
    else if (is_win31)
      osVersion = "Windows 3.1";
  }
  else if (is_mac)
    osPlatform = "Mac";
  else if (is_linux)
    osPlatform = "Linux";
  else if (is_unix)
    osPlatform = "Unix";

  DayPortUtils.system.osPlatform = osPlatform;
  DayPortUtils.system.osVersion = osVersion;
  DayPortUtils.system.browser = browser;
  DayPortUtils.system.browserVersion = browserVersion;
};
DayPortUtils.systemCheck();