Javascript document generator