Hats java script