javascript for pat