var timer = "";

function doScroll(drct) {
	if (drct=='left') {
		var divScroller = document.getElementById('ccasecontain');
		divScroller.scrollLeft -= 2;
		if (divScroller.scrollLeft == 0) {
			scrollStop('l');
			drct = "right";
		}		
	}
	if (drct=='right') {
		var divScroller = document.getElementById('ccasecontain');
		divScroller.scrollLeft += 2;
		if ((divScroller.scrollLeft + divScroller.offsetWidth) >= document.getElementById('scroll1').scrollWidth ) {
			scrollStop('r');
			drct = "left";
		}
	}
	
	if (drct=='up') {
		var divScroller = document.getElementById('ccasecontainup');
		divScroller.scrollTop -= 5;
		if (divScroller.scrollTop == document.getElementById('scroll2').scrollHeight ) {
			scrollStop('u');
		}		
	}
	if (drct=='down') {
		var divScroller = document.getElementById('ccasecontainup');
		divScroller.scrollTop += 5;
		if (divScroller.scrollTop == 0) {
			scrollStop('d');
		}
	}
	

	timer = setTimeout("doScroll('"+drct+"')",25);
}

function doScrollLoop(drct) {
	if (drct=='left') {
		var divScroller = document.getElementById('ccasecontain');
		divScroller.scrollLeft -= 5;
		if (divScroller.scrollLeft <= 0 ) {
			divScroller.scrollLeft = document.getElementById('scroll1').scrollWidth+10;
		}		
	}
	if (drct=='right') {
		var divScroller = document.getElementById('ccasecontain');
		divScroller.scrollLeft += 5;
		if (divScroller.scrollLeft >= document.getElementById('scroll1').scrollWidth+10) {
			divScroller.scrollLeft = 0;
		}
	}
	
	if (drct=='up') {
		var divScroller = document.getElementById('ccasecontainup');
		divScroller.scrollTop -= 5;
		if (divScroller.scrollTop <= 0 ) {
			divScroller.scrollTop = document.getElementById('scroll2').scrollHeight+10;
		}		
	}
	if (drct=='down') {
		var divScroller = document.getElementById('ccasecontainup');
		divScroller.scrollTop += 5;
		if (divScroller.scrollTop >= document.getElementById('scroll2').scrollHeight+10) {
			divScroller.scrollTop = 0;
		}
	}

	

	timer = setTimeout("doScrollLoop('"+drct+"')",25);
}

function scrollStop(scrollDirection) {
	switch (scrollDirection) {
		case 'l':
			break;
		case 'r':
			break;
		case 'u':
			break;
		case 'd':
			break;
	}

	clearTimeout(timer);
}


window.onload=function() {
 	// SCROLLERS
			direction = "right";
			doScroll('right');

 	if (document.getElementById('scrleft')) { 	
		document.getElementById('scrleft').onmouseover = function() {
			scrollStop('r');
			direction = "left";
			doScroll('left');
		}
		document.getElementById('scrleft').onmouseout = function() {
			scrollStop('l');
		}
	}
	
 	if (document.getElementById('scrright')) { 	
		document.getElementById('scrright').onmouseover = function() {
			scrollStop('l');
			direction = "right";
			doScroll('right');
		}
		document.getElementById('scrright').onmouseout = function() {
			scrollStop('r');
		}
	}

 	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');
		}
	}
	
};

