/* Initialize Rolling Banner */
function rollingBanner (id)
{
	var delay		= 2000;
	var root		= document.getElementById(id);
	var direction	= 'next';
	var pause		= false;

	if (typeof(root)!='object') { return false; }
	
	root.style.overflow	= 'hidden';
	root.style.position	= 'relative';

	try
	{
		for (var i in root.childNodes)
		{
			if (root.childNodes[i].nodeType!=1)
			{
				root.removeChild(root.childNodes[i]);
			}
		}
	}
	catch (e) {}

	var prev	= document.getElementById('site-banner-left');
	prev.onclick	= function ()
	{
		direction	= 'prev';
		root.insertBefore(root.lastChild, root.firstChild);
		return false;
	};
	
	var next	= document.getElementById('site-banner-right');
	next.onclick	= function ()
	{
		direction	= 'next';
		root.appendChild(root.firstChild);
		return false;
	};
	
	try
	{
		var btn_pause	= document.getElementById('site-banner-pause');
		btn_pause.onclick	= function ()
		{
			pause	= true;
		};
		var btn_play	= document.getElementById('site-banner-play');
		btn_play.onclick	= function ()
		{
			pause	= false;
		};
	}
	catch (e)
	{
	}

	var a = root.getElementsByTagName("a");
	
	for (var i in a)
	{
		a[i].onmouseover = a[i].onmouseout = a[i].onfocus = a[i].onblur = function (event)
		{
			var event	= event ? event : window.event;

			switch (event.type)
			{
				case 'mouseover'	:
				case 'focus'		:
										pause	= true;
										break;
				case 'mouseout'		:
				case 'blur'			:
										pause	= false;
										break;
			}
		}
	}

	setInterval(function()
	{
		if (!root.style.cssText) { return false; }
		if (pause==true) { return false;}

		if (direction=='prev')
		{
			root.insertBefore(root.lastChild, root.firstChild);
		}
		else
		{
			root.appendChild(root.firstChild);
		}
	}
	, delay);
	
}


