Moving javascript over to javascript file