var upH1 = 9; // Height of up-arrow
var upW1 = 5; // Width of up-arrow
var downH1 = 9; // Height of down-arrow
var downW1 = 5; // Width of down-arrow
var dragH1 = 26; // Height of scrollbar
var dragW1 = 17; // Width of scrollbar
var scrollH1 = 180; // Height of scrollbar
var speed1 = 4; // Scroll speed

// And now... go to the bottom of the page...
var clickUp1 = false; // If click on up-arrow
var clickDown1 = false; // If click on down-arrow
var clickDrag1 = false; // If click on scrollbar
var clickAbove1 = false; // If click above scrollbar
var clickBelow1 = false; // If click below scrollbar

var timer1 = setTimeout("",500); // Repeat variable
var upL1; // Up-arrow X
var upT1; // Up-arrow Y
var downL1; // Down-arrow X
var downT1; // Down-arrow Y
var dragL1; // Scrollbar X
var dragT1; // Scrollbar Y
var rulerL1; // Ruler X
var rulerT1; // Ruler Y
var contentT1; // Content layer Y;
var contentH1; // Content height
var contentClipH1; // Content clip height
var scrollLength1; // Number of pixels scrollbar should move
var startY1; // Keeps track of offset between mouse and span

// Reads content layer top
function getT1(){
	if(ie4)
		contentT1 = document.all.content1.style.pixelTop;
	else if(nn4)
		contentT1 = document.contentClip.document.content1.top;
	else if(dom)
		contentT1 = parseInt(document.getElementById("content1").style.top);
}

// Reads mouse X and Y coordinates

// Moves the layer
function moveTo1(){
	if(ie4){
		document.all.content1.style.top = contentT1;
		document.all.ruler1.style.top = dragT1;
		document.all.drag1.style.top = dragT1;
	}
	else if(nn4){
		document.contentClip.document.content1.top = contentT1;
		document.ruler1.top = dragT1;
		document.drag1.top = dragT1;
	}
	else if(dom){
		document.getElementById("content1").style.top = contentT1 + "px";
		document.getElementById("drag1").style.top = dragT1 + "px";
		document.getElementById("ruler1").style.top = dragT1 + "px";
	}
}

// Scrolls up
function scrollUp1(){
	getT1();
	if(clickAbove1){
		if(dragT1 <= (mouseY-(dragH1/2)))
			return up();
	}
	
	if(clickUp1){
		if(contentT1 < 0){
			dragT1 = dragT1 - (speed1*scrollLength1);
			
			if(dragT1 < (rulerT1))
				dragT1 = rulerT1;
				
			contentT1 = contentT1 + speed1;
			if(contentT1 > 0)
				contentT1 = 0;
			
			moveTo1();
			timer1 = setTimeout("scrollUp1()",25);
		}
	}
	return false;
}

// Scrolls down
function scrollDown1(){
	getContent1();
	getT1();
	
	if(clickBelow1){
		if(dragT1 >= (mouseY-(dragH1/2)))
			return up();
	}

	if(clickDown1){
		if(contentT1 > -(contentH1 - contentClipH1)){			
			dragT1 = dragT1 + (speed1*scrollLength1);
			if(dragT1 > (rulerT1 + scrollH1 - dragH1))
				dragT1 = (rulerT1 + scrollH1 - dragH1);
			
			contentT1 = contentT1 - speed1;
			if(contentT1 < -(contentH1 - contentClipH1))
				contentT1 = -(contentH1 - contentClipH1);
			
			moveTo1();
			timer1 = setTimeout("scrollDown1()",25);
		}
	}
	return false;
}

// reloads page to position the layers again

function getContent1(){
	if (ie4){
		// Height of content layer and clip layer
		contentH1 = parseInt(document.all.content1.scrollHeight);
		contentClipH1 = parseInt(document.all.contentClip.style.height);
	}
	else if (nn4){
		// Height of content layer and clip layer
		contentH1 = document.contentClip.document.content1.clip.bottom;
		contentClipH1 = document.contentClip.clip.bottom;	
	}
	else if(dom){
		contentH1 = parseInt(document.getElementById("content1").offsetHeight);
		contentClipH1 = parseInt(document.getElementById("contentClip").offsetHeight);
	}
	// Number of pixels scrollbar should move
	scrollLength1 = ((scrollH1-dragH1)/(contentH1-contentClipH1));
}

// Preload
function eventLoader1(){
	if(ie4){
		// Up-arrow X and Y variables
		upL1 = document.all.up1.style.pixelLeft;
		upT1 = document.all.up1.style.pixelTop;		
		// Down-arrow X and Y variables
		downL1 = document.all.down1.style.pixelLeft;
		downT1 = document.all.down1.style.pixelTop;
		// Scrollbar X and Y variables
		dragL1 = document.all.drag1.style.pixelLeft;
		dragT1 = document.all.drag1.style.pixelTop;		
		// Ruler Y variable
		rulerT1 = document.all.ruler1.style.pixelTop;
	}
	else if(nn4){
		// Up-arrow X and Y variables
		upL1 = document.up1.left;
		upT1 = document.up1.top;		
		// Down-arrow X and Y variables
		downL1 = document.down1.left;
		downT1 = document.down1.top;		
		// Scrollbar X and Y variables
		dragL1 = document.drag1.left;
		dragT1 = document.drag1.top;		
		// Ruler Y variable
		rulerT1 = document.ruler1.top;
	}
	else if(dom){
		// Up-arrow X and Y variables
		upL1 = parseInt(document.getElementById("up1").style.left);
		upT1 = parseInt(document.getElementById("up1").style.top);
		// Down-arrow X and Y variables
		downL1 = parseInt(document.getElementById("down1").style.left);
		downT1 = parseInt(document.getElementById("down1").style.top);
		// Scrollbar X and Y variables
		dragL1 = parseInt(document.getElementById("drag1").style.left);
		dragT1 = parseInt(document.getElementById("drag1").style.top);
		// Ruler Y variable
		rulerT1 = parseInt(document.getElementById("ruler1").style.top);
		document.getElementById("content1").style.top = 0 + "px";	
	}
	getContent1();

}
