// CUSTOM SCROLL CODE BASE //

// *******************************************************
// *******************************************************
// ** Customer Scroller for Scrollable DIVs
// ** Code By:  Dustin Horne / Information Analytics
// ** Copyright:  Janet Eskridge
// ** This code may not be used without express permission
// *******************************************************
// *******************************************************

// Grab reference to the scrolling elements from Config //
var sElmnt;
var cElmnt;
var Direction; //Direction of scroll, 1 = down, -1 = up.
var intervalID;

function loadScroller() {
	sElmnt = document.getElementById(targetName);
	cElmnt = document.getElementById(containerName);
}

//Set Over for the element//
function startScroll(elmnt, scrollDir) {
		//Set the button class
		Direction = scrollDir;
		
		if(Direction==-1) {
			elmnt.className='ias_Up_Over';
		}
		else
		{
			elmnt.className='ias_Down_Over';
		}
		
		initializeScroll();
}

function stopScroll(elmnt) {
	clearInterval(intervalID);
		//Set the button class
		if(Direction==-1) {
			elmnt.className='ias_Up_Normal';
		}
		else
		{
			elmnt.className='ias_Down_Normal';
		}
		
		clearInterval(intervalID);
		
}

function initializeScroll() {
	intervalID = setInterval(scrollContent, scrollSpeed);
}

function scrollContent() {
	//use scrollTop
	if(Direction==-1) {
		//Scrolling up, check for top
		//If less than the set scroll pixels from the top, set to 0 and stop the interval
		if(sElmnt.scrollTop < scrollPixels) {
			sElmnt.scrollTop = 0;
			stopScroll();
			return;
		}
	}
	else
	{
		//Scrolling down, check for bottom
		if(sElmnt.scrollHeight - sElmnt.scrollTop < 5) {
			sElmnt.scrollTop = sElmnt.scrollHeight;
			stopScroll();
			return;
		}
	}
	
	//If function is still executing, scroll the content
	sElmnt.scrollTop = sElmnt.scrollTop + (scrollPixels * Direction);
}




//***********************************************************************



function setOver(elmnt, dir, over) {
	var styleSuffix;
	if (over==true) {
		styleSuffix = 'Over';
	}
	else
	{
		styleSuffix = 'Normal';
	}
	
	document.getElementById(elmnt).className='ias_' + dir + '_' + styleSuffix;
		
}



function testOffset() {
	document.getElementById("MainTextBlock").style.top = "-200px";
}
