// JavaScript Document

/*======================================================================
*  Variables Declaration
======================================================================*/

// Variables to modify when set new image
var iRecursiveDelay = 50;
var iSpeed = 5;

var iFrameWidth = 492;
var iMoveWidth = 255;
var iPageWidth = 1540;


// NEVER CHANGE THOSE VARIABLES
var iNewInterval;

var iPos_x = 0;
var iActualPos_x = iPos_x;



/*======================================================================
*  Functions Declaration
======================================================================*/

// Function used to call set the new X & Y pos and start the interval
//======================================================================
function fCallScroll(bNextImg) {

	if(bNextImg)
		iPos_x = Math.min(Math.max(iPos_x + iMoveWidth, 0), iPageWidth - iFrameWidth);
	else
		iPos_x = Math.min(Math.max(iPos_x - iMoveWidth, 0), iPageWidth - iFrameWidth);
	
	clearInterval(iNewInterval);
	iNewInterval = window.setInterval('fMovePage()', iRecursiveDelay);
}



// Function used to move the image(html page) in the iframe
//======================================================================
function fMovePage() {
	
	iActualPos_x += (iPos_x - iActualPos_x) / iSpeed;
	
	picContent.scrollTo(iActualPos_x, 0);
	
	if(Math.abs(iActualPos_x - iPos_x) <= 1)	
		fStopScroll();
}



// Function used to stop the interval 
//======================================================================
function fStopScroll() {

	iActualPos_x = iPos_x;
	clearInterval(iNewInterval);
}



