window.addEvent('domready', function()
{	
	if($('rotating-features-container'))
	{
		var rotateInterval = setInterval('getRotating()',5500);
	
		$('rotating-features-container').getElements('li').addEvent('click',function()
		{
			rotateFeatures(this);
		});
		
		$('rotating-features-container').addEvent('mouseover',function()
		{
			clearInterval(rotateInterval);
		});
		
		$('rotating-features-container').addEvent('mouseleave',function()
		{
			rotateInterval = setInterval('getRotating()',5500);
		});
	}	
});

function rotateFeatures(object)
{
	$('rotating-features-container').getElements('li').removeClass('active');
	object.addClass('active');
	
	var featureScroll = new Fx.Morph('rotating-viewfinder', {duration: 'long', transition: Fx.Transitions.Quad.easeInOut});
	
	if(object.title == '1')
	{
		featureScroll.start({
			'left': '0px'
		});
	}
	if(object.title == '2')
	{
		featureScroll.start({
			'left': '-813px'
		});
		
	}
	if(object.title == '3')
	{
		featureScroll.start({
			'left': '-1626px'
		});
	}
	if(object.title == '4')
	{
		featureScroll.start({
			'left': '-2439px'
		});
	}
	if(object.title == '5')
	{
		featureScroll.start({
			'left': '-3252px'
		});
	}
}

function getRotating()
{
	var currentActive = $('rotating-features-container').getElement('li.active');
	if(currentActive.getNext())
	{
		rotateFeatures(currentActive.getNext());
	}
	else
	{
		var first = $('rotating-features-container').getElement('li');
		rotateFeatures(first);
	}
}

