
var max_specials = 4;
var special_width = 256;
    
var special_index = 0;
var document_width = 0;

function refresh_special()
{
    var specials = $('.special');
    var count = specials.size();
    var y = (document_width - max_specials * special_width) / 2;

    var index = special_index;
    
    $(specials[index]).animate({ "left": -special_width+"px" }, 1024);
    $(specials[next_index(index+max_specials-1, count)]).css({ "left": document_width+"px" });

    for(var i=0; i<max_specials; i++)
    {
	index = next_index(index, count);
	$(specials[index]).animate({ "left": y+"px" }, 1024);
	y += special_width;
    }

    special_index = next_index(special_index, count);		
    setTimeout("refresh_special()",4000);
}

function next_index(current, count)
{
    return (current + 1) % count;
}

$(document).ready(function()
{
    document_width = $(window).width();
    refresh_special();
});
