transformed to jquery plugin