/* cookies
===========================================================================*/
// This next little bit of code tests whether the user accepts cookies.

function WM_browserAcceptsCookies() {
	var WM_acceptsCookies = false;
	if ( document.cookie == '' ) {
		document.cookie = 'WM_acceptsCookies=yes'; // Try to set a cookie.
		if ( document.cookie.indexOf( 'WM_acceptsCookies=yes' ) != -1 ) {
			WM_acceptsCookies = true;
		} // If it succeeds, set variable
	} else { // there was already a cookie
		WM_acceptsCookies = true;
	}
	
	return ( WM_acceptsCookies );
}

function CNN_setCookie( name, value, hours, path, domain, secure ) {
		var numHours = 0;

		if ( hours) {
			if ( (typeof(hours) == 'string') && Date.parse(hours) ) { // already a Date string
				numHours = hours;
			} else if ( typeof(hours) == 'number' ) { // calculate Date from number of hours
				numHours = ( new Date((new Date()).getTime() + hours*3600000) ).toGMTString();
			}
		}

		document.cookie = name + '=' + escape(value) + ((numHours)?(';expires=' + numHours):'') + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:'') + ((secure && (secure == true))?'; secure':''); // Set the cookie, adding any parameters that were specified.

}


/* end cookies
===========================================================================*/


/* global event handlers
=========================================================================== */
function cnnMouseDown(e) {
	if (cnnDropdownOpen) cnnDD.mouseDownBody(e);
	//if (cnnOverlayMenuOpen) cnnOverlayMouseDownBody(e);
	return true;
}
/* end global event handlers
=========================================================================== */

/* styled dropdowns
=========================================================================== */
var cnnDropdownOpen = false;

