// JavaScript Document

function findPageBodyHeight() {

  var navibottom = document.getElementById('mainnavi-bottom');
  var contentbottom = document.getElementById('content-bottom');
  var stageBackHeight = document.getElementById('stageBackPic').getAttribute('height');
  var servicebottom = document.getElementById('servicebotline');
  var curtopNavBot = 0;
  var curtopConBot = 0;
  var curtopSerBot = 0;
  var curtopNavBotRules = 1;
  var curtopSerBotRules = 0;
  var curtopConBotRules = 0;
  var pageBodyHeight = 0;
  
  if (navibottom.offsetParent) {
    curtopNavBot = navibottom.offsetTop
    while (navibottom = navibottom.offsetParent) {
      curtopNavBot += navibottom.offsetTop
    }
  }
  
  if (contentbottom.offsetParent) {
    curtopConBot = contentbottom.offsetTop
    while (contentbottom = contentbottom.offsetParent) {
      curtopConBot += contentbottom.offsetTop
    }
  }
  
  if (servicebottom.offsetParent) {
    curtopSerBot = servicebottom.offsetTop
    while (servicebottom = servicebottom.offsetParent) {
      curtopSerBot += servicebottom.offsetTop
    }
  }
  
  if (curtopNavBot <= curtopSerBot) {
    curtopNavBotRules = 0;
    curtopSerBotRules = 1;
  }
  if (curtopSerBotRules == 1 && curtopSerBot <= curtopConBot) {
    curtopSerBotRules = 0;
    curtopConBotRules = 1;
  }
  if (curtopNavBotRules == 1 && curtopNavBot <= curtopConBot) {
    curtopNavBotRules = 0;
    curtopConBotRules = 1;
  }
  
  if (curtopNavBotRules == 1) {
    pageBodyHeight = curtopNavBot - 161;
  }
  if (curtopSerBotRules == 1) {
    pageBodyHeight = curtopSerBot - 161;
  }
  if (curtopConBotRules == 1) {
    pageBodyHeight = curtopConBot - 161;
  }
  if (pageBodyHeight <= stageBackHeight) {
    pageBodyHeight = stageBackHeight;
  } else {
    pageBodyHeight += 34;
  }
  
  document.write('<style type="text/css"><!-- .pagebody, .stage, .divider {height:' + pageBodyHeight + 'px;} --></style>');
  
}

