function phphaberci_slider()
{	
	this.recordCount = 0;
	
	this.elm = null;
	this.elmActive = null;
	this.elmTotal = null;
	
	this.class_name = '';
	
	this.current = 0;
	this.direction = -1;
	
	this.stepItemCount = 3;
	this.itemWidth = 0;
	this.visibleCount = 0;
	this.firstSlide =true;
	
	this.stepTime = 60;
	this.stepCount = 10;
	this.stepAmount = 0;
	this.stepIndex = 0;
	this.totalWidth = 0;
	this.lastestLeft = 0;
	this._automaticStepTime = 8000;
	this._automaticTimer = null;
	this.name = '';
	this.goStatus = true;
	
	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);
		
		this.lastestLeft = this.totalWidth - this.itemWidth; //document.getElementById(this.elm.id + "_" + (this.recordCount - 1)).offsetLeft;
		
		this.showElmTotal();
		
		this.showElmActive();
	}
	
	this.showElmTotal = function()
	{
		if(this.elmTotal)
		{
			this.elmTotal.innerHTML = this.recordCount;
		}
	}
	
	this.showElmActive = function()
	{
		if(this.elmActive)
		{
			tmp = this.current * -1 + this.stepItemCount;
			if(tmp > this.recordCount)
				tmp = this.recordCount;
			
			this.elmActive.innerHTML = tmp;
		}
	}
	
	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;
		}
		
		_step = _step * this.stepItemCount;
		
		for(i=0; i<this.recordCount; i++)
		{
			tmp = document.getElementById(this.elm.id + "_" + i).offsetLeft + _step * this.direction;
			if(tmp > this.lastestLeft)
			{
				tmp = _step - this.itemWidth;
			}
			
			document.getElementById(this.elm.id + "_" + i).style.left = tmp + "px";
		}
		if(this.stepIndex == this.stepCount)
		{
			this._clear();
		}
		else
		{
			this.timerIndex = setTimeout(this.name + "._go();", this.stepTime);
		}
		
		this.showElmActive();
	}
	function go(direction, automatic)
	{
		if(!this.goStatus)
			return;
		
		/*if(this.current * direction + this.stepItemCount >= this.recordCount)
		{
			return false;
		}*/
		
		if(!automatic){
			this._clearAutomaticTimer();
		}

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

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

		this.goStatus = false;
		
		this.direction = direction;
		this.current += direction * this.stepItemCount;
		this._go();
	}
	
	function _clear()
	{
		this.stepIndex = 0;
		
		if(this.timerIndex != null)
			clearTimeout(this.timerIndex);
		this.timerIndex = null;

		this.goStatus = true;
	}
	
	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(this.name + "._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;	
	}
}
phphaberci_font = 'Arial';
phphaberci_fontSize = '13px';
phphaberci_fontSizeNS4 = '11px';
phphaberci_fontWeight = 'normal';
phphaberci_fontColor = '#ffffff';
phphaberci_textDecoration = 'none';
phphaberci_fontColorHover = '#f5ff9e';
phphaberci_textDecorationHover = 'none';
phphaberci_bgColor = 'transparent';
phphaberci_top = 0;
phphaberci_left = 0;
phphaberci_width = 400;
phphaberci_height = 20;
phphaberci_paddingTop = 0;
phphaberci_paddingLeft = 4;
phphaberci_position = 'absolute';
phphaberci_timeout = 2500;
phphaberci_slideSpeed = 30;
phphaberci_slideDirection = 0;
phphaberci_pauseOnMouseOver = true;
phphaberci_slideStep = 4;
phphaberci_textAlign = 'left';
phphaberci_textVAlign = 'middle';

