var rutas = ["../jQueryProject/assets/images/dennisritchie2.jpg","../jQueryProject/assets/images/error-code.jpg","../jQueryProject/assets/images/jquery-cover.png"];
var rutaBoton = ["../jQueryProject/assets/images/botonlleno.png","../jQueryProject/assets/images/botonvacio.png"];
var n=1;

$(function() {
    setInterval(images, 5000);
});

function images() {
    var i = $("#slide");
    var buttons = $(".boton").toArray();
    if (n == 0) {
        $(i).attr("src", rutas[n]);
        $(buttons[0]).attr("src", rutaBoton[0]);
        $(buttons[1]).attr("src", rutaBoton[1]);
        $(buttons[buttons.length-1]).attr("src", rutaBoton[1]);
        $("#button_a").text("Introducción");
        $("#button_a").attr("href", "index.php?do=showIntro");
        $("#href_header").attr("href", "index.php?do=showIntro");
        n++;
    }
    else if (n == rutas.length-1) {
        $(i).attr("src", rutas[n]);
        $(buttons[0]).attr("src", rutaBoton[1]);
        $(buttons[n]).attr("src", rutaBoton[0]);
        $(buttons[n-1]).attr("src", rutaBoton[1]);
        $("#button_a").text("Selectores");
        $("#button_a").attr("href", "index.php?do=showSelectors");
        $("#href_header").attr("href", "index.php?do=showSelectors");
        n=0;
    }
    else {
        $(i).attr("src", rutas[n]);
        var num = buttons.length-1;
        $(buttons[num]).attr("src", rutaBoton[1]);
        $(buttons[n]).attr("src", rutaBoton[0]);
        $(buttons[n-1]).attr("src", rutaBoton[1]);
        $("#button_a").text("Cheatsheet");
        $("#button_a").attr("href", "index.php?do=showCheat");
        $("#href_header").attr("href", "index.php?do=showCheat");
        n++;
    }
	
}

$(function() {
    $(".buttons").click(function(e) {
        var num = $(this).attr('id');
        num = num.replace("button", "");
        n = num;
	images();
        e.preventDefault();
    });
});