var menuItems = 5;
var menuSpacing = 20;
var defaultLeft = 30;
var defaultWidth = 120;
var obj;

function sliderinit()
{
	for (i = 0; i < menuItems; i++)
	{
		obj = document.getElementById(menuIds[i]);
		obj.style.left = (defaultLeft + i * (defaultWidth + menuSpacing)).toString() + "px";
	}
}


function select(id){
	obj = document.getElementById(id);
	obj.style.zIndex = 1;
	obj.style.border = "solid 1px white";

	move_left(parseInt(obj.style.left));
}

function move_left(startLeft)
{
	if (parseInt(obj.style.left) > defaultLeft)
	{
		document.getElementById("arrow").src = "img/arrow.gif";
		obj.style.left=(parseInt(obj.style.left)-5).toString()+"px";
		var i = (parseInt(obj.style.left) - (defaultLeft + defaultWidth / 2)) / (defaultWidth + menuSpacing);
		if (i == parseInt(i))
		{
			if (i < menuItems)
			{
				var tempObj = document.getElementById(menuIds[i]);
				tempObj.style.left = (parseInt(tempObj.style.left) + defaultWidth + menuSpacing).toString() + "px";
			}
		}
		var timeout = 5;
	
		//if ((parseInt(obj.style.left) - defaultLeft < 70) || (startLeft - parseInt(obj.style.left) < 70))
			//timeout = 20;
		if ((parseInt(obj.style.left) - defaultLeft < 25) || (startLeft - parseInt(obj.style.left) < 30))
			timeout = 40;
	
		setTimeout('move_left(' + startLeft + ')', timeout);
	}
	else
	{
		obj.style.border = "solid 1px rgb(23, 55, 94)";
		obj.style.zIndex = 0;
		var index;
		for (i = 0; i < menuItems; i++)
			if (obj.id == menuIds[i]) index = i;
		menuIds.splice(index, 1);
		menuIds.splice(0, 0, obj.id);
		/*alert(menuIds.toString());*/
		if (menuIds[0].slice(8) == "index")
			window.location = menuIds[0].slice(8) + ".php?rs=nu";
		else
			window.location = menuIds[0].slice(8) + ".php";

		/*alert(menuIds[0].slice(8) + ".php");*/
	}
}

function move(id,i)
{
	var obj = document.getElementById(id);

	obj.style.left=(parseInt(obj.style.left)+3).toString()+"px";
	var timeout = 5;
	
	if ((i < 10) || (i > 95))
		timeout = 20;
	
	if (i > 0)
		setTimeout('move(\''+id+'\','+(i-1).toString()+')', timeout);
}

