var totalSlides;
var currentIndex = 1;

function setupSlideshow(total)
{
	totalSlides = total;
	
	$('#slider-container div p').css('width', (total * 522)+'px');
	
}

function showSlide(index)
{
	$("#slider-dot-"+currentIndex).removeClass().addClass('sliderdot-off');
	
	var diff = Math.abs(index - currentIndex);
	
	currentIndex = index;
	
	$("#slider-dot-"+currentIndex).removeClass().addClass('sliderdot-on');
	
	$('#slider-container div p').animate( { marginLeft: -(522 * (currentIndex-1))+'px' }, diff * 200 );
	
	return false;
}

function showNext()
{
	if(currentIndex != totalSlides)
	{
		showSlide(currentIndex + 1);	
	}
	
	return false;
}

function showPrevious()
{
	if(currentIndex != 1)
	{
		showSlide(currentIndex - 1);	
	}
	
	return false;
}

var currentNewsIndex = 0;
var totalNewsItems = 0;

function configNewsRotator(total)
{
	totalNewsItems = total;
	
	for(i = 0; i <= totalNewsItems; i++)
	{
		$('#news-excerpt-'+i+' a').css('margin-top', (37 - ($('#news-excerpt-'+i+' a').height() * .5))+'px');
		$('#news-excerpt-'+i).css('display','none');
	}
	
	rotateNews();
}

function rotateNews()
{
	$('#news-excerpt-'+currentNewsIndex).fadeTo(1000, 1).delay(4000).fadeTo(900, 0);
	
	setTimeout('hideLast()', 6000);
	
	setTimeout('rotateNews()', 6010);
}

function stepNews()
{
	if(currentNewsIndex == totalNewsItems-1)
	{
		currentNewsIndex = 0;
	}
	else
	{
		currentNewsIndex++;
	}
}

function hideLast()
{
	$('#news-excerpt-'+currentNewsIndex).css('display','none')
	
	stepNews();
}

