Scroller won't stop at end?

I’ve made a scroller that speeds up in either direction the further the mouse is from the centre of the scroll bar, which all works fine, but when it gets to the end of the images it jumps to the beginning again?

I’m sure its pretty straight forward, but I just need it to stop when the images run out so people know they’ve seen them all? It starts with the first image showing, so I need it to go right initially, and then go back left until it returns to that point, which it does, the problem is when it gets to the right end of the pics.

Heres the code thats set in the first frame of the .FLA-

 panel.onRollOver = panelOver;
 function panelOver() {
     this.onEnterFrame = scrollPanel;
     delete this.onRollOver;
 }
 var b = stroke.getBounds(_root);
 function scrollPanel() {
     if (_xmouse<b.xMin || _xmouse>b.xMax || _ymouse<b.yMin || _ymouse>b.yMax) {
         this.onRollOver = panelOver;
         delete this.onEnterFrame;
     }
     if (panel._x>=21.2) {
         panel._x = 21.2;
     }
     if (panel._x<=-4050) {
         panel._x = 4050;
     }
     var xdist = _xmouse-425;
     panel._x += -xdist/7;
 }

Any help with this would be really appreciated as I’ve been trying to fix it all weekend and still got nowhere, if you need to know anything else about it or want to look at the FLA post a response and I’ll reply asap.

Thanks in advance to anyone who knows how to do this…

Tom