var max_pos = 4;
var pos = 1;
var iniciodown;
var findown;
var iniciotop;
var fintop;
var bandera=true;

window.onload = function() 
{
	setInterval("slidedown()", 1);
	setInterval("slidetop()", 1);
}

function nextImage()
{
	if(bandera)
	{
		var div = document.getElementById('grupo_videos');
		var value = div.style.top;
		value = value.replace(/px/,'');
		pos++;
		bandera=false;
		if(pos == max_pos)
		{
			iniciotop=parseInt(value);
			fintop=0;
			pos = 1;
		}
		else
		{
			iniciodown=parseInt(value);
			findown=parseInt(value)+96;
		}
	}
}

function backImage()
{
	if(bandera)
	{
		var div = document.getElementById('grupo_videos');
		var value = div.style.top;
		value = value.replace(/px/,'');
		pos--;
		bandera=false;
		if(pos == -(max_pos-1))
		{
			iniciodown=parseInt(value);
			findown=0;
		}
		else
		{
			iniciotop=parseInt(value);
			fintop=parseInt(value)-96;
		}
	}
}

function slidedown()
{
	if(findown!=null)
	{
		var div = document.getElementById('grupo_videos');
		if(iniciodown<findown)
		{
			iniciodown++;
			div.style.top=iniciodown+"px";
		}
		else
		{
			bandera=true;
		}
	}
}

function slidetop()
{
	if(fintop!=null)
	{
		var div = document.getElementById('grupo_videos');
		if(iniciotop>fintop) 
		{
			iniciotop--;
			div.style.top=iniciotop+"px";
		}
		else
		{
			bandera=true;
		}
		
	}
}