// CNN dropdown menu (JavaScript object literal)
var cnnDD = {
	curId: "", // id of currently-open dropdown
	ignoreMouseDownBody: false,
	menus: [],

	rowHeight: 22,
	combinedBorderWidth: 20,
	scrollbarWidth: 18,

	minMenuWidth: 105,
	maxMenuWidth: 400,
	defaultMenuWidth: 205,
	defaultRowWidth: 150,
	combinedRowLRPad: 18,
	scrollbarRPad: 12,


	buildDisabledDropdown: function(menuId, buttonWidth, buttonClass, hiddenListSuffix) {
		// default parameters
		if (!buttonWidth) buttonWidth = 140;
		if (!buttonClass) buttonClass = 'cnnDDWireLtg';

		var wrapId = menuId + "_wrap";
		var listId = menuId + "_list" + (hiddenListSuffix ? '_' + hiddenListSuffix : '');

		if ($(wrapId) && $(listId)) {

			// hide the <select>
			$(listId).style.display = "none";

			// Get the displayed value for the first select option
			var listItems = $(listId).options;
			var buttonText = listItems[0].innerHTML;

			var buttonTextLPad = 10;
			var buttonTextRPad = 34;
			var buttonTextWidth = buttonWidth - (buttonTextLPad + buttonTextRPad);

			var leftBgStyle = 'background:#fff url(http://i.cdn.turner.com/cnn/.element/img/2.0/global/dropdowns/btn_ltg_left.gif) 0 0 no-repeat;';
			var rightBgStyle = 'background:url(http://i.cdn.turner.com/cnn/.element/img/2.0/global/dropdowns/btn_ltg_right.gif) 100% 0 no-repeat;';

			switch (buttonClass) {
				case 'cnnDDWire':
					leftBgStyle = 'background:#fff url(http://i.cdn.turner.com/cnn/.element/img/2.0/global/dropdowns/btn_wire_left.gif) 0 0 no-repeat;';
					rightBgStyle = 'background:url(http://i.cdn.turner.com/cnn/.element/img/2.0/global/dropdowns/btn_wire_right.gif) 100% 0 no-repeat;';
					break;
				case 'cnnBlkBgWhtBox':
					leftBgStyle = 'background:#fff url(http://i.cdn.turner.com/cnn/.element/img/2.0/global/dropdowns/btn_blk_left.gif) 0 0 no-repeat;';
					rightBgStyle = 'background:url(http://i.cdn.turner.com/cnn/.element/img/2.0/global/dropdowns/btn_blk_right.gif) 100% 0 no-repeat;';
					break;
			}


			// build content for the button
			var strContent = "\n\n\n\n";
			strContent += '	<div class="cnnDDContainer" style="width:'+buttonWidth+'px;">'+"\n";

			strContent += '		<div class="'+buttonClass+'">'+"\n";
			strContent += '		<div class="cnnDDBtn" onmousedown="return cnnDD.mouseDownBtn(event, \''+menuId+'\');" onclick="return cnnDD.open(\''+menuId+'\')" style="'+rightBgStyle+'">'+"\n";
			strContent += '				<table width="'+buttonWidth+'" border="0" cellspacing="0" cellpadding="0">'+"\n";
			strContent += '					<tr>'+"\n";
			strContent += '						<td width="'+buttonTextLPad+'"><div class="cnnDDBtnLeft" style="'+leftBgStyle+'"></div></td>'+"\n";
			strContent += '						<td width="'+buttonTextWidth+'">'+"\n";
			strContent += '							<div class="cnnDDValueContainer">'+"\n";
			strContent += '								<div id="'+menuId+'_Val" class="cnnDDValue" style="width:'+buttonTextWidth+'px;color:#c5c5c5;">'+buttonText+'</div>'+"\n";
			strContent += '						</td>'+"\n";
			strContent += '						<td width="'+buttonTextRPad+'"><img src="http://i.cdn.turner.com/cnn/.element/img/2.0/global/dropdowns/btn_icon_disabled.gif" alt="" border="0"></td>'+"\n";
			strContent += '					</tr>'+"\n";
			strContent += '				</table>'+"\n";
			strContent += '			</div><!--/cnnDDBtn -->'+"\n\n";
			strContent += '		</div><!--/'+buttonClass+' -->'+"\n\n";

			strContent += '	</div><!--/cnnDDContainer -->'+"\n";
			strContent += "\n\n";

			// draw the new content
			$(wrapId).innerHTML = strContent;

			// reset the list
			$(listId).selectedIndex = 0;

		}//else id of select not found [ abort ]
	},

	buildDropdown: function(menuId, buttonWidth, menuWidth, numVisibleRows, buttonClass, hiddenListSuffix) {
		// default parameters
		if (!buttonWidth) buttonWidth = 140;
		if (!menuWidth) menuWidth = this.defaultMenuWidth;
		if (!numVisibleRows) numVisibleRows = 10;
		if (!buttonClass) buttonClass = 'cnnDDWireLtg';

		if (menuWidth < this.minMenuWidth) menuWidth = this.minMenuWidth;
		if (menuWidth > this.maxMenuWidth) menuWidth = this.maxMenuWidth;

		var wrapId = menuId + "_wrap";
		var listId = menuId + "_list" + (hiddenListSuffix ? '_' + hiddenListSuffix : '');

		this.menus[menuId] = new Array();
		this.menus[menuId].listId = listId;
		this.menus[menuId].updateFirstRow = false;

		if ($(wrapId) && $(listId)) {
			// hide the <select>
			$(listId).style.display = "none";

			var displayedValue = new Array();
			var internalValue = new Array();
			var disabledRow = new Array();

			var listItems = $(listId).options;
			for (var i=0;i<listItems.length;i++) {
				displayedValue[i] = listItems[i].innerHTML;
				internalValue[i] = listItems[i].value;
				disabledRow[i] = listItems[i].disabled;
			}
			var selectedRow = $(listId).selectedIndex;
		
			// If no row was explicitly selected
			if (selectedRow == 0) {
				// See if the first row matches one of the later rows
				for (i=1;i<displayedValue.length;i++) {
					if (displayedValue[i] == displayedValue[0]) {
						selectedRow = i;
						this.menus[menuId].updateFirstRow = true;
						break;
					}
				}
			}
			var buttonText = displayedValue[selectedRow];
			var numRows = displayedValue.length;

			var buttonTextLPad = 24;
			var buttonTextRPad = 10;
			var buttonTextWidth = buttonWidth - (buttonTextLPad + buttonTextRPad);

			// minus left and right borders
			var fullRowWidth = menuWidth - this.combinedBorderWidth;

			// without scrollbar
			var visibleRowsHeight = numRows * this.rowHeight;
			var rowWidth = fullRowWidth;

			// with scrollbar
			if (numRows > numVisibleRows) {
				visibleRowsHeight = numVisibleRows * this.rowHeight;
				rowWidth -= 10;
			}

			var leftBgStyle = 'background:#fff url(http://i.cdn.turner.com/cnn/.element/img/2.0/global/dropdowns/btn_ltg_left.gif) 0 0 no-repeat;';
			var rightBgStyle = 'background:url(http://i.cdn.turner.com/cnn/.element/img/2.0/global/dropdowns/btn_ltg_right.gif) 100% 0 no-repeat;';

			switch (buttonClass) {
				case 'cnnDDWire':
					leftBgStyle = 'background:#fff url(http://i.cdn.turner.com/cnn/.element/img/2.0/global/dropdowns/btn_wire_left.gif) 0 0 no-repeat;';
					rightBgStyle = 'background:url(http://i.cdn.turner.com/cnn/.element/img/2.0/global/dropdowns/btn_wire_right.gif) 100% 0 no-repeat;';
					break;
				case 'cnnBlkBgWhtBox':
					leftBgStyle = 'background:#fff url(http://i.cdn.turner.com/cnn/.element/img/2.0/global/dropdowns/btn_blk_left.gif) 0 0 no-repeat;';
					rightBgStyle = 'background:url(http://i.cdn.turner.com/cnn/.element/img/2.0/global/dropdowns/btn_blk_right.gif) 100% 0 no-repeat;';
					break;
			}


			// build content for the menu
			var strContent = "\n\n\n\n";
			strContent += '	<div class="cnnDDContainer" style="width:'+buttonWidth+'px;">'+"\n";

			strContent += '		<div class="cnnDDBoxContainer">'+"\n";
			strContent += '		<div class="cnnDDBox" id="'+menuId+'" style="width:'+menuWidth+'px;" onmousedown="return cnnDD.mouseDown(event, \''+menuId+'\');">'+"\n";
			strContent += '			<div class="cnnDDBoxHeader"><div class="cnnDDBoxHeaderTL"></div><div class="cnnDDBoxHeaderTR"></div></div>'+"\n";
			strContent += '			<div class="cnnDDBoxContent">'+"\n";

			strContent += '				<div class="cnnDDContent" style="width:'+fullRowWidth+'px;">'+"\n";
			strContent += '					<div class="cnnPad6Top"></div>'+"\n";
			strContent += '					<div class="cnnDDList" style="height:'+visibleRowsHeight+'px; width:'+rowWidth+'px; direction:rtl; text-align:right;">'+"\n";
			strContent += '						<ul>'+"\n";

			for (var i=0;i<displayedValue.length;i++) {
				if ((i==0) && (this.menus[menuId].updateFirstRow)) {
					strContent += '						<li id="'+menuId+'_hdnVal"><a href="javascript:cnnDD.select('+i+',\''+this.encodeAttr(displayedValue[i])+'\',\''+this.encodeAttr(internalValue[i])+'\');">'+displayedValue[i]+'</a></li>'+"\n";
				}
				else if (disabledRow[i]) {
					strContent += '						<li class="cnnDDSeparator"><span>'+displayedValue[i]+'</span></li>'+"\n";
				}
				else {
					strContent += '						<li><a href="javascript:cnnDD.select('+i+',\''+this.encodeAttr(displayedValue[i])+'\',\''+this.encodeAttr(internalValue[i])+'\');">'+displayedValue[i]+'</a></li>'+"\n";
				}
			}
			var btnclass ='cnnDDBtn';
			strContent += '						</ul>'+"\n";
			strContent += '					</div>'+"\n";
			strContent += '					<div class="cnnPad8Top"></div>'+"\n";
			strContent += '				</div><!-- /cnnDDContent -->'+"\n";

			strContent += '			</div><!-- /cnnDDBoxContent -->'+"\n";
			strContent += '			<div class="cnnDDBoxFooter"><div class="cnnDDBoxFooterBL"></div><div class="cnnDDBoxFooterBR"></div></div>'+"\n";
			strContent += '		</div><!--/cnnDDBox-->'+"\n";
			strContent += '		</div><!--/cnnDDBoxContainer-->'+"\n";

			strContent += '		<div class="'+buttonClass+'">'+"\n";
			strContent += '			<div class="'+ btnclass+ '" onmousedown="return cnnDD.mouseDownBtn(event, \''+menuId+'\');" onclick="return cnnDD.open(\''+menuId+'\')" style="'+rightBgStyle+'">'+"\n";
			strContent += '				<table width="'+buttonWidth+'" border="0" cellspacing="0" cellpadding="0">'+"\n";
			strContent += '					<tr>'+"\n";
			strContent += '						<td width="'+buttonTextRPad+'"><div class="cnnDDBtnLeft" style="'+leftBgStyle+'"></div></td>'+"\n";
			strContent += '						<td width="'+buttonTextWidth+'">'+"\n";
			strContent += '							<div class="cnnDDValueContainer">'+"\n";
			strContent += '								<div id="'+menuId+'_Val" class="cnnDDValue" style="width:'+buttonTextWidth+'px;">'+buttonText+'</div>'+"\n";
			strContent += '						</td>'+"\n";
			strContent += '						<td width="'+buttonTextLPad+'"><img src="http://i.cdn.turner.com/cnn/.element/img/2.0/global/dropdowns/btn_icon.gif" alt="" border="0"></td>'+"\n";
			strContent += '					</tr>'+"\n";
			strContent += '				</table>'+"\n";
			strContent += '			</div><!--/cnnDDBtn -->'+"\n\n";
			strContent += '		</div><!--/'+buttonClass+' -->'+"\n\n";

			strContent += '	</div><!--/cnnDDContainer -->'+"\n";
			strContent += "\n\n";

			// draw the new content
			$(wrapId).innerHTML = strContent;

			// capture mousedown
			document.body.onmousedown = cnnMouseDown;
		}//else id of select not found [ abort ]
	},

	buildOverlay: function(menuId, menuWidth, numVisibleRows, dx, dy) {
		// default parameters
		if (!menuWidth) menuWidth = this.defaultMenuWidth;
		if (!numVisibleRows) numVisibleRows = 10;

		if (menuWidth < this.minMenuWidth) menuWidth = this.minMenuWidth;
		if (menuWidth > this.maxMenuWidth) menuWidth = this.maxMenuWidth;

		var leftPos = -20;
		var topPos = 1;
		if (dx) leftPos += dx;
		if (dy) topPos += dy;

		var wrapId = menuId + "_wrap";
		var listId = menuId + "_list";
		var titleId = menuId + "_title";

		if ($(wrapId) && $(titleId) && $(listId)) {
			// hide the list
			$(listId).style.display = "none";

			var title = $(titleId).innerHTML;

			// Get the displayed value for each select option
			var listItems = $(listId).getElementsByTagName('li');
			var displayedList = new Array();
			for (var i=0;i<listItems.length;i++) {
				displayedList[i] = listItems[i].innerHTML;
			}

			var numRows = displayedList.length;

			var menuTitleRPad = 60;
			var menuTitleWidth = menuWidth - menuTitleRPad;

			// minus left and right borders
			var fullRowWidth = menuWidth - this.combinedBorderWidth;

			// without scrollbar
			var visibleRowsHeight = numRows * this.rowHeight;
			var rowWidth = menuWidth - this.combinedBorderWidth;

			// with scrollbar
			if (numRows > numVisibleRows) {
				visibleRowsHeight = numVisibleRows * this.rowHeight;
				rowWidth -= 10;
			}


			// build content for the menu
			var strContent = "\n\n\n\n";
			strContent += ' <div class="cnnDDOvrBoxContainer">'+"\n";
			strContent += '		<div class="clear"><img src="http://i.cdn.turner.com/cnn/images/1.gif" width="1" height="1" border="0" alt=""></div>'+"\n";
			strContent += '		<div class="cnnDDOvrBox" id="'+menuId+'" style="width:'+menuWidth+'px;left:'+leftPos+'px; top:'+topPos+'px;" onmousedown="return cnnDD.mouseDown(event, \''+menuId+'\');">'+"\n";
			strContent += '			<div class="cnnDDBoxHeader"><div class="cnnDDBoxHeaderTL"></div><div class="cnnDDBoxHeaderTR"></div></div>'+"\n";
			strContent += '			<div class="cnnDDBoxContent">'+"\n";
			strContent += '				<div class="cnnDDOvrCloseContainer"><div class="cnnDDOvrClose" onclick="cnnDD.close(); return true;"><img src="http://i.cnn.net/cnn/.element/img/2.0/global/dropdowns/overlay_close.png" width="12" height="12" alt="" border="0"></div></div>'+"\n";
			strContent += '				<div class="cnnDDContent" style="width:'+fullRowWidth+'px;">'+"\n";
			strContent += '					<div class="cnnDDOvrTitle" style="width:'+menuTitleWidth+'px;overflow:hidden;">'+title+'</div>'+"\n";
			strContent += '					<div class="cnnDDList" style="height:'+visibleRowsHeight+'px;width:'+rowWidth+'px;">'+"\n";
			strContent += '						<ul>'+"\n";

			for (var i=0;i<displayedList.length;i++) {
				strContent += '					<li>'+displayedList[i]+'</li>'+"\n";
			}
			strContent += '						</ul>'+"\n";
			strContent += '					</div><!-- /cnnDDList -->'+"\n";
			strContent += '					<div class="cnnPad12Top"></div>'+"\n";
			strContent += '				</div><!-- /cnnDDContent -->'+"\n";
			strContent += '			</div><!-- /cnnDDBoxContent -->'+"\n";
			strContent += '			<div class="cnnDDBoxFooter"><div class="cnnDDBoxFooterBL"></div><div class="cnnDDBoxFooterBR"></div></div>'+"\n";
			strContent += '		</div><!--/cnnDDOvrBox-->'+"\n";
			strContent += ' </div><!--/cnnDDOvrBoxContainer-->'+"\n";
			strContent += "\n\n";
			// draw the new content
			$(wrapId).innerHTML = strContent;

			// capture mousedown
			document.body.onmousedown = cnnMouseDown;

		}//else id of select not found [ abort ]
	},


	select: function(index, displayedValue, internalValue) {
		if ($(this.curId)) {
			var menuId = this.curId;

			// close the dropdown
			this.close();

			// change the displayed dropdown value (button text)
			if ($(menuId + '_Val')) {
				$(menuId + '_Val').innerHTML = displayedValue;
			}

			// set the first row of the menu to the current value
			if ((this.menus[menuId].updateFirstRow) && $(menuId + '_hdnVal')) {
				$(menuId+'_hdnVal').innerHTML = '<a href="javascript:cnnDD.select(' + index + ',\'' + this.encodeAttr(displayedValue) + '\',\'' + this.encodeAttr(internalValue) + '\')">' + displayedValue + '</a>';
			}

			var listId = this.menus[menuId].listId;
			if ($(listId)) {
				// if the value has changed
				if ($(listId).selectedIndex != index) {
					// set the index of the selected option for the invisible <select>
					$(listId).selectedIndex = index;

					// If an onchange event handler exists
					if ($(listId).onchange) {
						$(listId).onchange();
					}
				}
			}

			// if a callback function exists
			try {
				var onChoose = eval(menuId + '_OnChoose');
				if (onChoose) {
					onChoose();
				}
			}
			catch(err) {
			}
		}
	},

	open: function(id) {
		if($(id)) {
			// Was the same menu clicked again?
			var sameMenu = (this.curId == id);

			// If a menu is already open
			this.close();

			// If a different menu was clicked
			if (!sameMenu) {
				$(id).style.display = "block";
				this.curId = id;
				cnnDropdownOpen = true;
			}
		}
	},

	close: function() {
		if ($(this.curId)) {
			$(this.curId).style.display = "none";
			this.curId = '';
			cnnDropdownOpen = false;
		}
	},

	encodeAttr: function(str) {
		str=str.replace(/\\/g,'\\\\');
		str=str.replace(/\'/g,'\\\'');
		str=str.replace(/\"/g,'&quot;');
		str=str.replace(/\0/g,'\\0');
		return str;
	},

	mouseDown: function(e, id) {
		this.ignoreMouseDownBody = true;
		return true;
	},

	mouseDownBtn: function(e, id) {
		// True if the same dropdown button was clicked again.
		this.ignoreMouseDownBody = (id && (this.curId == id));
		return true;
	},

	mouseDownBody: function(e) {
		if (!this.ignoreMouseDownBody) {
			this.close();
		}
		this.ignoreMouseDownBody = false;
		return true;
	}
}
/* end styled dropdowns
=========================================================================== */

/* intl market box
===================================================================== */
function cnnWbMarkets( intWhich ) {
	for(i=1;i<4;i++) {
		if(i==intWhich) {
			$('cnnWbMarkets' + i).style.display = 'block';
			$('cnnWbMarketsTab' + i).className = 'active';
		}
		else {
			$('cnnWbMarkets' + i).style.display = 'none';
			$('cnnWbMarketsTab' + i).className = '';
		}
	}
}
/* end intl market box
===================================================================== */
/* Image Swap
===================================================================== */
function cnnImgSwap( strId, intSwap ) {
	// assumes 2 images: image.gif and image_over.gif
	var imgObj = (typeof(strId) == "object") ? strId.getElementsByTagName('img')[0] : document.getElementById( strId );
	var strTemp = imgObj.src;
	var intStrLength = strTemp.length;
	var intChop, strEnd;

	if ( intSwap ) {
		if (strTemp.indexOf('_over.gif') == -1) {
			intChop = intStrLength - 4;
			strEnd = '_over.gif';
		}
	} else {
		if (strTemp.indexOf('_over.gif') > -1) {
			intChop = intStrLength - 9;
			strEnd = '.gif';
		}
	}

	if (typeof(intChop) != "undefined") {
		strTemp = strTemp.substring( 0, intChop );
	}

	if (typeof(strEnd) != "undefined") {
		imgObj.src = strTemp + strEnd;
	}
}
/* end Image Swap
======================================================================== */

var cnnHasOpenPopup = 0;
// this is for opening pop-up windows
function CNN_openPopup( url, name, widgets, openerUrl )
{
	var host = location.hostname;
	if (window == top) { window.top.name = "opener"; }
	var popupWin = window.open( url, name, widgets );
	if(popupWin) {cnnHasOpenPopup = 1;}
	if ( popupWin && popupWin.opener ) {
		if ( openerUrl )
		{
			popupWin.opener.location = openerUrl;
		}
	}
	if ( popupWin) {
		popupWin.focus();
	}
}

/* make cnn your home js
========================================================================= */
var cnnHPbkmrk = "http://arabic.cnn.com";


var cnnMakeHPBox_HTML = '<div id="cnnMakeHPBanner"><div class="cnnWireSeBox"><div class="cnnWireSeBoxHeader"><img src="http://i.cdn.turner.com/cnn/.element/img/2.0/global/set_edition/corner_se_tl.gif" width="4" height="4" alt="" /></div><div id="cnnBoxSeContent"><a href="javascript:cnnMakeHPBox_Close();"><img class="cnnEditionCloseBtn" src="http://i.cdn.turner.com/cnn/.element/img/2.0/global/set_edition/se_close_btn.gif" width="14" height="14" alt="" /></a><form id="cnnsetPref_Form"><table align="center" class="cnnSetEdition" cellpadding="0" cellspacing="0" border="0"><tr><td class="setEdText"><b>&#1575;&#1580;&#1593;&#1604; CNN &#1576;&#1575;&#1604;&#1593;&#1585;&#1576;&#1610;&#1577; &#1589;&#1601;&#1581;&#1578;&#1603;</b></td><td>&#160;<a href="javascript:void(0);" onclick="if(document.all) { this.style.behavior=\'url(#default#homepage)\';this.setHomePage(\''+cnnHPbkmrk+'\');cnnMakeHPBox_Close(); }"><img src="/.element/img/1.0/set_btn.gif" width="70" height="23" alt="" border="0" class="cnnEditionBoxBtn" /></a></td></tr></table></form></div><div class="cnnWireSeBoxFooter"><img src="http://i.cdn.turner.com/cnn/.element/img/2.0/global/set_edition/corner_se_bl.gif" width="4" height="4" alt="" /></div></div></div>';

function cnnMakeHPBox_Close() {
	if (document.getElementById) { document.getElementById('cnnMakeHPContainer').style.display = 'none'; }
	else if (document.all) { document.all['cnnMakeHPContainer'].style.display = 'none'; }
}

function cnnMakeHPBox() {
	if(document.all) {
		Element.update('cnnMakeHPContainer', cnnMakeHPBox_HTML);
		document.all['cnnMakeHPContainer'].style.display = 'block';
	}
	else {
	CNN_openPopup('/feedback/help/homepage/frameset.2.0.exclude.html','620x364','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=auto,resizable=no,width=620,height=430');
	}

}

/* end make cnn your home js
========================================================================= */

/*
Flash Detect and Render
=======================
The CNN_FlashObject takes a few required arguments...
	name ......... the id/name of the object/embed
	src .......... the URL of the swf
	width ........ (i think this should be required)
	height ....... (i think this should be required)

...and some optional arguments...
	parameters ... this is a "hash" of keys and values
		{ menu: "true", play: "false", loop: "false" }
		(or set this to null or an empty string to skip)
	flashVars .... this is a hash or a string

		{ cs_url: "/football/nfl/scoreboards/today/" }
		- or -
		"cs_url=/football/nfl/scoreboards/today/"
Sample Usage:

if ( new CNN_FlashDetect().detectVersion( 6 ) ) {
	var cnn_Scoreboard = new CNN_FlashObject( "cnnScoreboard",

		"/.element/img/2.0/swf/nfl_scoreboard.swf",

		420, 85, null, "cs_url=/football/nfl/scoreboards/today/" );
	cnn_Scoreboard.writeHtml();
} else {
	document.write( 'alternate html' );
}
Of course, if you plan to have Flash in lots of places on a page,
it might make more sense to make a global variable for the detection.
You could go as far as creating a session-based cookie...
*/

var VBS_Result = false;

function CNN_FlashDetect() { }

CNN_FlashDetect.prototype.maxVersionToDetect = 8;
CNN_FlashDetect.prototype.minVersionToDetect = 3;
CNN_FlashDetect.prototype.hasPlugin = ( navigator.mimeTypes &&
		navigator.mimeTypes.length &&
		navigator.mimeTypes["application/x-shockwave-flash"] &&
		navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin );
CNN_FlashDetect.prototype.hasActiveX = window.ActiveXObject;
CNN_FlashDetect.prototype.hasWinIE = ( navigator.userAgent &&
		( navigator.userAgent.indexOf( "MSIE" ) != -1 ) &&
		navigator.appVersion &&
		( navigator.appVersion.indexOf( "Win" ) != -1 ) );
CNN_FlashDetect.prototype.getVersion = function () {
	var versionNum = 0;
	var i = 0;
	if ( this.hasActiveX ) {
		var activeXObject = false;
		for ( i = this.maxVersionToDetect; i >= this.minVersionToDetect && !activeXObject; versionNum = ( activeXObject ? i : versionNum ), i-- ) {
			try {
				activeXObject = new ActiveXObject( "ShockwaveFlash.ShockwaveFlash." + i );
			} catch( e ) {
				// do nothing
			}
		}
	} else if ( this.hasWinIE ) {
		VBS_Result = false;
		for ( i = this.maxVersionToDetect; i >= this.minVersionToDetect && !VBS_Result; versionNum = ( VBS_Result ? i : versionNum ), i-- ) {
			execScript( 'on error resume next: VBS_Result = IsObject( CreateObject( "ShockwaveFlash.ShockwaveFlash.' + i + '" ) )', 'VBScript' );
		}
	} else if ( this.hasPlugin ) {
		if ( navigator.plugins && navigator.plugins.length && navigator.plugins["Shockwave Flash"] ) {
			var words = navigator.plugins["Shockwave Flash"].description.split( " " );
			for ( i = 0; i < words.length; ++i ) {
				if ( isNaN( parseInt( words[i] ) ) )
					continue;
				versionNum = words[i];
			}
		}
	}
	return ( versionNum );
}

CNN_FlashDetect.prototype.detectVersion = function ( num ) {
	var isVersionSupported = false;
	if ( ! isNaN( num ) ) {
		isVersionSupported = ( this.getVersion() >= parseInt( num ) );
	}
	return ( isVersionSupported );
}

function CNN_FlashObject( p_name, p_src, p_width, p_height, p_parameters, p_flashVars ) {
	this.m_name			= p_name;
	this.m_src			= p_src;
	this.m_width		= p_width;
	this.m_height		= p_height;
	this.m_flashVars	= p_flashVars;

// constructor
	if ( p_parameters )
	{
		this.setParams( p_parameters );
	}
}

// Declare member properties

CNN_FlashObject.prototype.m_name = '';
CNN_FlashObject.prototype.m_src = '';
CNN_FlashObject.prototype.m_width = '';
CNN_FlashObject.prototype.m_height = '';
CNN_FlashObject.prototype.m_flashVars = '';
CNN_FlashObject.prototype.m_params = {
	menu:		"false",
	quality:	"high",
	allowScriptAccess:		"always",
	wmode:		"transparent"
};

CNN_FlashObject.prototype.setParam = function ( p_name, p_value ) {
	this.m_params[ p_name ] = p_value;
}

CNN_FlashObject.prototype.setParams = function ( p_paramHash ) {

	if ( typeof p_paramHash == "object" ) {
		for ( var param in p_paramHash ) {
			if ( p_paramHash[param] ) {
				this.setParam( param, p_paramHash[param] );
			}
		}
	}
}

CNN_FlashObject.prototype.getParam = function ( p_name ) {
	return ( this.m_params[ p_name ] );
}

CNN_FlashObject.prototype.getParams = function () {
	return ( this.m_params );
}

CNN_FlashObject.prototype.getFlashVarsString = function () {
	var flashVarsString = '';
	if ( typeof this.m_flashVars == "string" ) {
		flashVarsString = this.m_flashVars;
	} else if ( typeof this.m_flashVars == "object" ) {
		for ( var flashVar in this.m_flashVars ) {
			if ( flashVarsString != '' ) {
				flashVarsString += "&";
			}
			flashVarsString += flashVar + "=" + escape( this.m_flashVars[flashVar] );
		}
	}
	return ( flashVarsString );
}

CNN_FlashObject.prototype.getAttributeString = function ( p_attr, p_value ) {
	return ( p_value ? ' ' + p_attr + '="' + p_value + '"' : '' );
}

CNN_FlashObject.prototype.getParamTag = function ( p_name, p_value ) {
	return ( p_value ? '<param name="' + p_name + '" value="' + p_value + '">' : '' );
}

CNN_FlashObject.prototype.getHtml = function () {
	var htmlString = '';
	var eachParam = '';
	var flashUrl = 'http://www.macromedia.com/go/getflashplayer';

// open object
	htmlString += '<object type="application/x-shockwave-flash" \
					classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
	htmlString += this.getAttributeString( 'pluginspage', flashUrl );
	htmlString += this.getAttributeString( 'id', this.m_name );
	htmlString += this.getAttributeString( 'data', this.m_src );
	htmlString += this.getAttributeString( 'width', this.m_width );
	htmlString += this.getAttributeString( 'height', this.m_height );
	htmlString += '>';
	htmlString += this.getParamTag( 'movie', this.m_src );
	for ( eachParam in this.getParams() ) {
		htmlString += this.getParamTag( eachParam, this.getParam( eachParam ) );
	}
	htmlString += this.getParamTag( 'flashVars', this.getFlashVarsString() );

// open embed
	htmlString += '<embed type="application/x-shockwave-flash"';
	htmlString += this.getAttributeString( 'pluginspage', flashUrl );
	htmlString += this.getAttributeString( 'name', this.m_name );
	htmlString += this.getAttributeString( 'src', this.m_src );
	htmlString += this.getAttributeString( 'width', this.m_width );
	htmlString += this.getAttributeString( 'height', this.m_height );
	for ( eachParam in this.getParams() ) {
		htmlString += this.getAttributeString( eachParam, this.getParam( eachParam ) );
	}
	htmlString += this.getAttributeString( 'flashVars', this.getFlashVarsString() );
	htmlString += '>';

// close embed

	htmlString += '<\/embed>';

// close object

	htmlString += '<\/object>';
	return ( htmlString );
}

CNN_FlashObject.prototype.writeHtml = function () {
	document.write( this.getHtml() );
}

CNN_FlashObject.prototype.writeMosaicHtml = function (id) {
	document.getElementById(id).innerHTML =  this.getHtml();
}

/* breaking news banners
=========================================================================== */

function cnnRenderGenericBanner(object,flashURL,leftColor,rightColor)
{
    var banner_title ='&#1570;&#1582;&#1585; &#1582;&#1576;&#1585;';
	if (allCookies['cnnLastClosedBannerId'] == object.id)
	{
		// don't render anything if the banner has been closed.
		return '';
	}
	var myHtml = '<div id="cnnBannerContent"><div id="cnnBannerTopic"';
	if (!(new CNN_FlashDetect().detectVersion( 8 )))
	{
		myHtml += 'class="'+leftColor+'"><div id="cnnBannerHeader"><div id="cnnBannerHeaderTxt">&#1570;&#1582;&#1585; &#1582;&#1576;&#1585;<\/div><\/div>';
	}
	else
	{
		var cnn_AnimatedBanner = new CNN_FlashObject( "cnnAnimatedBannerTitle", flashURL, 211, 73, null, { bn_title: banner_title } );
		myHtml += '>'+ cnn_AnimatedBanner.getHtml();
	}
	myHtml += '<\/div><div id="cnnBannerBox" class="'+rightColor+'">';
	myHtml += '<div id="cnnBannerBoxContent"><a href="#" onMouseOver="cnnImgSwap(this,1);" onMouseOut="cnnImgSwap(this,0);" onClick="CNN_setCookie(\'cnnLastClosedBannerId\',\''+object.id+'\'); $(\'cnnBannerContainer\').hide(); return true;"><img class="cnnCloseBtn" name="cnnBannerCloseBtn" src="/.element/img/1.0/content/live_news/banner_'+rightColor.substring(3).toLowerCase()+'_btn.gif" width="14" height="14" alt="" /><\/a>';
	myHtml += '<div id="cnnBannerHeadline"';
	myHtml += '>'+object.content+'<\/div>';
	myHtml += '<\/div><\/div><\/div><div class="cnnPad12Top" style="clear:both;"> <\/div>';
	return myHtml;
}

function cnnRenderArabicBanner(object){
	var flashURL='/.element/swf/1.0/breaking_news/bn_ar.swf';
	var leftColor='cnnYellow';
	var rightColor='cnnBlack';
	return cnnRenderGenericBanner(object,flashURL,leftColor,rightColor);
}

/* end breaking news banners
=========================================================================== */

/* CNNArabic Backward 
========================================================================== */
var agt		= navigator.userAgent.toLowerCase();
var versInt	= parseInt(navigator.appVersion);
var is_aol	= (agt.indexOf("aol") != -1);
var is_ie	= ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie6      = ((agt.indexOf("msie 6.0") != -1));
var is_ie3    = (is_ie && (versInt < 4));
var is_ie4    = (is_ie && (versInt == 4) && (agt.indexOf("msie 4")!=-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_comp   = (agt.indexOf("compuserve") != -1);
var is_comp2000   = (agt.indexOf("cs") != -1);	 
var is_compie = (is_comp && is_ie);
function openWindow (earl,name,widgets) 
{
	host = location.hostname;
	if (host.indexOf('customnews') != -1) 
	{
		var url = 'http://customnews.cnn.com' + earl;
	}
	else
	{
		var url = earl;
	}
	popupWin = window.open (url,name,widgets);
	
	if(!is_aol6 && !is_aol3 && !is_aol4 && !is_aol5 && !is_compie && !is_comp2000)
	{
		popupWin.opener.top.name = "opener";
		popupWin.focus();
	}
     
}
// _____________________________________________________ Tabbes video box

function showTab(tabId, tabNo)
{
	var tabCollection = document.getElementById(tabId);
	tabCollection.className='cnnTab'+tabNo+'Visible';
}

// _____________________________________________________ Tabbed Market box on Intl
var cnnIntlMarketsBoxArray = new Array();
cnnIntlMarketsBoxArray[1] = 'cnnAsiaMarketsBox';
cnnIntlMarketsBoxArray[2] = 'cnnEuropeMarketsBox';
cnnIntlMarketsBoxArray[3] = 'cnnUSAMarketsBox';
	
var cnnIntlMarketsTabArray = new Array();
cnnIntlMarketsTabArray[1] = 'cnnIntlMarketsBoxAsiaTab';
cnnIntlMarketsTabArray[2] = 'cnnIntlMarketsBoxEuropeTab';
cnnIntlMarketsTabArray[3] = 'cnnIntlMarketsBoxUSATab';
	
function cnnIntlSwitchMarkets(object) {	
	if (document.getElementById) {
		for (var i=1;i<=cnnIntlMarketsBoxArray.length-1;i++){
			if (object == i) { //show and set link to active state
				if (document.getElementById(cnnIntlMarketsBoxArray[i])) {
					document.getElementById(cnnIntlMarketsBoxArray[i]).style.display = 'block';
				}
				if(document.getElementById(cnnIntlMarketsTabArray[i])) {
					document.getElementById(cnnIntlMarketsTabArray[i]).className = "cnnIntlBixBoxCurrentSelection";
				}				
			} else { //hide and set link to non-active state
				if (document.getElementById(cnnIntlMarketsBoxArray[i])) {				
					document.getElementById(cnnIntlMarketsBoxArray[i]).style.display = 'none';
				}
				if(document.getElementById(cnnIntlMarketsTabArray[i])) {
					document.getElementById(cnnIntlMarketsTabArray[i]).className = "";
				}	
			}
		}	
	}
}

function cnnVideo(mode, arg, expiration) {
	var pipelineLauncher = document.getElementById( "cnnPipelineLauncher" );
	var CNN_convertArg = (mode == 'browse' && arg == '/mostwatched') ? true : false;
	var CNN_PipelineArg = (CNN_convertArg) ? '/ALL' : arg; 


	//var usePipeLinePlayer = cnnDetectCNNPipeLine();
	 var usePipeLinePlayer = false;
 	CNN_Player_Pref = WM_readCookie('CNN_Player_Pref');
 
//	if(usePipeLinePlayer) {
// 
//		if (pipelineLauncher && (typeof(pipelineLauncher.CanLaunch) != "undefined") && pipelineLauncher.CanLaunch("web")) {
//			CNN_Player_Pref = 'app_based';
//		}
 	
//	}
 
//	if (CNN_Player_Pref == 'app_based') {
//		cnnLaunchPipelineApp(mode, CNN_PipelineArg, expiration); 
//	}
//	else {
		
		if (CNN_Player_Pref == 'web_based') {
			cnnLaunchWebPlayer(mode, CNN_PipelineArg, expiration);
		}
		else {
			
			if(!WM_readCookie('oneaday') && !cnnValVidModExp(mode, arg, expiration)) {
				cnnLaunchWebPlayer(mode,  CNN_PipelineArg, expiration);
			}
			else if ( !cnnLaunchPreviewWebPlayer(mode, arg, expiration)) { 
				cnnLaunchWebPlayer(mode,  CNN_PipelineArg, expiration);
			}
			else {
				cnnLaunchFreePlayer(mode, arg, expiration); 
			}
		
		}
		
 //	 }
	 
}

// _____________________________________________________________ WebMonkey code
/*
WM_setCookie(), WM_readCookie(), WM_killCookie()
A set of functions that eases the pain of using cookies.

Source: Webmonkey Code Library
(http://www.hotwired.com/webmonkey/javascript/code_library/)

Author: Nadav Savio
*/

// This next little bit of code tests whether the user accepts cookies.
function WM_browserAcceptsCookies() {
	var WM_acceptsCookies = false;
	if ( document.cookie == '' ) {
		document.cookie = 'WM_acceptsCookies=yes'; // Try to set a cookie.
		if ( document.cookie.indexOf( 'WM_acceptsCookies=yes' ) != -1 ) {
			WM_acceptsCookies = true;
		} // If it succeeds, set variable
	} else { // there was already a cookie
		WM_acceptsCookies = true;
	}
	
	return ( WM_acceptsCookies );
}

function WM_setCookie( name, value, hours, path, domain, secure ) {
	if ( WM_browserAcceptsCookies() ) { // Don't waste your time if the browser doesn't accept cookies.
		var numHours = 0;
		var not_NN2 = ( navigator && navigator.appName
					&& (navigator.appName == 'Netscape')
					&& navigator.appVersion
					&& (parseInt(navigator.appVersion) == 2) ) ? false : true;

		if ( hours && not_NN2 ) { // NN2 cannot handle Dates, so skip this part
			if ( (typeof(hours) == 'string') && Date.parse(hours) ) { // already a Date string
				numHours = hours;
			} else if ( typeof(hours) == 'number' ) { // calculate Date from number of hours
				numHours = ( new Date((new Date()).getTime() + hours*3600000) ).toGMTString();
			}
		}
		
		document.cookie = name + '=' + escape(value) + ((numHours)?(';expires=' + numHours):'') + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:'') + ((secure && (secure == true))?'; secure':''); // Set the cookie, adding any parameters that were specified.
	}
} // WM_setCookie

function WM_readCookie( name ) {
	if ( document.cookie == '' ) { // there's no cookie, so go no further
	    return false;
	} else { // there is a cookie
	    var firstChar, lastChar;
		var theBigCookie = document.cookie;
		firstChar = theBigCookie.indexOf(name);	// find the start of 'name'
		var NN2Hack = firstChar + name.length;
		if ( (firstChar != -1) && (theBigCookie.charAt(NN2Hack) == '=') ) { // if you found the cookie
			firstChar += name.length + 1; // skip 'name' and '='
			lastChar = theBigCookie.indexOf(';', firstChar); // Find the end of the value string (i.e. the next ';').
			if (lastChar == -1) lastChar = theBigCookie.length;
			return unescape( theBigCookie.substring(firstChar, lastChar) );
		} else { // If there was no cookie of that name, return false.
			return false;
		}
	}	
} // WM_readCookie

function WM_killCookie( name, path, domain ) {
	var theValue = WM_readCookie( name ); // We need the value to kill the cookie
	if ( theValue ) {
		document.cookie = name + '=' + theValue + '; expires=Fri, 13-Apr-1970 00:00:00 GMT' + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:''); // set an already-expired cookie
	}
} // WM_killCookie


// ______________________________________________________________________ Apple
// Copyright ¨ 2000 by Apple Computer, Inc., All Rights Reserved.


function cnnValVidModExp(mode, arg, expiration)
{
        var launchFreePlayer = true;
        
		if(mode=='live') { launchFreePlayer = false;}
        else if(mode=='play')
        {
                var cnnExpireDate = new Date( new Date().getTime() - 24*60*60*1000 );
                var dateStringRegExp = /^(\d{4})\/(\d{2})\/(\d{2})$/;
                var dateStringArray = dateStringRegExp.exec( expiration );                
                if ( dateStringArray && expiration)
                {
                     cnnExpireDate = new Date( dateStringArray[1], dateStringArray[2] - 1, dateStringArray[3] );

                     if ( cnnExpireDate.getTime() < cnnSiteWideCurrDate.getTime() )
                     {
                          launchFreePlayer = false;
                     }
                
				}                      
         }
		
		return launchFreePlayer;
}

function LaunchVideo( videoPath ) {
	var videoDate = "";
	var cnnVideoDatePathRegExp = /(\d{4})\/(\d{2})\/(\d{2})/;
	var cnnVideoDatePathArray = cnnVideoDatePathRegExp.exec( videoPath );
	
	if ( cnnVideoDatePathArray )
	{
		var originalDate = new Date( parseInt( cnnVideoDatePathArray[1] ), parseInt( cnnVideoDatePathArray[2] ) - 1, parseInt( cnnVideoDatePathArray[3] ) );
		var expireDate = new Date( originalDate.getTime() + ( 7 * 24 * 60 * 60 * 1000 ) );
		var expireYear = new String( expireDate.getFullYear() );
		var expireMonth = new String( expireDate.getMonth() + 1 );
		var expireDay = new String( expireDate.getDate() );
		
		if ( expireMonth.length < 2 ) {
			expireMonth = '0' + expireMonth;
		}
		
		if ( expireDay.length < 2 ) {
			expireDay = '0' + expireDay;
		}
		
		videoDate = expireYear + '/' + expireMonth + '/' + expireDay;
	}
	
	cnnVideo( 'play', '/video' + videoPath.substring( 0, ( videoPath.length - 1 ) ), videoDate );
}


// _____________________________________________________ Pipeline

function cnnDetectCNNPipeLine() {
	
	if( detectPlugin( 'CNN Pipeline') ) { return 1;}
    
	if((window.ActiveXObject && navigator.userAgent.indexOf('Windows') != -1) || window.GeckoActiveXObject) {
       	if(createActiveXObject('PipelineLauncherX.PipelineLauncherCom.1') || createActiveXObject('CNNPipelineLauncherX.PipelineLauncherCom.1')){ return 2;}
	}
	
	return 0;

}

var CNN_Player_Pref;
var CNN_Stream_Name;
var CNN_req_Premium_Auth;
var cnnHasCNNPL = cnnDetectCNNPipeLine();
var CNN_FreePassDate = new Date(2006,10,6);
var CNN_FreePassURL = '/linkto/pipeline/preview.html';

		
if(!document.getElementById('cnnPipelineLauncher')) {

	if(cnnHasCNNPL==2) {
		document.write('<OBJECT ID="cnnPipelineLauncher" height="0" width="0" CLASSID="CLSID:BB815F16-1FF7-4DF1-87EE-68381DC3FDC2"></OBJECT>');
	}
	else if(cnnHasCNNPL == 1) {
	
		document.write('<embed type="application/x-vnd-cnn-pipeline" width="0" id="cnnPipelineLauncher" height="0" hidden="true">');
		if(document.getElementById) { var cnnFFTest = document.getElementById('cnnPipelineLauncher');}

	}

}

function cnnLaunchFreePlayer(mode, arg, expiration) {

	var playerURL    = '/video/player/player.html';
	var detectURL    = '/video/player/detect.exclude.html';
	var predetectURL = '/video/player/predetect.exclude.html';
	var noplugURL    = '/video/player/pages/detection/noplugin.html';
	var noplugURL    = '/video/player/player.html';
	var expireURL    = '/video/player/player.html';
	var openURL      = detectURL;
	var cnnVideoArgs = '';
	var dl_arg = '';
	var dl_mode = '';
	
	//var usePipeLinePlayer = cnnDetectCNNPipeLine();
	  var usePipeLinePlayer = false;

	if (detectWindowsMedia()) {
		var cnnPassedDetection = new String( WM_readCookie( 'cnnVidPlug' ) ).toLowerCase();
		if ( cnnPassedDetection == "activex" || cnnPassedDetection == "native" ) {
			openURL = playerURL;
		}
	}
	else {
		openURL = noplugURL;
	}
	switch ( mode )	{

		case 'play':

			var cnnExpireDate = new Date( new Date().getTime() - 24*60*60*1000 );
			var dateStringRegExp = /^(\d{4})\/(\d{2})\/(\d{2})$/;
			var dateStringArray = dateStringRegExp.exec( expiration );
						
			if ( dateStringArray && expiration)
			{
				cnnExpireDate = new Date( dateStringArray[1], dateStringArray[2] - 1, dateStringArray[3] );
			} else {
				cnnExpireDate = cnnSiteWideCurrDate;
			}
					
			if ( cnnExpireDate.getTime() < cnnSiteWideCurrDate.getTime() )
			{
				if ( cnnPassedDetection == "activex" || cnnPassedDetection == "native" )
				{
						openURL = expireURL;
				}
				else {
						openURL = detectURL;
				}				
				cnnVideoArgs = 'url=/video/player/static/404'
				CNN_req_Premium_Auth = true;

			}
			else
			{
				cnnVideoArgs = 'url=' + arg;
			}
			dl_mode = 'vod';
			dl_arg = '&video=' + arg;
			break;
		
		case 'browse':
			cnnVideoArgs = 'section=' + arg;
			break;
			
		case 'live':
			cnnVideoArgs = 'url=/video/player/static/404'
			CNN_req_Premium_Auth = true;
			dl_mode = 'live';
			dl_arg = '&stream=' + arg;
			break;

		default:
			cnnVideoArgs = 'section=/ALL';
			break;
			
	}
	
	if(((window.location.hostname.indexOf('search.cnn.com')>-1)||(window.location.hostname.indexOf('audience.cnn.com')>-1)) && (openURL.indexOf('http://')==-1) ) {
		openURL='http://www.cnn.com'+openURL;
	}	
	
	if(CNN_req_Premium_Auth) {
		
		top.location.href = "/pr/pipeline/download.html?mode=" + dl_mode + dl_arg;
		
	}
	else { 
	
		CNN_openPopup( openURL+'?'+cnnVideoArgs, 'CNNVideoPlayer', 'scrollbars=no,resizable=no,width=770,height=570' );
		
	}

}

function cnnLaunchWebPlayer(mode, arg, expiration) {
	var cnnFreePreview = (cnnSiteWideCurrDate.getTime() == CNN_FreePassDate.getTime() && !WM_readCookie('CNN_Player_Pref')) ? true : false;
	var wp_height = (cnnFreePreview) ? '646' : '604';
	var playerURL = (cnnFreePreview) ? CNN_FreePassURL : '/pr/video/portable/player.html';
	if(!WM_readCookie('oneaday') && (WM_readCookie('CNN_Player_Pref') != 'web_based')) {
		playerURL = '/video/portable/promoplayer.html';
		wp_height = '646';
	}	

	var openURL      = playerURL;
	var cnnVideoArgs = '';

	switch ( mode )	{

		case 'play':
			cnnVideoArgs = 'mode=vod&video=' + arg;
			break;
		
		case 'browse':
			cnnVideoArgs = 'mode=browse&section=' + arg + '&sectionDir=' + arg.toLowerCase();
			break;
			
		case 'live':
			cnnVideoArgs = 'mode=live&stream=' + arg;
			break;

		default:
			cnnVideoArgs = 'section=/ALL';
			break;
			
	}

	cnnVideoArgs += '&source=pop/';
	
	CNN_openPopup( openURL+'?'+cnnVideoArgs, 'CNNWebPlayer', 'scrollbars=no,resizable=no,width=804,height='+wp_height);

}

function cnnLaunchPipelineApp(mode, arg, expiration) {
	
	var pipelineLaunchObj = document.getElementById('cnnPipelineLauncher');
	var launchFree = false;
	
	if(!pipelineLaunchObj) { launchFree = true; }
	if(pipelineLaunchObj && pipelineLaunchObj.CanLaunch("web")!=true) {
		launchFree = true;
	}
	
	if(launchFree) {
		
		cnnLaunchFreePlayer(mode, arg, expiration);
	
	}
	else {
	
		if(WM_readCookie('CNN_Stream_Name')) {
			CNN_Stream_Name = WM_readCookie('CNN_Stream_Name');
		}
		else {
			CNN_Stream_Name = '';
		}
		
		switch ( mode )	{
			
			case 'play':
				var cmd = '<commands><command name="playVOD">http://premium.cnn.com/pr'+arg+'/video.ws.asx</command></commands>';
				pipelineLaunchObj.Launch(cmd,'');
				break;
		
			case 'browse':
				pipelineLaunchObj.Launch('<commands><command name="changeMode">MaxMode</command><command name="changeTab">BrowseVideo</command><command name="playLive">pipeline_1</command></commands>','');
				break;
			
			case 'live':
				pipelineLaunchObj.Launch('<commands><command name="changeMode">MaxMode</command><command name="playLive">pipeline_' + arg + CNN_Stream_Name + '</command></commands>','');
				break;

			default:
				pipelineLaunchObj.Launch('<commands><command name="changeMode">MaxMode</command><command name="changeTab">BrowseVideo</command><command name="playLive">pipeline_1</command></commands>','');
				break;
		
		}

	}
	
}

function cnnLaunchPreviewWebPlayer(mode, arg, expiration)
{
        var launchFreePlayer = true;
        if(cnnSiteWideCurrDate.toUTCString() == CNN_FreePassDate.toUTCString())
        {
               if(mode=='live') {launchFreePlayer = false;}
               else if(mode=='play')
                {
                        var cnnExpireDate = new Date( new Date().getTime() - 24*60*60*1000 );
                       var dateStringRegExp = /^(\d{4})\/(\d{2})\/(\d{2})$/;
                       var dateStringArray = dateStringRegExp.exec( expiration );                
                       if ( dateStringArray && expiration)
                       {
                              cnnExpireDate = new Date( dateStringArray[1], dateStringArray[2] - 1, dateStringArray[3] );

                              if ( cnnExpireDate.getTime() < cnnSiteWideCurrDate.getTime() )
                              {
                                      launchFreePlayer = false;
                              }
                       }                      
               }
        }
        return launchFreePlayer;
}
function detectPlugin() {
	// allow for multiple checks in a single pass
	var daPlugins = arguments;
	// consider pluginFound to be false until proven true
	var pluginFound = false;
	// if plugins array is there and not fake
	if ( navigator.plugins && navigator.plugins.length > 0 ) {
		var pluginsArrayLength = navigator.plugins.length;
		// for each plugin...
		for ( var pluginsArrayCounter = 0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) {
			// loop through all desired names and check each against the current plugin name
			var numFound = 0;
			for ( var namesCounter = 0; namesCounter < daPlugins.length; namesCounter++ ) {
				// if desired plugin name is found in either plugin name or description
				if ( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) ||
					(navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) ) {
					// this name was found
					numFound++;
				}
			}
			// now that we have checked all the required names against this one plugin,
			// if the number we found matches the total number provided then we were successful
			if ( numFound == daPlugins.length ) {
				pluginFound = true;
				// if we've found the plugin, we can stop looking through at the rest of the plugins
				break;
			}
		}
	}
	return pluginFound;
} // detectPlugin
function createActiveXObject(id){
  var error;
  var control = null;

  try{
    if (window.ActiveXObject){
      control = new ActiveXObject(id);
    }else if (window.GeckoActiveXObject){
      control = new GeckoActiveXObject(id);
    }
  }
  catch (error){;}
  return control;
}
var cnnSiteWideCurrDate = new Date();
function detectQuickTime() {
	pluginFound = detectPlugin( 'QuickTime' );
	// if not found, try to detect with VisualBasic
	if ( !pluginFound && detectableWithVB ) {
		pluginFound = detectQuickTimeActiveXControl();
	}
	return pluginFound;
}