phphaberci_ua = navigator.userAgent;
phphaberci_nS4 = document.layers ? 1 : 0;
phphaberci_iE = document.all && !window.innerWidth && phphaberci_ua.indexOf("MSIE") !=  - 1 ? 1 : 0;
phphaberci_oP = phphaberci_ua.indexOf("Opera") !=  - 1 && document.clear ? 1 : 0;
phphaberci_oP7 = phphaberci_oP && document.appendChild ? 1 : 0;
phphaberci_oP4 = phphaberci_ua.indexOf("Opera") !=  - 1 && !document.clear;
phphaberci_kN = phphaberci_ua.indexOf("Konqueror") !=  - 1 && parseFloat(phphaberci_ua.substring(phphaberci_ua.indexOf("Konqueror/") + 10)) < 3.1 ? 1 : 0;
phphaberci_cur = 1;
phphaberci_cl = 0;
phphaberci_d = phphaberci_slideDirection ?  - 1: 1;
phphaberci_TIM = 0;
phphaberci_fontSize2 = phphaberci_nS4 && navigator.platform.toLowerCase().indexOf("win") !=  - 1 ? phphaberci_fontSizeNS4 : phphaberci_fontSize;
phphaberci_canPause = 0;

function phphaberci_getOS(a)
{
	return phphaberci_iE ? document.all[a].style: phphaberci_nS4 ? document.layers["phphaberci_container"].document.layers[a]: document.getElementById(a).style
}
function phphaberci_start()
{
	var o, px;
	o = phphaberci_getOS("phphaberci_1");
	px = phphaberci_oP && !phphaberci_oP7 || phphaberci_nS4 ? 0 : "px";
	if (parseInt(o.top) == phphaberci_paddingTop)
	{
		phphaberci_canPause = 1;
		if (phphaberci_count > 1)
			phphaberci_TIM = setTimeout("phphaberci_canPause=0;phphaberci_slide()", phphaberci_timeout);
		return 
	}
	o.top = (parseInt(o.top) - phphaberci_slideStep * phphaberci_d) * phphaberci_d > phphaberci_paddingTop * phphaberci_d ? parseInt(o.top) - phphaberci_slideStep * phphaberci_d + px: phphaberci_paddingTop + px;
	if (phphaberci_oP && o.visibility.toLowerCase() != "visible")
		o.visibility = "visible";
	setTimeout("phphaberci_start()", phphaberci_slideSpeed)
}

function phphaberci_slide()
{
	var o, o2, px;
	o = phphaberci_getOS("phphaberci_" + phphaberci_cur);
	o2 = phphaberci_getOS("phphaberci_" + (phphaberci_cur < phphaberci_count ? phphaberci_cur + 1: 1));
	px = phphaberci_oP && !phphaberci_oP7 || phphaberci_nS4 ? 0 : "px";
	if (parseInt(o2.top) == phphaberci_paddingTop)
	{
		if (phphaberci_oP)
			o.visibility = "hidden";
		o.top = phphaberci_height * phphaberci_d + px;
		phphaberci_cur = phphaberci_cur < phphaberci_count ? phphaberci_cur + 1: 1;
		phphaberci_canPause = 1;
		phphaberci_TIM = setTimeout("phphaberci_canPause=0;phphaberci_slide()", phphaberci_timeout);
		return ;
	}
	if (phphaberci_oP && o2.visibility.toLowerCase() != "visible")
		o2.visibility = "visible";
	if ((parseInt(o2.top) - phphaberci_slideStep * phphaberci_d) * phphaberci_d > phphaberci_paddingTop * phphaberci_d)
	{
		o.top = parseInt(o.top) - phphaberci_slideStep * phphaberci_d + px;
		o2.top = parseInt(o2.top) - phphaberci_slideStep * phphaberci_d + px
	}
	else
	{
		o.top =  - phphaberci_height * phphaberci_d + px;
		o2.top = phphaberci_paddingTop + px
	}
	setTimeout("phphaberci_slide()", phphaberci_slideSpeed)
}

