
declare Boolean Prev_DistractionFreeMode = False;
declare netwrite Boolean Net_DistractionFreeMode for UI;

declare CMlLabel Author_Label <=> (Page.GetFirstChild("author_label") as CMlLabel);
declare CMlQuad Author_Flag <=> (Page.GetFirstChild("author_flag") as CMlQuad);

declare Boolean Show_Login = False;

if (Map != Null) {
  Author_Label.SetText(Map.AuthorNickName);
  Author_Flag.ChangeImageUrl(Map.AuthorZoneIconUrl);
}

if (Net_DistractionFreeMode == True) {
  Page.GetClassChildren("distraction-hide", Page.MainFrame, True);
  foreach (Control in Page.GetClassChildren_Result) {
    Control.Hide();
  }
}

while(True) {
  foreach (Event in PendingEvents) {
    if (Event.ControlId == "author_label" && Event.Type == CMlScriptEvent::Type::MouseClick && Map != Null) {
      if (Show_Login) {
        Show_Login = False;
        Author_Label.SetText(Map.AuthorNickName);
      } else {
        Show_Login = True;
        Author_Label.SetText(Map.AuthorLogin);
      }
    }
  }

  if (Prev_DistractionFreeMode != Net_DistractionFreeMode) {
    Prev_DistractionFreeMode = Net_DistractionFreeMode;

    if (Net_DistractionFreeMode == True) {
      Page.GetClassChildren("distraction-hide", Page.MainFrame, True);
      foreach (Control in Page.GetClassChildren_Result) {
        Control.Hide();
      }
    } else {
      Page.GetClassChildren("distraction-hide", Page.MainFrame, True);
      foreach (Control in Page.GetClassChildren_Result) {
        Control.Show();
      }
    }
  }
  yield;
}
