Figure out the minimum and maximum Y values that the control panel should be allowed to have. Let's say it's 0 and 1000.

MINIMUM_Y = 0;
MAXIMUM_Y = 1000;

Then change these two lines:

if (mousey>panely+400){
...
}else if (mousey<panely-100){

to this:

if (mousey>panely+400 and _root.controlpanel._y < MAXIMUM_Y){
...
}else if (mousey<panely-100 and _root.controlpanel._y > MINIMUM_Y){