split off the layout control code into layout.js...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
Merge branch 'master' of git@github.com:flynx/PortableMag