//scrollit function & declarations
//john reeve did this

var x = 0;
var destination = 0;
var maxWidth = 0;
var incScroll = 25;
var speedScroll = 50;
var columnWidth = 400;
var slideTimer = 0;
//var yHeight;

isNS4 = (document.layers) ? true : false;
isIE4 = (document.all && !document.getElementById) ? true : false;
isIE5 = (document.all && document.getElementById) ? true : false;
isNS6 = (!document.all && document.getElementById) ? true : false;

function scrollit(direction) {

	beginPoint = 0;
	clearInterval(slideTimer);

	if (isIE5 || isNS6) {
		endPoint = document.getElementById('contentTable').style.width;
	}
	else if (isIE4) {
		endPoint = document.all['contentTable'].style.width;
	}
	else {
		endPoint = document.layers['contentTable'].width;
	}
	endPoint = endPoint.replace("px","");
	endPoint = (endPoint - 100) * -1;

	//hardcode the columnwidth
	if (direction == "b") { destination = x + columnWidth; }
	else if (direction == "f") { destination = x - columnWidth; }
	else { 
		destination = direction; 
		if (x > destination) { direction = "f"; }
		else { direction = "b"; }
	}
	//check to see if the slide should stop
	if (destination <= beginPoint && destination >= endPoint) {
		slideTimer = setInterval("slideTo(" + destination+ ",'" + direction + "')", speedScroll);

		//these lines of code control the appearance of the back button
		if (destination + columnWidth > beginPoint) { //beginning
			//backButton("off");
		}
		else {
			//backButton("on");
		}
		
		//these lines of code control the appearance of the forward button
		if (destination - columnWidth < endPoint) { //end
			//forwardButton("off");
		}
		else {
			//forwardButton("on");
		}
		
	}

}

function backButton(status) {
	document['button_back'].src = "i/button_back_" + status + ".gif";
	button_back_on.src = "i/button_back_" + status + ".gif";
	if (status == "on") {
		button_back_mouse.src = "i/button_back_mouse.gif";
	}
	else {
		button_back_mouse.src = "i/button_back_" + status + ".gif";
	}
}

function forwardButton(status) {
	document['button_forward'].src = "i/button_forward_" + status + ".gif";
	button_forward_on.src = "i/button_forward_" + status + ".gif";
	if (status == "on") {
		button_forward_mouse.src = "i/button_forward_mouse.gif";
	}
	else {
		button_forward_mouse.src = "i/button_forward_" + status + ".gif";
	}
}

function slideTo(destination,direction) {
	var increment = 0;
	
	//if moving forward
	if (direction == "f") { 
		if (x <= destination) { 		
			clearInterval(slideTimer);
		}
		else {
			increment = incScroll * -1; 
			moveLayer(increment);
		}
	}
	//if moving backward
	else if (direction == "b") { 
		if (x >= destination) { 		
			clearInterval(slideTimer);
		}
		else {
			increment = incScroll; 
			moveLayer(increment);
		}
	}
	x += increment; //don't forget to update this global x coordinate :)
}

function moveLayer(increment) {
	if (isIE5 || isNS6) {
		document.getElementById('contentTable').style.left = x + increment;
	}
	else if (isIE4) {
		document.all['contentTable'].style.left += increment;
	}
	else {
		document.layers['contentTable'].left += increment;
	}
}