var activeTab = 1;
var tabWidth = 940;
var totalTabs;
var curPosition;
var timer;

document.observe("dom:loaded", function() {
	timer = setTimeout("slideTo(2)", 7000);
	totalTabs = $$('#rotar_rot img').length;
});


function slideTo(tab) {
	clearTimeout(timer);
	
	curPosition = tab * 940 - 940;
	
	$('tab_' + activeTab).removeClassName('active');
	
	new Effect.Morph('rotar_rot', {
		style: 'left: -' + curPosition + 'px;',
  		duration: 0.8,
  		transition: Effect.Transitions.sinoidal
	});
	
	$('tab_' + tab).addClassName('active');
	activeTab = tab;
	
	
	
	nextTab = activeTab + 1;
	if (nextTab > totalTabs) {
		nextTab = 1;	
	}
	timer = setTimeout("slideTo(" + nextTab + ")", 7000);
}