function phphaberci_init()
{
	phphaberci_count = phphaberci_content.length;
	if (phphaberci_nS4 || phphaberci_iE || phphaberci_oP || document.getElementById && !phphaberci_kN && !phphaberci_oP4)
	{
		document.write("<style>.vnewsticker,a.vnewsticker{font-family:" + phphaberci_font + ";font-size:" + phphaberci_fontSize2 + ";color:" + phphaberci_fontColor + ";text-decoration:" + phphaberci_textDecoration + ";font-weight:" + phphaberci_fontWeight + "}a.vnewsticker:hover{font-family:" + phphaberci_font + ";font-size:" + phphaberci_fontSize2 + ";color:" + phphaberci_fontColorHover + ";text-decoration:" + phphaberci_textDecorationHover + "}</style>");
		phphaberci_temp = "<div " + (phphaberci_nS4 ? "name" : "id") + "=phphaberci_container style='position:" + phphaberci_position + ";top:" + phphaberci_top + "px;left:" + phphaberci_left + "px;width:" + phphaberci_width + "px;height:" + phphaberci_height + "px;background:" + phphaberci_bgColor + ";layer-background" + (phphaberci_bgColor.indexOf("url(") == 0 ? "-image" : "-color") + ":" + phphaberci_bgColor + ";clip:rect(0," + phphaberci_width + "," + phphaberci_height + ",0);overflow:hidden'>" + (phphaberci_iE ? "<div style='position:absolute;top:0px;left:0px;width:100%;height:100%;clip:rect(0," + phphaberci_width + "," + phphaberci_height + ",0)'>": "");
		for (phphaberci_i = 0; phphaberci_i < phphaberci_count; phphaberci_i++)
			phphaberci_temp += "<div " + (phphaberci_nS4 ? "name" : "id") + "=phphaberci_" + (phphaberci_i + 1) + " style='position:absolute;top:" + (phphaberci_height * phphaberci_d) + "px;left:" + phphaberci_paddingLeft + "px;width:" + (phphaberci_width - phphaberci_paddingLeft * 2) + "px;height:" + (phphaberci_height - phphaberci_paddingTop * 2) + "px;clip:rect(0," + (phphaberci_width - phphaberci_paddingLeft * 2) + "," + (phphaberci_height - phphaberci_paddingTop * 2) + ",0);overflow:hidden" + (phphaberci_oP ? ";visibility:hidden" : "") + ";text-align:" + phphaberci_textAlign + "' class=vnewsticker>" + (!phphaberci_nS4 ? "<table width=" + (phphaberci_width - phphaberci_paddingLeft * 2) + " height=" + (phphaberci_height - phphaberci_paddingTop * 2) + " cellpadding=0 cellspacing=0 border=0><tr><td width=" + (phphaberci_width - phphaberci_paddingLeft * 2) + " height=" + (phphaberci_height - phphaberci_paddingTop * 2) + " align=" + phphaberci_textAlign + " valign=" + phphaberci_textVAlign + " class=vnewsticker>": "") + (phphaberci_content[phphaberci_i][0] != "" ? "<a href='" + phphaberci_content[phphaberci_i][0] + "' class=vnewsticker" + (phphaberci_pauseOnMouseOver ? " onmouseover='if(phphaberci_canPause&&phphaberci_count>1){clearTimeout(phphaberci_TIM);phphaberci_cl=1};window.status=\"\";return true' onmouseout='if(phphaberci_canPause&&phphaberci_count>1&&phphaberci_cl)phphaberci_TIM=setTimeout(\"phphaberci_canPause=0;phphaberci_slide();phphaberci_cl=0\"," + phphaberci_timeout + ")' onmouseover='if(phphaberci_canPause&&phphaberci_count>1){clearTimeout(phphaberci_TIM);phphaberci_cl=1};window.status=\"" + phphaberci_content[phphaberci_i][1] + "\";return true'": "") + ">": "<span" + (phphaberci_pauseOnMouseOver ? " onmouseover='if(phphaberci_canPause&&phphaberci_count>1){clearTimeout(phphaberci_TIM);phphaberci_cl=1}' onmouseout='if(phphaberci_canPause&&phphaberci_count>1&&phphaberci_cl)phphaberci_TIM=setTimeout(\"phphaberci_canPause=0;phphaberci_slide();phphaberci_cl=0\"," + phphaberci_timeout + ")'": "") + "><span class=time>") + phphaberci_content[phphaberci_i][1] + "</span> - <b>" + phphaberci_content[phphaberci_i][2] + '</b>' + (phphaberci_content[phphaberci_i][0] != "" ? "</a>" : "</span>") + (!phphaberci_nS4 ? "</td></tr></table>" : "") + "</div>";
		phphaberci_temp += (phphaberci_iE ? "</div>" : "") + "</div>";
		document.write(phphaberci_temp);
		setTimeout("phphaberci_start()", 1000);
		if (phphaberci_nS4)
		onresize = function()
		{
			location.reload()
		}
	}
}

