Calculate dimensions of inner box

This is my first post here and also i'm bad with math so don't be mad at me :)

Here is my issue, i have a box and i have another box inside, now i want that box inside to be at exactly same distance from each side, no matter what size it parent is.

Now i know how to calculate the distance from the sides, but i can't figure how to get right box dimensions. To make thing more clear i draw this example:

http://www.part.lt/img/f2204b0558a21a3695c6698de6e0f7f4835.png

I hope i make some sense here :)

-
Do you want to maximize the volume of the box inside such that the distance from either side between the boxes is same? This is a optimization problem and we can use tools from calculus to solve it. Maximize $A=(x-2d)(y-2d)$ where $A$ is area of box inside and $x,y$ are length and width respectively. Although, I am not sure where this will lead to! – Lyapunov Jul 1 '12 at 23:37

If your outer box is $x \times y$ and you want the inner one at distance $d$, the inner dimensions are $x-2d \times y-2d$ and the centers need to match. Is that what you are after?

-
well i think so my inner box should be 90% size of the outer box, the thing that i can't calculate is that my distances always isn't the same – Linas Jul 1 '12 at 22:20
@Linas: If you want to specify d, you can't also have the inner box 90% the size of the outer. If you want the inner 90% (linear dimensions, not area, I assume) the size of the outer box, its dimensions are 0.9x×0.9y and the gap around will be 0.05x in one direction and 0.05y in the other. – Ross Millikan Jul 1 '12 at 22:54
i didn't really understood what you mean, but you gave me some idea which i think gonna solve it, so thanks anyway – Linas Jul 2 '12 at 16:57
@Linas: maybe I am not getting by what you mean by "exactly same distance" or by 90%. Let's say the outer box is 16x20. Do you want to say the spacing between the inner and outer box is (say) 2? If so, my original answer says the inner box is 12x16. If you want the inner box 90% in each dimension of the outer box, it would be 14.4x16, but then the spacings in the two directions are different. You can still center the smaller in the larger. – Ross Millikan Jul 2 '12 at 17:30