/* main page video box (domestic & intl)
===================================================================== */
var bhpMpVpCurPage = 1;
var bhpMpVpLock = false;
bhpMpVpUpdateBtns();
function bhpMpVpBlur( lnk ) {
	try {
		lnk.blur();
	} catch(e) {};
}
/*
 * bhpMpVpNext() and bhpMpVpPrev()
 * are called from previous and next buttons
 */
function bhpMpVpNext( lnk ) {
	bhpMpVpBlur( lnk );
	if((bhpMpVpCurPage < 4)&&(!bhpMpVpLock)) {
		bhpMpVpSlide("left", 1);
	}
}

function bhpMpVpPrev( lnk ) {
	bhpMpVpBlur( lnk );
	if((bhpMpVpCurPage > 1)&&(!bhpMpVpLock)) {
		bhpMpVpSlide("right", 1);
	}
}

/*
 * bhpMpVpPage( intPage )
 * called from clicking on gray dot icon
 */
function bhpMpVpPage( intPage, lnk ) {
	bhpMpVpBlur( lnk );
	if((bhpMpVpCurPage != intPage)&&(!bhpMpVpLock)) {
		if(bhpMpVpCurPage < intPage) {
			bhpMpVpSlide("left", (intPage - bhpMpVpCurPage));
		}
		else {
			bhpMpVpSlide("right", (bhpMpVpCurPage - intPage));
		}
	}
}

function bhpLockMpVp( intDur ) {
	var bhpLockDur = intDur * 100;
	bhpMpVpLock = true;
	setTimeout(function() { bhpMpVpLock = false; },bhpLockDur);
}
function bhpMpVpSlide(sDirection, nTimes) {
	bhpLockMpVp(2 * nTimes);
	var nDuration = 0.3;
	var nDistance = 450;
	var nDirection;
	if(sDirection == "left"){
		nDirection=-1;
	}else{
		nDirection=1;
	}
	
	var totalMovement = nDirection * nDistance * nTimes;
	var totalDuration = nDuration *  nTimes;
	
	new Effect.MoveBy( 'bhpMpVidCtnt0', 0, totalMovement , {duration: totalDuration} );
	new Effect.MoveBy( 'bhpMpVidCtnt1', 0, totalMovement , {duration: totalDuration} );
	new Effect.MoveBy( 'bhpMpVidCtnt2', 0, totalMovement , {duration: totalDuration} );
	new Effect.MoveBy( 'bhpMpVidCtnt3', 0, totalMovement , {duration: totalDuration} );
	bhpMpVpCurPage= bhpMpVpCurPage + (-1 * nDirection * nTimes);

	bhpMpVpUpdateBtns();
}


// image change functions
function bhpMpVpUpdateBtns() {
	if(bhpMpVpCurPage > 1) {
		$('bhpMpVidBtnL').style.cursor ='auto';
		$('bhpMpVidBtnL').style.background ='url(http://i.bloodhorse.com/MpVideo/Images/left_btn_100.gif) no-repeat top center'
	}
	else {
		$('bhpMpVidBtnL').style.cursor ='default';
		$('bhpMpVidBtnL').style.background = 'url(http://i.bloodhorse.com/MpVideo/Images/left_gray_btn_100.gif) no-repeat top center';
	}

	if(bhpMpVpCurPage < 4) {
		$('bhpMpVidBtnR').style.cursor ='auto';
		$('bhpMpVidBtnR').style.background ='url(http://i.bloodhorse.com/MpVideo/Images/right_btn_100.gif) no-repeat top center'
	}
	else {
		$('bhpMpVidBtnR').style.cursor ='default';
		$('bhpMpVidBtnR').style.background = 'url(http://i.bloodhorse.com/MpVideo/Images/right_gray_btn_100.gif) no-repeat top center';
	}
}