AD1006 in Javascript