var showed 	= 0;
//var total	= TOPBLOCK_LIMIT;
var rotationGo = true;

function showBox(toShow)
{
	//console.log( plg_homepage_topblock_data[toShow].link );
	$('#rotater_link_img').attr('href',plg_homepage_topblock_data[toShow].link);
	$('#rotater_img').attr('src',plg_homepage_topblock_data[toShow].img);
	$('#rotater_img').attr('alt',plg_homepage_topblock_data[toShow].alt);

	$('#rotater_link_'  + showed).removeClass('active');
	$('#rotater_link_'  + showed).addClass('normal');
	$('#rotater_link_'  + toShow).removeClass('normal');
	$('#rotater_link_'  + toShow).addClass('active');

	showed = toShow;
}


function rotate()
{
	if( rotationGo ) {
		var nr = ( ( showed < TOPBLOCK_LIMIT-1 ) ? eval(showed+1) : 0 );
		showBox(nr);
	}
	setTimeout(rotate, 5000);
}


$().ready( function() {

	$('#top_content_rotater').mouseover(function(){
		rotationGo = false;
	});
	$('#top_content_rotater').mouseout(function(){
		rotationGo = true;
	});
	setTimeout(rotate, 5000);
});
