Debugged javascript logic for compare page.