Orbit ?

I cant find and cant think of how do make one object orbit another and another object orbit that object
it is to complex look at planet simulator http://dan-ball.jp/en/javagame/planet/ doesn’t matter how much objects are there it runs smooth and it is stable. I was always been interested in simulation games and sandbox games
but to make one that is so hard
does any of you people know any way to make this kind of simulator work ?