Marson,
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
#galleryCounter{
width: 300px;
height: 190px;
margin: 20px auto;
}
#galleryCounter img{
width: 300px;
height: 170px;
}
</style>
</head>
<body>
<script>
var image = ["http://s00.yaplakal.com/pics/pics_preview/5/3/6/12440635.jpg", "http://s00.yaplakal.com/pics/pics_original/1/9/4/3736491.jpg"];
function gallery(idparameter, array) {
var current = 1;
var kolvo = array.length;
var div = document.createElement("div");
div.id = idparameter;
var img = document.createElement("img");
img.src = array[current];
div.appendChild(img);
var input1 = document.createElement("input");
input1.setAttribute("type", "button");
input1.setAttribute("value", "\u0412\u043f\u0435\u0440\u0451\u0434");
input1.onclick = frw;
div.appendChild(input1);
var input2 = document.createElement("input");
input2.setAttribute("type", "button");
input2.setAttribute("value",
"\u041d\u0430\u0437\u0430\u0434");
input2.onclick = bck;
div.appendChild(input2);
function frw() {
current++;
if (current == kolvo) current = 0;
img.src = array[current]
}
function bck() {
current--;
if (current < 0) current = kolvo - 1;
img.src = array[current]
}
return div
}
document.body.appendChild(gallery("galleryCounter", image));
</script>
</body>
</html>