Wrote javascript for wacky conditional

Wrote javascript for wacky conditional