function detectReal() {
	pluginFound = detectPlugin( 'RealPlayer' );
	// if not found, try to detect with VisualBasic
	if ( !pluginFound && detectableWithVB ) {
		pluginFound = ( detectActiveXControl('rmocx.RealPlayer G2 Control') ||
			detectActiveXControl('RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)') ||
			detectActiveXControl('RealVideo.RealVideo(tm) ActiveX Control (32-bit)')
		);
	}
	return pluginFound;
}

function detectRealOne() {
	pluginFound = detectPlugin( 'RealOne Player Version Plugin' ) || detectPlugin( 'RealPlayer Version Plugin' );
	// if not found, try to detect with VisualBasic
	if ( !pluginFound && detectableWithVB ) {
		pluginFound = detectRealOneActiveXControl();
	}
	return pluginFound;
}

function detectWindowsMedia() {
	pluginFound = detectPlugin( 'Windows Media' );
	// if not found, try to detect with VisualBasic
//	if ( !pluginFound && detectableWithVB ) {
//		pluginFound = detectActiveXControl( 'MediaPlayer.MediaPlayer.1' );
//	}
	if ( !pluginFound && detectWMPSupport() ) {
		pluginFound = true;
	}
	return pluginFound;
}

function detectWMPSupport(){

    var wmp64 = "MediaPlayer.MediaPlayer.1";
    var wmp7 = "WMPlayer.OCX.7";
    if((window.ActiveXObject && navigator.userAgent.indexOf('Windows') != -1) || window.GeckoActiveXObject)
    {
        if(createActiveXObject(wmp7)){ 
            return true;

        }else{
            if(createActiveXObject(wmp64)){
                return true;
            }else{
                return false;
            }
        }
    }else{ 
        return false;
    }
}

  function getObj(name) {
             if (document.getElementById) {
                 if (this.obj = document.getElementById(name))
                     this.style = document.getElementById(name).style;
                 else
                     this.style = this.obj;
             } else if (document.all) {
                 if (this.obj = document.all[name])
                     this.style = document.all[name].style;
                 else
                     this.style = this.obj;
             } else if (document.layers) {
                 this.obj = getObjNN4(document, name);
                 this.style = this.obj;
             }
         }

         function getObjNN4(obj, name) {
             var x = obj.layers;
             var foundLayer;
             for (var i = 0; i < x.length; i++) {
                 if (x[i].id == name)
                     foundLayer = x[i];
                 else if (x[i].layers.length)
                     var tmp = getObjNN4(x[i], name);
                 if (tmp) foundLayer = tmp;
             }
             return foundLayer;
         }

         // ----------------------------------------------------------------------------

         var totalPagesNumber, currentPageNumber;
         var oCurrentPage, oButtonPagePrev, oButtonPageNext;
         var currentButtonHTML = '', prevButtonHTML = '', nextButtonHTML = '';

         function cnnMtBodyOnLoad() {

             var i = 1, o;
             while ((o = new getObj('Page' + i)) && o.obj) ++i;
             totalPagesNumber = i - 1;

             var strPagerContent = '<table><tr><td align="center"><table class="cnnPagination" align="center"><tr>';
             strPagerContent += '<td id="liGoToPagePrev"><a href="#aCurrentPage" id="buttonPagePrev" class="pagerButton" onClick="goToPage(\'prev\');" onMouseOver="window.status = \'\'; return true;"><b class="cnnArrows">&laquo;</b> &#1575;&#1604;&#1587;&#1575;&#1576;&#1602;</a></td>';
             for (var i = 0; i < totalPagesNumber; ++i) {
                 var j = i + 1;
                 strPagerContent += '<td id="liGoToPage' + j + '"><a href="#aCurrentPage" id="buttonPage' + j + '" class="pagerButton" onClick="goToPage(' + j + ');">' + j + '</a></td>';
             }
             strPagerContent += '<td id="liGoToPageNext"><a href="#aCurrentPage" id="buttonPageNext" class="pagerButton" onClick="goToPage(\'next\');" onMouseOver="window.status = \'\'; return true;">&#1575;&#1604;&#1578;&#1575;&#1604;&#1610; <b class="cnnArrows">&raquo;</b></a></td>';
             strPagerContent += '</tr></table></td></tr></table>';
             var oPager = new getObj('cnnPagination');
             if (oPager) oPager.obj.innerHTML = strPagerContent;

             oButtonPagePrev = new getObj('buttonPagePrev');
             oButtonPageNext = new getObj('buttonPageNext');
             oCurrentPage = new getObj('currentPage');

             goToPage(1);
         }

         function goToPage(page) {
             if (page && page == 'next')
                 page = currentPageNumber + 1;
             else if (page && page == 'prev')
                 page = currentPageNumber - 1;
             if (!page || isNaN(page) || page < 1)
                 var page = 1;
             else if (page > totalPagesNumber)
                 page = totalPagesNumber;

             if (currentPageNumber == page) return; else {
                 var oldPageNumber = currentPageNumber;
                 currentPageNumber = page;
             }

             var o = new getObj('Page' + page);
             if (o && o.obj) {
                 oCurrentPage.obj.innerHTML = o.obj.innerHTML;

                 // Change current page number style and link
                 if ((o = new getObj('buttonPage' + page)) && o.obj)
                     o.obj.className = 'pagerButtonActive';

                 // Remove link on active element
                 if ((o = new getObj('liGoToPage' + oldPageNumber)) && o.obj && o.obj.innerHTML && currentButtonHTML)
                     o.obj.innerHTML = currentButtonHTML;
                 if ((o = new getObj('liGoToPage' + page)) && o.obj && o.obj.innerHTML) {
                     currentButtonHTML = o.obj.innerHTML;
                     o.obj.innerHTML = '<span class="pagerButtonActive">&#160;' + page + '&#160;</span>';
                 }

                 // Change previously viewed page number style
                 if ((o = new getObj('buttonPage' + oldPageNumber)) && o.obj)
                     o.obj.className = 'pagerButtonViewed';

                 // Show/Hide prev button if on first page
                 o = new getObj('liGoToPagePrev');
                 if (page == 1) {
                     prevButtonHTML = o.obj.innerHTML;
                     o.obj.innerHTML = '<span class="pagerButtonActive prevNextPagerButtonActive"><b class="cnnArrows">&laquo;</b> &#1575;&#1604;&#1587;&#1575;&#1576;&#1602;</span>';
                 } else if (prevButtonHTML > '') {
                     o.obj.innerHTML = prevButtonHTML;
                     prevButtonHTML = '';
                 }
                 // Show/Hide next button if on last page
                 o = new getObj('liGoToPageNext');
                 if (page == totalPagesNumber) {
                     nextButtonHTML = o.obj.innerHTML;
                     o.obj.innerHTML = '<span class="pagerButtonActive prevNextPagerButtonActive">&#1575;&#1604;&#1578;&#1575;&#1604;&#1610; <b class="cnnArrows">&raquo;</b></span>';
                 } else if (nextButtonHTML > '') {
                     o.obj.innerHTML = nextButtonHTML;
                     nextButtonHTML = '';
                 }
             }
         }
