var original_height = 0;

function defaultSet(id, default_value) {
  if ($(id).value == '') {
    $(id).value = default_value;
  }
}

function defaultUnset(id, default_value) {
  if ($(id).value == default_value) {
    $(id).value = '';
  }
}

function fixHeight() {
  var max_height = Element.getHeight($('main_content_id'));
  var tmp = Element.getHeight($('left_content_id'));
  
  if (max_height < tmp) { max_height = tmp; }
  
  tmp = Element.getHeight($('right_content_id'));
  
  if (max_height < tmp) { max_height = tmp; }
  
  $('main_content_id').style.height = max_height + 'px';
  $('left_content_id').style.height = max_height + 'px';
  $('right_content_id').style.height = max_height + 'px';
  original_height = max_height;
}


function showItemInfo(id) {
  if ($(id).visible() == false) {
    var max_height = Element.getHeight($('main_content_id'));    
    var c_height = Element.getHeight($('content_block'));
    var tmp = Element.getHeight($(id));

    Effect.SlideDown(id, { duration: 0.2 });

    if (c_height + tmp + 100 > max_height) {
      max_height = max_height + tmp;
      
      $('main_content_id').style.height = max_height + 'px';
      $('left_content_id').style.height = max_height + 'px';
      $('right_content_id').style.height = max_height + 'px';
    }
  } else {
    hideItemInfo(id);
  }
}


function hideItemInfo(id) {
  var max_height = Element.getHeight($('left_content_id'));
  var c_height = Element.getHeight($('content_block'));
  var tmp = Element.getHeight($(id));
  
  Effect.SlideUp(id, { duration: 0.1 });  
  
  if (c_height - tmp > original_height) {
    max_height = max_height - tmp;
    
    $('main_content_id').style.height = max_height + 'px';
    $('left_content_id').style.height = max_height + 'px';
    $('right_content_id').style.height = max_height + 'px';
  } else {
    $('main_content_id').style.height = original_height + 'px';
    $('left_content_id').style.height = original_height + 'px';
    $('right_content_id').style.height = original_height + 'px';  
  }
}

Event.observe(window, 'load', fixHeight);