After watching this closely, I think you are making it way to complicated. Maybe creating a simple slideshow will sort this out (without colorbox):
Code explainations:
$(document).ready(function() {
$("#gallery").find("li").hide(); // hide all images
$("#gallery").find("li:first").show(); // show first image
$("#gallery li").click(function() { // when user click on an image we switch to next image
if ($(this).next().length != 0) // If we are not at the last image of the slideshow
$(this).next().show().prev().hide(); // we show the next image and hide the current one
else {
$("#gallery").find("li:first").show(); // in the case we are at the last image, we hide the last one and show the first one
$("#gallery").find("li:last").hide();
}
});
});