added js video handler and made php nicer