okay.. so here's very simple gallery... that does only what your question's code does.. actually i only corrected it.. so click next and back... and get new images.. i did it very quickly.. so many things are missing for it to be called a gallery.. any ways you can fiddle with it here
changed your markup to..
<a href="#" onclick="next(); return false;">Next</a>
<a href="#" onclick="previous(); return false;">Back</a>
<img id="gallery" src="http://i26.tinypic.com/2hwx3c.jpg" style="height:420px; width:744px" >
and your script to...
var imageGallery = [
"http://i26.tinypic.com/2hwx3c.jpg" ,
"http://i43.tinypic.com/2iqxpg1.jpg" ,
"http://i40.tinypic.com/2agls15.jpg" ,
"http://i41.tinypic.com/2ym9f01.jpg",
"http://i32.tinypic.com/14aa4o7.jpg"
];
var imgCount = 0;
var totalImgs = imageGallery.length - 1;
function next() {
imgCount++ ;
if(imgCount > totalImgs) imgCount = 0
document.getElementById("gallery").src = imageGallery[imgCount] ;
}
function previous() {
imgCount--;
if(imgCount < 0) imgCount = totalImgs ;
document.getElementById("gallery").src = imageGallery[imgCount] ;
}