var cl = 0;
var cr = 0

function gallery_go(i, m) {
  if (m == "l") {
    $('p-' + m + "-" + cl).hide();
    $('p-' + m + "-" + i).show();
    cl = i;
  } else {
    $('p-' + m + "-" + cr).hide();
    $('p-' + m + "-" + i).show();
    cr = i;
  }
};

function setup_page() {
  if ($('pl') && $('pr')) {
    hl = $('pl').getHeight();
    hr = $('pr').getHeight();
    m = Math.max(hl, hr);
    if ($('or')) {
      if ($('gr')) {
        $('pl').setStyle({ height: m + 5 + "px" });
      } else {
        $('pl').setStyle({ height: m - 15 + "px" });
      }
      $('pr').setStyle({ background: "#1E371A" });
    } else {
      $('pl').setStyle({ height: m - 2 + "px" });
    }
    if ($('ol')) {
      if ($('gl')) {
        $('pr').setStyle({ height: m + 5 + "px" });
      } else {
        $('pr').setStyle({ height: m - 15 + "px" });
      }
      $('pl').setStyle({ background: "#1E371A" });
    } else {
      $('pr').setStyle({ height: m - 2 + "px" });
    }
    if ($('cl') && $('cr')) {
      $('cl').setStyle({ height: m + "px" });
      $('cr').setStyle({ height: m + "px" });
    } else if ($('cl')) {
      $('cl').setStyle({ height: m - 27 + "px" });
      $('pl').setStyle({ height: m - 20 + "px" });
      $('pr').setStyle({ height: m - 20 + "px" });
    } else  if ($('cr')) {
      $('cr').setStyle({ height: m - 27 + "px" });
      $('pl').setStyle({ height: m - 20 + "px" });
      $('pr').setStyle({ height: m - 20 + "px" });
    }
    if ($('fl')) { 
      $('fl').setStyle({ height: m + 11 + "px" }); 
      if ($('fgr')) {
        $('pr').setStyle({ height: m + 18 + "px" });
      }
      if ($('or')) {
        $('pr').setStyle({ height: m + 11 + "px" });
      }
      if ($('cr')) {
        $('cr').setStyle({ height: m - 9 + "px" });
      }
    }
    if ($('fr')) { 
      $('fr').setStyle({ height: m + 11 + "px" }); 
      if ($('fgl')) {
        $('pl').setStyle({ height: m + 18 + "px" });
      }
      if ($('ol')) {
        $('pl').setStyle({ height: m + 11 + "px" });
      }
      if ($('cl')) {
        $('cl').setStyle({ height: m - 9 + "px" });
      }
    }
    if ($('cl') && $('or')) {
      $('pr').setStyle({ height: m - 7 + "px" });
    }
    if ($('cr') && $('ol')) {
      $('pl').setStyle({ height: m - 7 + "px" });
    }
  }
}