
/* Javascript module for frame handling (c) Stefan Bebbo Franke 1998-2011
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Commercial usage granted to IKOR Products GmbH.
 *
 */
function dump(o) { // helper function to dump an object
  s = "properties of " + o + "\r\n";
  for(x in o) {
    var z = "" + o[x];
    if (z.indexOf("[native code]") < 0)
      s += x + " = " + z + ", ";
  }
  alert(s);
}
function _mark(t) { // call the navigation menu
  var nav = parent.frames['navi'];
  if (nav) nav.$m(t);
}
function _handleA(ev) { // hook for A elements
  if (!ev) ev = window.event;
  var t = ev.target ? ev.target : ev.srcElement;
  if (t.nodeName != "A") t = t.parentNode;
  if (t.nodeName == "A" && t.href) _mark(t.href);
}
function _handleF(ev) { // hook. for FORM elements
  if (!ev) ev = window.event;
  if (!ev.target) ev.target = ev.srcElement;
  if (ev.target.action) _mark(ev.target.action);
}
function $resize(o) { // reload surrounding frame and resize this frame
  var u = '' + this.location;
  // check for outer page containg this frame
  if(parent.frames.length == 0) {
    var i = u.indexOf('/', 8);
    if (i > 0) {
      i += 1;
      u = u.substring(0, i) + '#' + u.substring(i);
      this.document.location = u;
    }
    return;
  }
  // load the redirected content into main
  if (!parent.reframed) {
    parent.reframed = true;
    var t = '' + parent.location;
    var ri = t.indexOf("#");
    if (ri > 0) {
      var s = t.substring(0, ri);
      var u = s + t.substring(ri + 1);
      var l = '' + parent.main.location;
      if (l != u) {
        parent.main.location = u;
        _mark(u);
  } } }
  // now hook all links to update the menu
  if (document.all)
  {
    document.onclick = _handleA;
    var fs = document.forms;
    for (var i = 0; i < fs.length; ++i) {
      fs[i].onsubmit = _handleF;
    }
  } else {
    document.addEventListener("click", _handleA, true);
    document.addEventListener("submit", _handleF, true);
  }
}

