Implements the PHP Function into Javascript