function rcmdReplacer()
{
	var buttonsContainer = document.getElementById("rcmd_links");
	if(!buttonsContainer)
		return false;
		
	var animationMode = featuredAnimationMode; // got from appparams
	var automaticSwitcher = featuredAutomaticSwitcher;
	var animationIsOn = false;
	var activeButton = 0;
	var link = "/index.xml?polecamy=#no#";//#polecamy_blok_#no#";

	buttonsContainer.parentNode.style.height = buttonsContainer.parentNode.offsetHeight + "px";

	var blocksArray = new Array();
	var buttons = buttonsContainer.getElementsByTagName("a");
	
	for( var i = 0; i < buttons.length; i++ )
	{
		blocksArray[i] = buttons[i].hash.slice(1);
		buttons[i].onclick = function()
		{
			return manualChange(this);
		};
	}
	
	var featuredInterval;
	if(featuredAutomaticSwitcher)
	{
		var featuredInterval = setInterval(function()
		{
			activeButton = (activeButton + 1) % buttons.length;
			autoChange(buttons[activeButton]);
		}, featuredAutomaticSwitcherTime*1000);
	}
	
	return;
	
	function autoChange(button)
	{
		return change(button);
	}
	
	function manualChange(button)
	{
		if(featuredAutomaticSwitcher)
			clearInterval(featuredInterval);
		return change(button);
	}
	
	function change(button)
	{
		button.blur();
		if(animationIsOn) return false;
		if(containsClass(button,"active")) return true;
		
		var links = button.parentNode.getElementsByTagName("a");
		var block, n, o;
		for(var i = 0; i < links.length; i++ )
		{
			block = document.getElementById("polecamy_blok_" + (i+1));
			if(links[i] == button)
			{
				addClass(links[i],"active");
				n = block;
			}
			else if(links[i].className.indexOf("active") != -1)
			{
				removeClass(links[i],"active");
				o = block;
			}
		}
		
		animation(n,o,animationMode);
		
		changeURLs(button);

		return false;
	}
	
	function changeURLs(button)
	{
		for( var i = 0; i < buttons.length; i++ )
		{
			buttons[i].href = (buttons[i] == button) ? featuredCategoriesHref[i] : link.replace(/#no#/g,i+1);
		}
	}
	
	function animation(n,o,t)
	{
		animationIsOn = true;
		switch(t)
		{
			case 1: return replacer();
			case 2: return alpha(5,10);
			case 3: return scroller(15,20);
			case 4: return roller(15,20);
		}
		
		// simple replacer
		function replacer()
		{
			addClass(n,"active"); removeClass(o,"active");
			animationIsOn = false; return;
		}

		function alpha(step, speed)
		{
			n.style.zIndex = 1;
			o.style.zIndex = 2;
			
			var opacity = 0;
			setOpacity(n,100)
			addClass(n,"active");
			
			var animation = setInterval(function ()
			{
				opacity += step;
				setOpacity(o,100-opacity)
				if(opacity >= 100)
				{
					clearInterval(animation);
					// turn on animation
					animationIsOn = false;
					removeClass(o,"active");
				}
			} , speed );
			
			return;
		}
		
		function scroller(step, speed)
		{
			var offsetStartTop = 25;
			n.style.zIndex = 2;
			addClass(n,"active");
			n.actualPos = (parseInt(n.offsetHeight) * -1) + offsetStartTop;
			n.style.top = n.actualPos + "px";
			var animation = setInterval(function ()
			{
				if(n.actualPos + step > offsetStartTop)
				{
					clearInterval(animation);
					animationIsOn = false;
					removeClass(o,"active");
					n.style.top=offsetStartTop + "px";
					n.style.zIndex = 1;
				}
				n.actualPos += step;
				n.style.top = n.actualPos + "px";
			} , speed );
			
			return;
		}
		
		function roller(step, speed)
		{
			addClass(n,"active");
			n.actualPos = parseInt(n.offsetWidth);
			o.actualPos = 0;
			n.style.left = n.offsetWidth + "px";
			var animation = setInterval(function ()
			{
				if(n.actualPos - step < 0)
				{
					clearInterval(animation);
					animationIsOn = false;
					removeClass(o,"active");
					o.style.left="-3000px"
					n.style.left=0;
				}
				n.actualPos -= step;
				o.actualPos -= step;
				n.style.left = n.actualPos + "px";
				o.style.left = o.actualPos + "px";
			} , speed );
			
			return;
		}
	}
	
	function setOpacity(el, o)
	{
		el.style.opacity = o/100;
		el.style.filter = "alpha(opacity="+o+")";
	}
}