var current_margin = 0;
var imageCount = 5;

var doPrev = function()
{
	current_margin--;
	if (current_margin < 0)
		current_margin = imageCount - 1;

	change_ss(current_margin);
}

var doNext = function()
{
	current_margin++;
	if (current_margin == imageCount)
		current_margin = 0;

	change_ss(current_margin);
}

function change_ss (idx)
{
	current_margin = idx;

	for (i = 0; i < imageCount; i++)
	{
		document.getElementById("smallScreenThumb" + i).style.borderColor="#ddd";
	}

	document.getElementById("smallScreenThumb" + idx).style.borderColor="#F48100";
	
	//document.getElementById('spinnerImg').style.display = "";
	document.getElementById('spinnerImg').style.visibility = "visible";
	imgObj = document.getElementById('bigScreenPlace');
	imgObj.src = document.getElementById("smallScreenThumb" + idx).src.replace("-small", "-big");
	//imgObj.style.visibility = "hidden";
	imgObj.style.opacity = 0.05;

	waitFor();
}

function waitFor()
{
	if(!document.getElementById('bigScreenPlace').complete)
	{
		imgWait = setTimeout('waitFor()', 100);
	}
	else
	{
		//imgObj.style.visibility = "visible";
		imgObj.style.opacity = 1.0;
		//document.getElementById("spinnerImg").style.display = "none";
		document.getElementById('spinnerImg').style.visibility = "hidden";
	}
}

window.addEvent('domready', function()
{

});

