


// functions to check if mouse is over arrows
var SUp = false;
var SDown = false;

function startScrollUp()
	{
		SUp = true;
	}

function stopScrollUp()
	{
		SUp = false;
	}

function startScrollDown()
	{
		 SDown = true;
	}

function stopScrollDown()
	{
		SDown = false;
	}

function setnewPos(P)
	{
		newPos = P;
	}


// functions to start scrolling in image and text layers(if mouseover)
function setScroll()
	{
	setTimeout("setScroll()",48);
		if (SUp == true)
			{	
				scrollUp('text');
			}		

		if (SDown == true)
			{	
				scrollDown('text');
			}
		if (newPos != Pos)
			{
				sampleScroll();
			}
	 imageScroll();
	}
 


// functions to scroll text

// If text has not reached it's highest allowable point, scroll up
function scrollUp(L)
	{
		if ((textHeight + textPos) <= textHeight)
			{
				textPos = (textPos + textSpeed)
				moveLayerTo(getLayer(L),0,textPos);
			}
	}

// If text has not reached it's lowest allowable point, scroll down
function scrollDown(L)
	{

		if ((textHeight + textPos)  > 125)
			{
				textPos = (textPos - textSpeed)
				moveLayerTo(getLayer(L),0,textPos);
			}

	
	}

// Function to scroll images
function imageScroll()
{
	if (image1Pos > (0 - (imageWidth - imageSpeed)))
		{
			image1Pos = image1Pos - imageSpeed;
			moveLayerTo(getLayer('image1'),image1Pos,0)
		}
	else
		{
			image1Pos = imageWidth;
			moveLayerTo(getLayer('image1'),image1Pos,0)
		}
	if (image2Pos > (0 - (imageWidth - imageSpeed)))
		{
			image2Pos = image2Pos - imageSpeed;
			moveLayerTo(getLayer('image2'),image2Pos,0)
		}
	else
		{
			image2Pos = imageWidth;
			moveLayerTo(getLayer('image2'),image2Pos,0)
		}
	}

function sampleScroll()
{
var toMove;

if (newPos > Pos)
	{
	if (newPos > (Pos + 5))
		{
			toMove = (newPos - Pos) / 5;
			Pos = Pos + toMove;
			moveLayerTo(getLayer('samples'),Pos,0);	
		}
	else 
		{ 	Pos = Pos + 1;
			moveLayerTo(getLayer('samples'),Pos,0)
		}
	}

if (newPos < Pos)
	{
	if (newPos < (Pos - 5))
		{
			toMove = (Pos - newPos) / 5;
			Pos = Pos - toMove;
			moveLayerTo(getLayer('samples'),Pos,0);	
		}
	else 
		{ 	Pos = Pos - 1;
			moveLayerTo(getLayer('samples'),Pos,0)
		}
	}
}