This is a library function, can be shared across html files.  Would like to replace with an external library sometime.