var cGallery = function(sElement, iSpeed, iScroll, iSize) {
	
	var timeout = null;
	
	var iMove = null;
	
	var oElement = document.getElementById(sElement);
	
	var scrollLeft = function() {
		oElement.scrollLeft -= iScroll;
		iMove += iScroll;
		if(iMove + iScroll > iSize) {
			oElement.scrollLeft -= (iSize - iMove);
			clearTimeout(timeout);
			iMove = 0;
		} else {
			timeout = setTimeout(scrollLeft, iSpeed);
		}
	}
	
	this.scrollLeft = function() {
		if(oElement.scrollLeft - iSize >= 0) {
			timeout = setTimeout(scrollLeft, iSpeed);
		}
	}
	
	var scrollRight = function() {
		oElement.scrollLeft += iScroll;
		iMove += iScroll;
		if(iMove + iScroll > iSize) {
			oElement.scrollLeft += (iSize - iMove);
			clearTimeout(timeout);
			iMove = 0;
		} else {
			timeout = setTimeout(scrollRight, iSpeed);
		}
	}
	
	this.scrollRight = function() {
		if(oElement.scrollLeft + iSize + oElement.clientWidth <= oElement.scrollWidth) {
			timeout = setTimeout(scrollRight, iSpeed);
		}
	}
	
}
