$(document).ready(function() { initTextScroll(); });
var stext_amount = 0;
var stext_width = 376;
var stext_padding = 28;
var stext_current = 1;
var stext_moving = false;

function initTextScroll()
{
	stext_amount = $('div#textscroll > .stext').length;
	check();
	if (isIE6())
	{
		$('a#stnav_left img, a#stnav_right img').ifixpng();
	}
}

function goRight()
{
	if (!stext_moving)
	{
		if (stext_current < (stext_amount - 1))
		{
			stext_moving = true;
			var amount = $('div#textscroll').position().left - (stext_width + stext_padding);
			$('div#textscroll').animate({left: amount}, 500, 'linear', function() { stext_moving = false; });
			stext_current++;
			check();
		}
	}
}

function goLeft()
{
	if (!stext_moving)
	{
		if (stext_current > 1)
		{
			stext_moving = true;
			var amount = $('div#textscroll').position().left + (stext_width + stext_padding);
			$('div#textscroll').animate({left: amount}, 500, 'linear', function() { stext_moving = false; });
			stext_current--;
			check();
		}
	}
}

function check()
{
	//hiding img instead of a element because of ie6 bug
	if (stext_current == 1)
	{
		$('a#stnav_left img').hide();
	} else {
		$('a#stnav_left img').show();
	}
	if (stext_current == (stext_amount - 1))
	{
		$('a#stnav_right img').hide();
	} else {
		$('a#stnav_right img').show();
	}
}

