function CM_slider()
{
	// Lütfen izinsiz kullanmayınız.

	this.recordCount = 0;

	this.elm = null;

	this.current = 0;
	this.direction = -1;

	this.itemWidth = 0;
	this.visibleCount = 0;
	this.firstSlide =true;

	this.class_name = '';

	this.stepTime = 60;
	this.stepCount = 10;
	this.stepAmount = 0;
	this.stepIndex = 0;
	this.totalWidth = 0;
	this.lastestLeft = 0;
	this._automaticStepTime = 5000;
	this._automaticTimer = null;

	this.timerIndex = null;

	this._start = _start;
	this._action = _action;
	this._clear = _clear;
	this._go = _go;
	this.go = go;
	this._automatic = _automatic;
	this._clearAutomaticTimer = _clearAutomaticTimer;
	this._checkStatus = _checkStatus;

	function _start()
	{
		if(!this.elm)
			return false;

		tmp = this.elm.getElementsByTagName('div');

		for(i = 0; i<tmp.length; i++)
		{
			if(tmp[i].className == this.class_name)
			{
				this.recordCount += 1;
				this.itemWidth = tmp[i].offsetWidth;
			}
		}

		this.visibleCount = parseInt(this.elm.offsetWidth / this.itemWidth) * 1;

		this.totalWidth = this.itemWidth * this.recordCount;

		this.stepAmount = parseInt(this.itemWidth / this.stepCount);

		if(this.recordCount > 1)
			this.lastestLeft = document.getElementById(this.class_name + "_" + (this.recordCount)).offsetLeft;
		else
			this.lastestLeft = 0;

		//alert( 'Visible Count: ' + this.visibleCount + '; Total Width: ' + this.totalWidth + '; Step Amount : ' + this.stepAmount + '; LatestLeft : ' + this.lastestLeft);
	}

	function _action()
	{
		if(!this.recordCount)
			return false;
		else if (this.visibleCount >= this.recordCount)
			return false;

		this._automatic();
	}

	function _go()
	{
		this.stepIndex++;

		if(this.stepIndex == this.stepCount)
		{
			_step = this.itemWidth - (this.stepCount * this.stepAmount) + this.stepAmount;
		}
		else
		{
			_step = this.stepAmount;
		}

		for(i=1; i <= this.recordCount; i++)
		{
			tmp = document.getElementById(this.class_name + "_" + i).offsetLeft + _step * this.direction;

			if(tmp > this.lastestLeft)
			{
				tmp = _step - this.itemWidth;
			}

			document.getElementById(this.class_name + "_" + i).style.left = tmp + "px";
		}

		if(this.stepIndex == this.stepCount)
		{
			this._clear();
		}
		else
		{
			this.timerIndex = setTimeout("CMSLIDER._go();", this.stepTime);
		}
	}
	function go(direction,automatic)
	{
		if(!automatic){
			this._clearAutomaticTimer();
		}

		if(this.current + direction > 0)
			return false;

		if((this.recordCount - this.visibleCount) < Math.abs(this.current + direction))
			return false;

		this.direction = direction;
		this.current += direction;
		this._go();
	}

	function _clear()
	{
		this.stepIndex = 0;
		
		if(this.timerIndex != null)
			clearTimeout(this.timerIndex);
		this.timerIndex = null;
	}

	function _clearAutomaticTimer()
	{
		if (this._automaticTimer != null)
			clearTimeout(this._automaticTimer);
		this._automaticTimer = null;		
	}

	function _automatic() {
		if(this.firstSlide)
		{
			var temp = setTimeout("this.go(this.direction,1)", this._automaticStepTime);
			clearTimeout(temp);
			this.firstSlide = false;
		}
		else
		{
			this._checkStatus();
			this.go(this.direction, 1);
		}
		this._automaticTimer = setTimeout("CMSLIDER._automatic();", this._automaticStepTime);
	}

	function _checkStatus()
	{
		var index = this.recordCount - this.visibleCount;

		if(this.current == -(index) )
			this.direction = 1;
		else if(this.current== 0)
			this.direction = -1;	
	}
}