Button alignment calculation

How to calculate the button alignment using a mathematical formula. After clicking the links goes two sides. See this url

http://www.wireframe.co.za/w1r3d.html