﻿/* 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, -220 , {duration: 0.3} );
 new Effect.MoveBy( 'cnnMpVidCtnt1', 0, -220 , {duration: 0.3} );
 new Effect.MoveBy( 'cnnMpVidCtnt2', 0, -220 , {duration: 0.3} );
 cnnMpVpCurPage++;
 cnnMpVpMoveDot();
 cnnMpVpUpdateBtns();
}

function cnnMpVpSlideDoubleLeft() {
 cnnLockMpVp(6);
 new Effect.MoveBy( 'cnnMpVidCtnt0', 0, -440 , {duration: 0.6} );
 new Effect.MoveBy( 'cnnMpVidCtnt1', 0, -440 , {duration: 0.6} );
 new Effect.MoveBy( 'cnnMpVidCtnt2', 0, -440 , {duration: 0.6} );
 cnnMpVpCurPage++;
 cnnMpVpCurPage++;
 cnnMpVpMoveDot();
 cnnMpVpUpdateBtns();
}

function cnnMpVpSlideRight() {
 cnnLockMpVp(3);
 new Effect.MoveBy( 'cnnMpVidCtnt0', 0, 220 , {duration: 0.3} );
 new Effect.MoveBy( 'cnnMpVidCtnt1', 0, 220 , {duration: 0.3} );
 new Effect.MoveBy( 'cnnMpVidCtnt2', 0, 220 , {duration: 0.3} );
 cnnMpVpCurPage--;
 cnnMpVpMoveDot();
 cnnMpVpUpdateBtns();
}

function cnnMpVpSlideDoubleRight() {
 cnnLockMpVp(6);
 new Effect.MoveBy( 'cnnMpVidCtnt0', 0, 440 , {duration: 0.6} );
 new Effect.MoveBy( 'cnnMpVidCtnt1', 0, 440 , {duration: 0.6} );
 new Effect.MoveBy( 'cnnMpVidCtnt2', 0, 440 , {duration: 0.6} );
 cnnMpVpCurPage--;
 cnnMpVpCurPage--;
 cnnMpVpMoveDot();
 cnnMpVpUpdateBtns();
}

function cnnMpDotMouseOver( id ) {
 $(id).src = '/images/btn_go_ed.gif';
}

// image change functions
function cnnMpVpMoveDot() {
 for(i=1;i<4;i++) {
 $('cnnMpVidDot'+i).src = '/images/btn_go_un.gif';
 $('cnnMpVidDot'+i).onmouseover = function() {this.src = '/images/btn_go_ed.gif';}
 $('cnnMpVidDot'+i).onmouseout = function() {this.src = '/images/btn_go_un.gif';}
 }
 $('cnnMpVidDot'+cnnMpVpCurPage).src = '/images/btn_go_ed.gif';
 $('cnnMpVidDot'+cnnMpVpCurPage).onmouseover = function() {}
 $('cnnMpVidDot'+cnnMpVpCurPage).onmouseout = function() {}
}
function cnnMpVpUpdateBtns() {
return;
 if(cnnMpVpCurPage > 1) {
 $('cnnMpVidBtnL').style.cursor ='auto';
 $('cnnMpVidBtnL').src = '/images/btn_go_left.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 = '/images/btn_go_left.gif';
// $('cnnMpVidBtnL').onmouseover = function() {}
// $('cnnMpVidBtnL').onmouseout = function() {}
 }

 if(cnnMpVpCurPage < 3) {
 $('cnnMpVidBtnR').style.cursor ='auto';
 $('cnnMpVidBtnR').src = '/images/btn_go_right.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 = '/images/btn_go_right.gif';
// $('cnnMpVidBtnR').onmouseover = function() {}
// $('cnnMpVidBtnR').onmouseout = function() {}
 }
}

