This simple method allows testing of a coordinate in 2D space against the X,Y position and Width and Height of a given rectangle to determine if the point falls within the rectangles bounds.
function pointInRect(x, y, rx, ry, rw, rh)
{
return (x>=rx && x<=(rx+rw) && y>=ry && y<=(ry+rh));
}