Fixed a null-reference error in javascript code