<div id="box1" class="box1">
      <span id="anchor1">Anchor LTR.</span>
    </div>

    <div class="box2">
      <div id="popup1">
        <div>Popup ltr.</div>
      </div>
    </div>
  </div>

  <div class="outerbox" dir="rtl">
    <div class="box1">
      <span id="anchor2">Anchor RTL.</span>
    </div>

    <div class="box2">
      <div id="popup2">
        <div>Popup rtl.</div>
      </div>
    </div>
  </div>

  <div id="anchor4">
    Anchor 4.
  </div>

  <div id="popup3">
    Popup.
  </div>

<div 