Hover Caption Tutorial Help?

I have got this code to work fine but one small problem…on the rightside of the stage the hover goes away…is there anyway to determine if your close to the rightside edge of the stage reverse the hover to the bottom right corner instead of always using the bottom left corner as the center of the hover…

any help would be greatly appreciated…

thanks

captionFN = function (showCaption, captionText, bName) {
if (showCaption) {
_root.nation.createEmptyMovieClip(“hoverCaption”, this.getNextHighestDepth());
cap.desc.text = captionText;
cap._width = 8*cap.desc.text.length;
cap._alpha = 95;
//
if ((bName._width+bName._x+cap._width)>Stage.width) {
xo = -2-cap._width;
yo = -17;
} else {
xo = 2;
yo = -17;
}
hoverCaption.onEnterFrame = function() {
cap._x = _root.nation._xmouse+xo;
cap._y = _root.nation._ymouse+yo;
cap._visible = true;
};
} else {
delete hoverCaption.onEnterFrame;
cap._visible = false;
}
};