// openHTM.js
// Standort: In jedem DefaultDocument (index.html) einer jeden Ebene.
// Aufruf im Header
// Sofern Frames vorhanden, im Frame FraNAV lokalisiert

function IsNotProtocolHttp(){
   var strProtocol="";
   strProtocol=window.location.protocol;
   if (strProtocol==="http:"){
      return false;
   }else{
      document.write("<font color=\"red\">Achtung: Wurde mit Protocol <b>"+strProtocol+"</b> geöffnet</font><br>");
      return true;
   }      
}

function HasNoFrames(){
   return (top.frames.length===0);
}
function CallRoot(){
// Ermitteln des aktuellen Pfades
   var strPath =""; 
   strPath=window.location.pathname;
   strPath= strPath.substring(1, strPath.lastIndexOf("/")+1);
// Searchstring berücksichtigen
   var strSearch = "";
   strSearch=window.location.search;
   if(strSearch != ""){strSearch ="&"+ strSearch.substr(1,strSearch.length);}
// Lenke um zur Index.php im Rootverzeichnis ('/') mit Parametern
   if(strPath== "" && strSearch== ""){
      strNeueURL = "/index.php";
   }else{
      strNeueURL = "/index.php?path="+strPath+strSearch;
   }
// Weise neue Adresse zu
   document.location.href = strNeueURL;
}

function IsOutOfSynch(){
// Tatsächlicher Pfad dieser Content-Datei (HTM)
   var strPathNAV="";
   strPathNAV= document.location.pathname;
   strPathNAV= strPathNAV.substring(0,strPathNAV.lastIndexOf("/")+1);
// top.fraWer.document.write("NAV: "+strPathNAV);

// Pfadanteil der NAVigationsseite (HTML) im Document ausgeben
//   document.write("::"+strPathNAV+"<br>");
// Inhalt des Contentframes prüfen
   var strPathCON ="";
   strPathCON =top.fraCon.location.pathname;
   strPathCON=strPathCON.substring(0,strPathCON.lastIndexOf("/")+1);
   // Wenn der Pfadanteil der Inhaltsdatei (hier) nicht mit der NAVigation übereinstimmt
      if(strPathCON != strPathNAV){
   // dann manipuliere den (fernen) CONtentframe

      top.fraCon.location.href = strPathNAV+"index.htm";
   }
}
// Ausführen bei Laden des Skripts:
var cancel=false;
// Abbrechen, wenn das Protocol nicht http ist
   cancel=IsNotProtocolHttp();
// Sofern nicht abgebrochen, prüfen, ob Frameseite vorhanden ist.
if (cancel===false) {
   cancel=HasNoFrames();
   if (cancel===true){ CallRoot()}else{ IsOutOfSynch()};
}



