bug fix related to $doc vs $wnd.document usage