var isSupported = document.getElementById && document.getElementsByTagName;
if (isSupported) {
	document.documentElement.className = "js";
}
pos_i = 0;
pos_f = 2;

arr_videos = new Array();
window.onload = function() {
	if (!(div_carrusel = document.getElementById('carrusel')))
		return false;
	
	// Cogemos el primer y el último elemento (los que tienen flechas de navegación)
	arr_videos = div_carrusel.getElementsByTagName('li');
	ant = document.getElementById('anterior');
	sig = document.getElementById('siguiente');


	// Muestra los videos iniciales
	for (var i = pos_i; i <= pos_f; i++) {
		if (arr_videos[i]) { 
			arr_videos[i].style.display = 'block';
		}
	}
	
	if (pos_i == 0) {
		ant.style.backgroundPosition = 'right top'
	}
	if (pos_f == arr_videos.length - 1) {
		sig.style.backgroundPosition = 'right top';
	}
	
	
	ant.onclick = function() {
		if (pos_i > 0) {
			arr_videos[pos_f].style.display = 'none';
			pos_f--; pos_i--;
			arr_videos[pos_i].style.display = 'block';
			sig.style.backgroundPosition = 'left top';
		}
		if (pos_i == 0) {
			this.style.backgroundPosition = 'right top';
		}
		else { 
			this.style.backgroundPosition = 'left top';
		}
		return false;
		
	}
	sig.onclick = function() {
		
		if (pos_f < arr_videos.length - 1) {
			arr_videos[pos_i].style.display = 'none';
			pos_f++; pos_i++;
			arr_videos[pos_f].style.display = 'block';
			ant.style.backgroundPosition = 'left top';
		}
		if (pos_f == arr_videos.length - 1) {
			this.style.backgroundPosition = 'right top';
		}
		else { 
			this.style.backgroundPosition = 'left top';
		}
		return false;
	}

	
	
}
