Entirely too much javascript in my life.