$(function() {
  /*@cc_on _d=document;eval('var document=_d')@*/
  var isIE = /*@cc_on!@*/false;
  
  //  + #container
  //      + #header
  //      + #main_contents
  //          + #main_contents_inner
  //              + #side_bar
  //                  - #sidebar_inner
  //                  - #footer
  //
  //

  window.__FOOMA_HEIGHT_CONTENTS_DEFAULT = $( '#contents_area').height();  // # contents_area のデフォルト高さ．newsloader.js とやりとりするためにグローバルに格納しておく

  var fixfooter = function() {
    var header   = $( '#header')
      , contents = $( '#contents_area' )
      //, contents = $( '#side_bar_inner' )
      , footer   = $( '#footer' )
      , win      = $( window )
      , body     = $( '#container' ) //$( 'body' )
    ;
  
    var h = {
      header:   header.height(),
      contents: contents.height(),
      footer:   footer.height(),
      win:      win.height(),
      body:     body.height()
    };
    if( isIE ) {
      h.win = document.body.clientHeight || document.documentElement.clientHeight || body.height();
    }

    var height_contents_after = h.contents + ( h.win - h.body);

    if( h.body < h.win  ||  height_contents_after > window.__FOOMA_HEIGHT_CONTENTS_DEFAULT ) {
      contents.height( height_contents_after );
      //alert( 'javascript has fixed the size of document.' );
    }
  };

  fixfooter();

  var __window_onresize = window.onresize  ||  function(){};
  window.onresize = function( e ) {
    __window_onresize( e );
    fixfooter();
  };

});
