
function cnnMpOnUpdateBtns() {
	// left btn
	if(cnnMpOnCurPage > 0) {
		$('cnnMpOnL').style.cursor ='auto';
		$('cnnMpOnL').src = 'http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/left_red_btn.gif';
		$('cnnMpOnL').onmouseover = function() {this.src='http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/left_red_over_btn.gif';}
		$('cnnMpOnL').onmouseout = function() {this.src='http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/left_red_btn.gif';}
	}
	else {
		$('cnnMpOnL').style.cursor ='default';
		$('cnnMpOnL').src = 'http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/left_gray_btn.gif';
		$('cnnMpOnL').onmouseover = function() {}
		$('cnnMpOnL').onmouseout = function() {}
	}

	// move the dot
	for(i=0;i<cnnMpOnNumPages;i++) {
		$('cnnMpOnDot'+i).src = 'http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/gray_status.gif';
		$('cnnMpOnDot'+i).onmouseover = function() {this.src = 'http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/gray_active_status.gif';}
		$('cnnMpOnDot'+i).onmouseout = function() {this.src = 'http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/gray_status.gif';}
	}
	$('cnnMpOnDot'+cnnMpOnCurPage).src = 'http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/gray_active_status.gif';
	$('cnnMpOnDot'+cnnMpOnCurPage).onmouseover = function() {}
	$('cnnMpOnDot'+cnnMpOnCurPage).onmouseout = function() {}

	// right btn
	if(cnnMpOnCurPage < (cnnMpOnNumPages-1)) {
		$('cnnMpOnR').src = 'http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/right_red_btn.gif';
		$('cnnMpOnR').onmouseover = function() {this.src='http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/right_red_over_btn.gif';}
		$('cnnMpOnR').onmouseout = function() {this.src='http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/right_red_btn.gif';}
	}
	else {
		$('cnnMpOnR').src = 'http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/right_gray_btn.gif';
		$('cnnMpOnR').onmouseover = function() {}
		$('cnnMpOnR').onmouseout = function() {}
	}
}

function cnnInitOtherNews() {
	// must use javascript to initially hide or scriptaculous effect won't work
	for(i=0;i<8;i++) { // setting a max possible of 8 pages here
		if($('cnnOnSects' + i)) {
			$('cnnOnSects' + i).style.display = 'none';
		}
	}
	cnnDrawOnButtons();
	$('cnnOnSects0').style.display = 'block';
	$('cnnOtherNews').style.display = 'block';
}

function cnnDrawOnButtons() {
	var str = '';
	str += '<a href="javascript:void(0);" onclick="javascript:cnnMpOnPrev(this);return false;"><img src="http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/left_gray_btn.gif" alt="" class="cnnONBtn" border="0" height="19" width="26" id="cnnMpOnL"></a>';
	str += '<a href="javascript:void(0);" onclick="javascript:cnnMpOnJumpTo(0,this);return false;"><img src="http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/gray_active_status.gif" class="cnnONStatus" alt="" border="0" height="5" width="5" id="cnnMpOnDot0"></a>';
	for(i=1;i<cnnMpOnNumPages;i++) {
		str += '<a href="javascript:void(0);" onclick="javascript:cnnMpOnJumpTo(' + i + ',this);return false;"><img src="http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/gray_status.gif" onmouseover="this.src=\'http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/gray_active_status.gif\'" onmouseout="this.src=\'http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/gray_status.gif\'" class="cnnONStatus" alt="" border="0" height="5" width="5" id="cnnMpOnDot'+ i +'"></a>';
	}
	str += '<a href="javascript:void(0);" onclick="javascript:cnnMpOnNext(this);return false;"><img src="http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/right_red_btn.gif" alt="" onmouseover="this.src=\'http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/right_red_over_btn.gif\'" onmouseout="this.src=\'http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/right_red_btn.gif\'" class="cnnONBtn" border="0" height="19" width="26" id="cnnMpOnR"></a>';
	$('cnnONBtns').innerHTML = str;
}
/* end main page more stories
===================================================================== */





