﻿
/* main page Audio box (domestic & intl)
===================================================================== */
var cnnMpApCurPage = 1;
var cnnMpApLock = false;
function cnnMpApBlur( lnk ) {
	try {
		lnk.blur();
	} catch(e) {};
}
/*
 * cnnMpApNext() and cnnMpApPrev()
 * are called from preAious and next buttons
 */
function cnnMpApNext( lnk ) {
	cnnMpApBlur( lnk );
	if((cnnMpApCurPage < 3)&&(!cnnMpApLock)) {
		cnnMpApSlideLeft();
	}
}

function cnnMpApPrev( lnk ) {
	cnnMpApBlur( lnk );
	if((cnnMpApCurPage > 1)&&(!cnnMpApLock)) {
		cnnMpApSlideRight();
	}
}

/*
 * cnnMpApPage( intPage )
 * called from clicking on gray dot icon
 */
function cnnMpApPage( intPage, lnk ) {
	cnnMpApBlur( lnk );
	if((cnnMpApCurPage != intPage)&&(!cnnMpApLock)) {
		if(cnnMpApCurPage < intPage) {
			if((intPage - cnnMpApCurPage) > 1) {
				cnnMpApSlideDoubleLeft();
			}
			else {
				cnnMpApSlideLeft();
			}
		}
		else {
			if((cnnMpApCurPage - intPage) > 1) {
				cnnMpApSlideDoubleRight();
			}
			else {
				cnnMpApSlideRight();
			}
		}
	}
}

function cnnLockMpAp( intDur ) {
	var cnnLockDur = intDur * 100;
	cnnMpApLock = true;
	setTimeout(function() { cnnMpApLock = false; },cnnLockDur);
}
function cnnMpApSlideLeft() {
	cnnLockMpAp(3);
	new Effect.MoveBy( 'cnnMpAidCtnt0', 0, -336 , {duration: 0.3} );
	new Effect.MoveBy( 'cnnMpAidCtnt1', 0, -336 , {duration: 0.3} );
	new Effect.MoveBy( 'cnnMpAidCtnt2', 0, -336 , {duration: 0.3} );
	cnnMpApCurPage++;
	cnnMpApMoveDot();
	cnnMpApUpdateBtns();
}

function cnnMpApSlideDoubleLeft() {
	cnnLockMpAp(6);
	new Effect.MoveBy( 'cnnMpAidCtnt0', 0, -672 , {duration: 0.6} );
	new Effect.MoveBy( 'cnnMpAidCtnt1', 0, -672 , {duration: 0.6} );
	new Effect.MoveBy( 'cnnMpAidCtnt2', 0, -672 , {duration: 0.6} );
	cnnMpApCurPage++;
	cnnMpApCurPage++;
	cnnMpApMoveDot();
	cnnMpApUpdateBtns();
}

function cnnMpApSlideRight() {
	cnnLockMpAp(3);
	new Effect.MoveBy( 'cnnMpAidCtnt0', 0, 336 , {duration: 0.3} );
	new Effect.MoveBy( 'cnnMpAidCtnt1', 0, 336 , {duration: 0.3} );
	new Effect.MoveBy( 'cnnMpAidCtnt2', 0, 336 , {duration: 0.3} );
	cnnMpApCurPage--;
	cnnMpApMoveDot();
	cnnMpApUpdateBtns();
}

function cnnMpApSlideDoubleRight() {
	cnnLockMpAp(6);
	new Effect.MoveBy( 'cnnMpAidCtnt0', 0, 672 , {duration: 0.6} );
	new Effect.MoveBy( 'cnnMpAidCtnt1', 0, 672 , {duration: 0.6} );
	new Effect.MoveBy( 'cnnMpAidCtnt2', 0, 672 , {duration: 0.6} );
	cnnMpApCurPage--;
	cnnMpApCurPage--;
	cnnMpApMoveDot();
	cnnMpApUpdateBtns();
}

function cnnMpDotMouseOver( id ) {
	$(id).src = 'Images/gray_active_status.gif';
}

// image change functions
function cnnMpApMoveDot() {
	for(i=1;i<4;i++) {
		$('cnnMpAidDot'+i).src = 'Images/gray_status.gif';
		$('cnnMpAidDot'+i).onmouseover = function() {this.src = 'Images/gray_active_status.gif';}
		$('cnnMpAidDot'+i).onmouseout = function() {this.src = 'Images/gray_status.gif';}
	}
	$('cnnMpAidDot'+cnnMpApCurPage).src = 'Images/gray_active_status.gif';
	$('cnnMpAidDot'+cnnMpApCurPage).onmouseover = function() {}
	$('cnnMpAidDot'+cnnMpApCurPage).onmouseout = function() {}
}
function cnnMpApUpdateBtns() {
	if(cnnMpApCurPage > 1) {
		$('cnnMpAidBtnL').style.cursor ='pointer';
		$('cnnMpAidBtnL').src = 'Images/left_red_btn.gif';
		$('cnnMpAidBtnL').onmouseover = function() { this.src='Images/left_red_over_btn.gif'; }
		$('cnnMpAidBtnL').onmouseout = function() { this.src='Images/left_red_btn.gif'; }
	}
	else {
		$('cnnMpAidBtnL').style.cursor ='pointer';
		$('cnnMpAidBtnL').src = 'Images/left_gray_btn.gif';
		$('cnnMpAidBtnL').onmouseover = function() {}
		$('cnnMpAidBtnL').onmouseout = function() {}
	}

	if(cnnMpApCurPage < 3) {
		$('cnnMpAidBtnR').style.cursor ='pointer';
		$('cnnMpAidBtnR').src = 'Images/right_red_btn.gif';
		$('cnnMpAidBtnR').onmouseover = function() {this.src = 'Images/right_red_over_btn.gif';}
		$('cnnMpAidBtnR').onmouseout = function() {this.src = 'Images/right_red_btn.gif';}
	}
	else {
		$('cnnMpAidBtnR').style.cursor ='pointer';
		$('cnnMpAidBtnR').src = 'Images/right_gray_btn.gif';
		$('cnnMpAidBtnR').onmouseover = function() {}
		$('cnnMpAidBtnR').onmouseout = function() {}
	}
}
/* end main page Audio box
===================================================================== */
