var timer = "";

function doScroll(drct) {
	var divScroller = document.getElementById('ccasecontain');
	if (drct=='up') {
		if (divScroller.scrollTop <= 0 ) {
			scrollStop();
			doScroll('down');
		}else{
			divScroller.scrollTop -= 2;
			timer = setTimeout("doScroll('"+drct+"')",25);
		}
	}
	if (drct=='down') {
		if (divScroller.scrollTop >= (document.getElementById('scroll1').scrollHeight - document.getElementById('ccasecontain').offsetHeight)) {
			scrollStop();
			doScroll('up');
		}else {
			divScroller.scrollTop += 2;
			timer = setTimeout("doScroll('"+drct+"')",25);
		}
	}
}

function doScrollLoop(drct) {
	var divScroller = document.getElementById('ccasecontain');
	if (drct=='up') {
		divScroller.scrollTop -= 5;
		if (divScroller.scrollTop <= 0 ) {
			divScroller.scrollTop = document.getElementById('scroll1').scrollHeight+10;
		}		
	}
	if (drct=='down') {
		divScroller.scrollTop += 5;
		if (divScroller.scrollTop >= document.getElementById('scroll1').scrollHeight+10) {
			divScroller.scrollTop = 0;
		}
	}

	timer = setTimeout("doScrollLoop('"+drct+"')",25);
}

function scrollStop() {
	clearTimeout(timer);
}


window.onload=function() {
 	// SCROLLERS
 	var direction="down";

	if (document.getElementById('prodsel')) {
		curTop = document.getElementById('prodsel').offsetTop;
		document.getElementById('ccasecontain').scrollTop = curTop - 120;
		
	}



 	if (document.getElementById('ccasecontain')) { 
 		doScroll(direction);
 	}
 	
 	if (document.getElementById('ccasecontain')) { 
		document.getElementById('ccasecontain').onmouseover = function() {
			//scrollStop('r');
		}
	}
 	if (document.getElementById('ccasecontain')) { 
		document.getElementById('ccasecontain').onmouseout = function() {
			//doScroll(direction);
		}
	}	
		

 	if (document.getElementById('scrup')) { 	
		document.getElementById('scrup').onmouseover = function() {
			//scrollStop('d');
			//direction = "up";
			//doScroll('up');
		}
		document.getElementById('scrup').onmouseout = function() {
			//scrollStop('u');
		}
	}
	
 	if (document.getElementById('scrdown')) { 	
		document.getElementById('scrdown').onmouseover = function() {
			//scrollStop('u');
			//direction = "down";
			//doScroll('down');
		}
		document.getElementById('scrdown').onmouseout = function() {
			//scrollStop('d');
		}
	}

	
	
};

