cycle plug-in - creating links to specific slides

cycle plug-in - creating links to specific slides

hi,

i'm hoping someone can look over this code and tell me if it is right; i'm not a programmer, and although this works (at least in safari and chrome), i'm worried that it is bad code.  

what i'm trying to do is add a function to the cycle plug-in where the address bar reflects a link to the specific image in the slideshow using #1, #2, etc.  not quite a history function, as i'm not concerned with back/forward buttons.  (this code also includes for a 'position', i.e. 1/7, 2/7, etc., and a caption using the title).

$(document).ready(function() {
if (window.location.hash.substr(1)=="")
{
var hash = 0;
}
else
{
var hash = window.location.hash.substr(1)-1;
};
$('#slideshow').cycle({
fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
after: onAfter,
timeout: 0,
speed: 100,
next: '.next', 
prev: '.prev',
startingSlide: hash
});
});

function onAfter(curr,next,opts) {
var position = (opts.currSlide + 1) + ' / ' + opts.slideCount;
$('#position').html(position);
var count = (opts.currSlide +1);
window.location.hash = count;
$('#caption').html(this.title);
}

the main reason why i think this is wrong is because i've seen jquery history plugins that are much more complicated (and which i can't understand), but perhaps that is because they are dealing with the back/forward buttons?  in any case, if it is this simple, i imagine i'm not the only one who would find this functionality useful.

thanks!