RR: minor tidy up of Javascript code.
RR: revised Javascript to fix bug.
RR: minor tweaks on Javascroipt.
Change and revert after testing against real Nagios server.