function cnnUpdateSrchTypeLnks( searchType ) {
	if($('cnnHeadSrchTypeArea')) {
		switch(searchType) {
			case 'web':
				$('cnnHeadSrchTypeArea').innerHTML = '<span class="cnnSearchLabel">Web</span> | <a href="javascript:cnnUpdateSrchType(\'news\');">CNN News</a> | <a href="javascript:cnnUpdateSrchType(\'video\');">CNN Videos</a>';
				break;
			case 'news':
				$('cnnHeadSrchTypeArea').innerHTML = '<a href="javascript:cnnUpdateSrchType(\'web\');">Web</a> | <span class="cnnSearchLabel">CNN News</span> | <a href="javascript:cnnUpdateSrchType(\'video\');">CNN Videos</a>';
				break;
			case 'video':
				$('cnnHeadSrchTypeArea').innerHTML = '<a href="javascript:cnnUpdateSrchType(\'web\');">Web</a> | <a href="javascript:cnnUpdateSrchType(\'news\');">CNN News</a> | <span class="cnnSearchLabel">CNN Videos</span>';
				break;
			default:
				break;
		}
	}
}

/* end search functions
===================================================================== */

/* cnn live video popup
===================================================================== */
var cnnVidServer = '';
function cnnLiveVideo( strWhich ) {
	if(!strWhich) {
		strWhich = '1';
	}
	var strVidLoc = cnnVidServer + '/video/live/live.html?stream=stream' + strWhich;
	javascript:CNN_openPopup(strVidLoc,'liveplayer','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=672,height=540')
}
/* end cnn live video popup
===================================================================== */


function cnnVideo(mode, arg, expiration) {
	video_url = '/video/#' + arg;

	if(mode == 'live') { cnnLiveVideo(arg); }
	else if(top.location == self.location) { location.href = video_url; }
	else { vid_win = window.open(video_url, 'vid_win'); }
}


/* main page video box (domestic & intl)
===================================================================== */
var cnnMpVpCurPage = 1;
var cnnMpVpLock = false;
function cnnMpVpBlur( lnk ) {
	try {
		lnk.blur();
	} catch(e) {};
}
/*
 * cnnMpVpNext() and cnnMpVpPrev()
 * are called from previous and next buttons
 */
function cnnMpVpNext( lnk ) {
	cnnMpVpBlur( lnk );
	if((cnnMpVpCurPage < 3)&&(!cnnMpVpLock)) {
		cnnMpVpSlideLeft();
	}
}

function cnnMpVpPrev( lnk ) {
	cnnMpVpBlur( lnk );
	if((cnnMpVpCurPage > 1)&&(!cnnMpVpLock)) {
		cnnMpVpSlideRight();
	}
}

/*
 * cnnMpVpPage( intPage )
 * called from clicking on gray dot icon
 */
function cnnMpVpPage( intPage, lnk ) {
	cnnMpVpBlur( lnk );
	if((cnnMpVpCurPage != intPage)&&(!cnnMpVpLock)) {
		if(cnnMpVpCurPage < intPage) {
			if((intPage - cnnMpVpCurPage) > 1) {
				cnnMpVpSlideDoubleLeft();
			}
			else {
				cnnMpVpSlideLeft();
			}
		}
		else {
			if((cnnMpVpCurPage - intPage) > 1) {
				cnnMpVpSlideDoubleRight();
			}
			else {
				cnnMpVpSlideRight();
			}
		}
	}
}

function cnnLockMpVp( intDur ) {
	var cnnLockDur = intDur * 100;
	cnnMpVpLock = true;
	setTimeout(function() { cnnMpVpLock = false; },cnnLockDur);
}
function cnnMpVpSlideLeft() {
	cnnLockMpVp(3);
	new Effect.MoveBy( 'cnnMpVidCtnt0', 0, -336 , {duration: 0.3} );
	new Effect.MoveBy( 'cnnMpVidCtnt1', 0, -336 , {duration: 0.3} );
	new Effect.MoveBy( 'cnnMpVidCtnt2', 0, -336 , {duration: 0.3} );
	cnnMpVpCurPage++;
	cnnMpVpMoveDot();
	cnnMpVpUpdateBtns();
}

