In about the simplest terms (this sort of thing can be done much more elegantly, like for all thumbnails without having to give each one an onclick event):
I don't know what your slider is like, whether or not you can put that code in it. Oh, and if it's not the body whose background needs to be changed you could use like:
<a href="pathto/largerimage.jpg" onclick="document.body.style.backgroundImage = 'url(' + this.href + ')'; return false;">
in the above.
If you want more help, please include a link to the page on your site that contains the problematic code so we can check it out.