function toAll(collection, condition, action)
{
	var length = collection.length - 1;
	
	for(var i = length; i >= 0; i--)
	{
		var item = collection[i];
		if(condition(item))
		{
			action(item);
		}
	}
}

function newWindowLinks()
{
	toAll(
		document.getElementsByTagName('a'),
		function(item)
		{
			return /\bnew-window\b/.test(item.className);
		},
		function(item)
		{
			item.target = '_blank';
		}
	);
}

var scroller = document.getElementById('scroller');
scroller.innerHTML = '<div><div>' + scroller.innerHTML + '</div></div>';

function scroll()
{
	var scrollLeft = scroller.scrollLeft;
	scroller.scrollLeft += 1;
	if(scroller.scrollLeft == scrollLeft) scroller.scrollLeft = 0;
}

setInterval(scroll, 25);

newWindowLinks();
