You cant create an animated jpg, only an animated GIF. I would strongly suggest NOT trying to code this yourself unless youre a very good programmer. It would require building a GIF file by hand which means understanding the headers involved and how the bytes of the data work for the image.
You might be able to find a control that helps you with some of this. But, if you really just want to create an animated gif and not write a program that does it, Id suggest finding a utility to do it. I use Paint Shop Pros Animation Studio (last copy I bought was around $80 for both PSP and the Animation Studio). Id bet a dollar there are some free animated gif builders available if you search google. They normally work by having you add a bunch of individual gif files and then tweaking the speed of each frame and a few other parameters.
-Ner