/* there's lots of voodoo to do for a working map. Most of it is in here.
 *
 * CONTENTS:
 * ---------
 * function set_map_area () -> calculate div size for the map and the layout (reduced to layout only for now)
 * register set_map_area () as resize event handler
 */

  // trick around the map positioning problem
  // to position the map I need to use the position:absolute style attribute. this means, that the div for the map is taken out of the text flow and
  // placed anywhere on screen. it's necessary, because in standard compliance mode the "float: right" map positioning doesn't work (the map height
  // is not relative to the screen height using 50%). But, because taken out of text flow, the map is not surrounded, it's overflown by the text. to
  // workaround this problem I use "float: right" and an onresize event handler to keep div 50% of the size of the surrounding div. It seems to work.

  // and for standards compliance now everything on screen is in divs, and I insist in having them resize with the users browser window, too. So all
  // basic layout divs are adjusted in size according to the browser window. I hope this works as expected...

  // define function for onresize event and register it
  function set_map_area () {
    var height;  // total height
    var height_navi;  // calculated height of navigation div
    var height_main;  // height of main div
    var div_browser_window, div_browser_header, div_browser_main, div_browser_footer, div_navi_main2, div_navi_main, div_main, div_map;  // div handles
    var Minimum = 240;  // minimum map size 240x240
    var Maximum = 600;  // maximum map size 600x600

    div_browser_window = getElement('id', "browser_window", null);  // get div handles
    div_browser_header = getElement('id', "browser_header", null);  // We still need to use the really old dhtml.js
    div_browser_main = getElement('id', "browser_main", null);      // helper functions, as browsers (especially IE)
    div_browser_footer = getElement('id', "browser_footer", null);  // still don't support the DOM correctly.
    div_navi_main = getElement('id', "navi_main", null);            // This is more than stupid...
    div_navi_main2 = getElement('id', "navi_main2", null);
    div_main = getElement('id', "main", null);
//    div_map = getElement('id', "map", null);  // this is the map

    // width of main area always fits into the browser window. Hopefully the browser immediately adjusts the div.height: auto and
    // gives back those values, so we can set the new heights. At least, Firefox does.

    // ok, first we have to find the maximum height for the content. awfully the .navi_main is not auto-sized to the content, because the content must
    // overflow (overflow: visible;). So we have to set .navi_main.height to the required total height, too.
    // also we have to check the browsers total space, as we may have to adjust height to screen space if all content is smaller

    height = div_browser_window.clientHeight;  // total screen height
    height_navi = div_navi_main2.clientHeight; // navi-content height
    height_main = div_main.clientHeight;  // main-content height

    if (height_navi > height_main) height_main = height_navi;  // select navi-content height if bigger than main-content height

    height -= (div_browser_header.clientHeight+1);  // reduce the screen height by the fixed height content
    height -= (div_browser_footer.clientHeight+1);  // (need to get border values from the handle)

    if (height > height_main) height_main = height;  // select the remaining screen space if bigger than content

    div_browser_main.style.height = height_main + "px";  // set main row to get correct scroll bar (div_main must remain "auto"!)
    div_navi_main.style.height = (height_main-(4+4)) + "px";  // need to get the border and padding values from the handle

    return;  // don't process the map stuff up to now

/*    // the map shall be half the main area size:
    height = Math.round (height/2);
    width = Math.round (width/2);

    // there's already a lower limit to the map dimensions because of the window limit,
    // but I don't want the map to become smaller than the zoombar and stuff:
    if (height < Minimum) { height = Minimum; }
    if (width < Minimum) { width = Minimum; }

    // also I don't want the map to grow too big to have control of the tile requirements on the webserver:
    if (height > Maximum) { height = Maximum; }
    if (width > Maximum) { width = Maximum; }

    // now let's set the size:
    div_map.style.height = height + "px";
    div_map.style.width = width + "px";
*/  };

  // register set_map_area () as resize event handler
  window.onresize = set_map_area;  // register the event handler



