var scrollSpeedC = 200;
var speedC = 25;
var headerRowsC = 2;

var engagedC = false;
var scrollObjC = null;
var mainObjC = null;
var dataObjC = null;
		
function engageC(type) {
	engagedC = true;
	if(type=='btm') {
		 scrollBottomC();
	} else {
		 scrollTopC();
	}
}

function unengageC() {
	engagedC = false;
}

var rem = new Array();
var t = null;

function scrollBottomC() {	
	if(t) clearTimeout(t);
	if(engagedC) doScrollBtm();
	
	function doScrollBtm() {					
		if(navigator.appName == 'Microsoft Internet Explorer') {
			mainObjC.scrollTop += speedC;
		} else {
			var mt = mainObjC.firstChild.style.top;
			if(typeof mt == 'undefined' || mt == '') mt = 0;
			var topH = parseInt(mt) - speedC;
			if(mainObjC.offsetHeight - dataObjC.offsetHeight > topH) topH = mainObjC.offsetHeight - dataObjC.offsetHeight;
			
			mainObjC.firstChild.style.top = topH + 'px';
		}
		t = setTimeout(scrollBottomC, scrollSpeedC);
	}
}

function scrollTopC() {
	if(t) clearTimeout(t);
	if(engagedC) doScrollTop();
		
	function doScrollTop() {						
		if(navigator.appName == 'Microsoft Internet Explorer') {
			if(mainObjC.scrollTop - speedC < 0) mainObjC.scrollTop = 0;
			else mainObjC.scrollTop -= speedC;
		} else {
			var mt = mainObjC.firstChild.style.top;
			if(typeof mt == 'undefined' || mt == '') mt = 0;
			var topH = parseInt(mt) + speedC;
			
			if(topH < 0) mainObjC.firstChild.style.top = topH + 'px';
			else mainObjC.firstChild.style.top = '0px';
		}				
		t = setTimeout(scrollTopC, scrollSpeedC);
	}
}

function initScrollC() {
	if(document.getElementById('scrollContent')) {		
		scrollObjC = document.getElementById('scrollContent');
		mainObjC = document.getElementById('main');
		dataObjC = document.getElementById('data');		
		if(dataObjC.offsetHeight - mainObjC.offsetHeight > 0) {			
			scrollObjC.style.display = 'block';
		}				
	}	
}
