function scrollX(objElement, intWidth)
{
	var self = this;
	var useAjaxHandler = '';
	this._x = 0;
	intPos = 0;
	objElement.style.left = "0px";
	if(arguments.length>2) usedSaveHandler = arguments[2];
	
	this.setPosition = function(intPos) {
		if (intPos > 0)
		{
			intPos = 0;
		}
		else if ((intPos < intWidth - objElement.offsetWidth))
		{
			intPos = intWidth - objElement.offsetWidth;
  		}
		else if (!intPos)
		{
			intPos = 0;
		}
		//alert(intPos);
		this._x = intPos;
	//	alert(intWidth+"   "+objElement.offsetWidth);
		objElement.style.left  = this._x +"px";
	};

	this.scrollX = function(x) {
		this.setPosition(this._x + x);
	};

	this.start = function(x) {
		this.scrollTimer = window.setInterval(
			function() { self.scrollX(x); }, 25
		);
	};
	
	var checkSaveHandler = function() {
		if(typeof usedSaveHandler == 'object')
		{
			if(typeof usedSaveHandler.saveHandler == 'string')
			{
				if(usedSaveHandler.saveHandler == 'ajax') {
					if(typeof usedSaveHandler.parameterName != 'string'
						|| typeof usedSaveHandler.sessionParam != 'string' || typeof usedSaveHandler.sessionId != 'string'
						|| typeof Ajax != 'object' || typeof Ajax.Request == 'undefined')
					{
						usedSaveHandler = null;
					}
				} else if (usedSaveHandler.saveHandler == 'cookie') {
					if(typeof usedSaveHandler.parameterName != 'string' ||
						typeof Cookie != 'object') {
						usedSaveHandler = null;				
					}
				}
			}
			else
			{
				usedSaveHandler = null;
			}
		}
		else usedSaveHandler = null;
	}();
	
	var doSaveValues = function() {
		if(usedSaveHandler != null)
		{
			if(usedSaveHandler.saveHandler == 'ajax') {
				var ajaxUrl = usedSaveHandler.url + '?' + usedSaveHandler.parameterName + '=' + encodeURIComponent(self._x) + '&' +
								usedSaveHandler.sessionParam + '=' + encodeURIComponent(usedSaveHandler.sessionId)
				new Ajax.Request(ajaxUrl, 
					{ method: 'url' }
				);			
				
			} else if(usedSaveHandler.saveHandler == 'cookie') {
				Cookie.write('scroll_save_' + usedSaveHandler.parameterName, this._x);
			}
		}
	};
	
	this.stop = function()
	{
		doSaveValues();
		// requires prototype framework with Ajax.Request support
		if (this.scrollTimer) window.clearInterval(this.scrollTimer);
	};
};
