var index;

$(document).ready(function () {
	$('.arrow').on('click', newNextSlide);
	$('.go').on('click', goSlide);
	$('.btn-feedback').on('click', showFeedback);
	$('.close').on('click', closeFeedback);
	
	$('#eje1-p2').hide();
});


function newNextSlide() {
	indexSection = $(this).attr('data-section');
	direction = $(this).attr('data-direction');
	section = document.querySelector('#'+indexSection+' div[data-content="1"]');
	content = section.querySelectorAll('#'+indexSection+' div[data-content="1"] > .slide');
	limit = $('#'+indexSection+' div[data-content="1"]').attr('data-limit');
	console.log(content.length);
	for (var i = 0; i < content.length; i++) {
		if ($(content[i]).is(':visible')) {
			if (direction == 'next') {
				index = parseInt($(content[i+1]).attr('data-position'));
				console.log(index);
				$('#'+indexSection+' div[data-content="1"] .arrow').show();
				if (index == content.length || index == limit) {
					$(this).hide();
				}
			} else if (direction == 'previous') {
				index = parseInt($(content[i-1]).attr('data-position'));
				console.log(index);
				$('#'+indexSection+' div[data-content="1"] .arrow').show();
				if (index == 1) {
					$(this).hide();
				}
			}
		}
	}
	for (var i = 1; i < 3; i++) {
		v =	$('#'+indexSection+' .content'+i).attr('data-content');
		if (v != 0) {
			for (var i2 = 1; i2 <= content.length; i2++) {
				$('#'+indexSection+' .slide'+i2).hide();
			}
			$('#'+indexSection+' .slide'+index).fadeIn();
			break
		}
	}
}