function cnnMpVpSlideDoubleLeft() {
	cnnLockMpVp(6);
	new Effect.MoveBy( 'cnnMpVidCtnt0', 0, -672 , {duration: 0.6} );
	new Effect.MoveBy( 'cnnMpVidCtnt1', 0, -672 , {duration: 0.6} );
	new Effect.MoveBy( 'cnnMpVidCtnt2', 0, -672 , {duration: 0.6} );
	cnnMpVpCurPage++;
	cnnMpVpCurPage++;
	cnnMpVpMoveDot();
	cnnMpVpUpdateBtns();
}

function cnnMpVpSlideRight() {
	cnnLockMpVp(3);
	new Effect.MoveBy( 'cnnMpVidCtnt0', 0, 336 , {duration: 0.3} );
	new Effect.MoveBy( 'cnnMpVidCtnt1', 0, 336 , {duration: 0.3} );
	new Effect.MoveBy( 'cnnMpVidCtnt2', 0, 336 , {duration: 0.3} );
	cnnMpVpCurPage--;
	cnnMpVpMoveDot();
	cnnMpVpUpdateBtns();
}

function cnnMpVpSlideDoubleRight() {
	cnnLockMpVp(6);
	new Effect.MoveBy( 'cnnMpVidCtnt0', 0, 672 , {duration: 0.6} );
	new Effect.MoveBy( 'cnnMpVidCtnt1', 0, 672 , {duration: 0.6} );
	new Effect.MoveBy( 'cnnMpVidCtnt2', 0, 672 , {duration: 0.6} );
	cnnMpVpCurPage--;
	cnnMpVpCurPage--;
	cnnMpVpMoveDot();
	cnnMpVpUpdateBtns();
}

function cnnMpDotMouseOver( id ) {
	$(id).src = 'http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/gray_active_status.gif';
}

// image change functions
function cnnMpVpMoveDot() {
	for(i=1;i<4;i++) {
		$('cnnMpVidDot'+i).src = 'http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/gray_status.gif';
		$('cnnMpVidDot'+i).onmouseover = function() {this.src = 'http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/gray_active_status.gif';}
		$('cnnMpVidDot'+i).onmouseout = function() {this.src = 'http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/gray_status.gif';}
	}
	$('cnnMpVidDot'+cnnMpVpCurPage).src = 'http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/gray_active_status.gif';
	$('cnnMpVidDot'+cnnMpVpCurPage).onmouseover = function() {}
	$('cnnMpVidDot'+cnnMpVpCurPage).onmouseout = function() {}
}
function cnnMpVpUpdateBtns() {
	if(cnnMpVpCurPage > 1) {
		$('cnnMpVidBtnL').style.cursor ='auto';
		$('cnnMpVidBtnL').src = 'http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/left_red_btn.gif';
		$('cnnMpVidBtnL').onmouseover = function() { this.src='http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/left_red_over_btn.gif'; }
		$('cnnMpVidBtnL').onmouseout = function() { this.src='http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/left_red_btn.gif'; }
	}
	else {
		$('cnnMpVidBtnL').style.cursor ='default';
		$('cnnMpVidBtnL').src = 'http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/left_gray_btn.gif';
		$('cnnMpVidBtnL').onmouseover = function() {}
		$('cnnMpVidBtnL').onmouseout = function() {}
	}

	if(cnnMpVpCurPage < 3) {
		$('cnnMpVidBtnR').style.cursor ='auto';
		$('cnnMpVidBtnR').src = 'http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/right_red_btn.gif';
		$('cnnMpVidBtnR').onmouseover = function() {this.src = 'http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/right_red_over_btn.gif';}
		$('cnnMpVidBtnR').onmouseout = function() {this.src = 'http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/right_red_btn.gif';}
	}
	else {
		$('cnnMpVidBtnR').style.cursor ='default';
		$('cnnMpVidBtnR').src = 'http://i.cdn.turner.com/cnn/.element/img/2.0/content/in_the_news/right_gray_btn.gif';
		$('cnnMpVidBtnR').onmouseover = function() {}
		$('cnnMpVidBtnR').onmouseout = function() {}
	}
}
/* end main page video box
===================================================================== */
