// (c) M.Boerger: mailto:marcus.boerger@post.rwth-aachen.de
// See Copyright-Info at / Beachten Sie Copyright-Info in Seite
// http://www.marcus-boerger.de/js/DynamicJavaScript.html
// Scriptname: AutoReload.js


function ParamConcat( P1, P2) {
  if ( P1 == "") return P2;
  if ( P2 == "") return P1;
  return P1 + "," + P2;
}

function ParamNoNavigation( Params) {
  return ParamConcat( "TOOLBAR=NO,LOCATION=NO,DIRECTORIES=NO,STATUS=YES,MENUBAR=NO,SCROLLBARS=YES,RESIZABLE=NO,COPYHISTORY=NO", Params);
}

function ParamFullscreen() {
  return "FULLSCREEN=1";
}

function ParamSize( iWidth, iHeight) {
  return "WIDTH=" + iWidth + ",HEIGHT=" +iHeight;
}

function Param1024x768() {
  return ParamSize( 1016, 760);
}

function Param800x600() {
  return ParamSize( 792, 592);
}

function ParamDefault() {
  return ParamNoNavigation( Param1024x768());
}

function AutoOpen( url, name, params) {
  if ( name == "_top") {
    window.top.location = url;
  } else {
    window.open( url, name, params);
    if ( name == "_blank") {
      window.close();
    }
  }
}

// url: url must part of top-window-location (that is what the browser displays in location bar)
// name: name of window to open
// params: parameters to pass to new/opend window
// file: if true the functions works with "file://..." otherwise on such resources it does nothing
// open_url: url to open. if left blank than url is used.
function ForceTop( url, name, params, file, open_url) {
  if ( ( navigator.appName.indexOf( "Netscape") >= 0 && parseInt( navigator.appVersion) >= 3) || parseInt( navigator.appVersion) >= 4 ) {
    if ( window.location.protocol.toLowerCase().indexOf( "file") < 0 || file) {
      pos = url.lastIndexOf( "/");
      if ( (window.top.location.href.indexOf( url)<0 && url!='/') || (url=='/' && (window.top.location.pathname!='/' || window.top.location.hostname!=location.hostname))) {
        // Im richtigen Frame-Kontext laden.
        if ( !open_url) open_url=url;
        else if ( !open_url.length) open_url=url;
        // Benutzen Sie folgende Zeile, um zu sehen was passiert
        // Use the following line to see what is happening
        /*
        alert( "href:'"+location.href+"'\n"+
               "url:'"+url+"'\n"+
               "path:'"+window.top.location.pathname+"'\n"+
               "host:'"+window.top.location.hostname+"'\n");
        */
        window.setTimeout( "AutoOpen( '"+open_url+"', '"+name+"', '"+params+"');", 250);
      }
    }
  }
}
