var LinkAnimator = function(id, delay)
{
	var me = this;
	var element = document.getElementById(id);
	if (!element)
	{	// несовместимый браузер или неправильно указан id
		return false;
	}

	var images = [];
	var links = [];
	var current_step = -1;
	var delay = delay;

	var next_pic = function()
	{
		current_step++;
		if (current_step >= images.length)
		{
			current_step = 0;
		}

		if (!images[current_step])
		{	// Нет ни одного кадра
			return;
		}

		element.href = links[current_step];
		element.childNodes[0].src = images[current_step];
		setTimeout(next_pic, delay);
	};

	this.add_frame = function(link, image)
	{
		images[images.length] = image;
		links[links.length] = link;
		var img = new Image();
		img.src = image; // предварительная загрузка изображения в кеш браузера
	};

	this.start_animation = function()
	{
		next_pic();
	};
}

