closes #1776, fixed legend toggle

var headerIcon was declared before header was rendered