var images = ['home_default.png','about_default.png','blog_default.png','logo.png'];



function nextimage() {
    var img = document.getElementById("slideimage");
    var imgname = img.name.split("_");
    var index = imgname[1];
    if (index == images.length - 1) {
        index = 0;
    } else {
        index++;
    }
    img.src = images[index];
    img.name = "image_" + index;
}



function previmage() {
    var img = document.getElementById("slideimage");
    var imgname = img.name.split("_");
    var index = imgname[1];
    if (index == 0) {
        index = images.length - 1;
    } else {
        index--;
    }
    img.src = images[index];
    img.name = "image_" + index;
}



<p><img id="slideimage" name="image_0" src="home_default.png" alt="Home"></p>



<input type = "button" id="prevbtn" value = "Previous" onclick="previmage()">



<input type = "button" id="nextbtn" value = "Next" onclick="nextimage()">
