var FramesCount = 12;

var loaderDiv = document.getElementById('loader_old');
function addFrame(index, src)
{
    var imgElement = document.createElement('img');
    imgElement.setAttribute('id', 'frame_'+index);
    imgElement.setAttribute('src', src);
    imgElement.setAttribute('alt', '');
    imgElement.style.display = 'None';

    loaderDiv.appendChild(imgElement);
}

addFrame(1, "#html_loader.png#");
addFrame(2, "#html_loader30.png#");
addFrame(3, "#html_loader60.png#");
addFrame(4, "#html_loader90.png#");
addFrame(5, "#html_loader120.png#");
addFrame(6, "#html_loader150.png#");
addFrame(7, "#html_loader180.png#");
addFrame(8, "#html_loader210.png#");
addFrame(9, "#html_loader240.png#");
addFrame(10, "#html_loader270.png#");
addFrame(11, "#html_loader300.png#");
addFrame(12, "#html_loader330.png#");

(function loop(i, j) {
	setTimeout(function () {
		if (j == FramesCount) {
			document.getElementById('frame_'+j).style.display = "None";
			j = 0;
		}
		if (j != 0) {
			document.getElementById('frame_'+j).style.display = "None";
		}
		var current = document.getElementById('frame_'+i);
		current.style.display = "Block";
		i++;
		j++;
		if (i<=FramesCount) {
			loop(i,j);
		}
		else {
		    loop(1,FramesCount);
		}
	}, 100);
})(1,0);