// JavaScript Document

/*======================================================================
*  Variables Declaration
======================================================================*/

// Variables to modify when set new image
var iRecursiveDelay = 100;
var iSpeed = 5;

var iFrameWidth = 519;
var iFrameHeight = 133;
var iPicWidth = 900;
var iPicHeight = 640;


// NEVER CHANGE THOSE VARIABLES
var iNewInterval;

var iPos_x = 0;
var iPos_y = 0;
var iActualPos_x = iPos_x;
var iActualPos_y = iPos_y;



/*======================================================================
*  Functions Declaration
======================================================================*/

// Function used to call set the new X & Y pos and start the interval
//======================================================================
function fCallScroll(iNewPos_x, iNewPos_y) {

	iPos_x = Math.min(Math.max(iNewPos_x, 0), iPicWidth - iFrameWidth);
	iPos_y = Math.min(Math.max(iNewPos_y, 0), iPicHeight - iFrameHeight);
	
	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;
	iActualPos_y += (iPos_y - iActualPos_y) / iSpeed;
	
	picContent.scrollTo(iActualPos_x, iActualPos_y);
	
	if(Math.abs(iActualPos_x - iPos_x) <= 1 && Math.abs(iActualPos_y - iPos_y) <= 1)	
		fStopScroll();
}



// Function used to stop the interval 
//======================================================================
function fStopScroll() {

	iActualPos_x = iPos_x;
	iActualPos_y = iPos_y;
	
	clearInterval(iNewInterval);
}



