Javascript implementation of Boxhead