/*
    titel:  JavaScript Frame-Page-Controlling
    author: Rolf-Stephan Badura
    email:  badura@badura-software.de
    URL:    http://www.badura-software.de
    date:   2000-02-26

    (c)1999-2008 Badura Software-Entwicklung & Beratung 
    All rights reserved. Alle Rechte vorbehalten.
*/



function CheckSubPageState( )
{
  if ( top.frames.length <= 0 )
    LoadIndexPage( );    /* webpage isn't in frame context */
  else
    FocusContentPage( ); /* focus for scrolling keys */
}


function FocusContentPage( )
{
  /* focus for scrolling keys */
  
  theContentPage = top.frames.content;
  theContentPage.focus( ); /* only Netscape */
}


function LoadIndexPage( )
{
  /* webpage isn't in frame context, load frameset */
  /* (could be a loop problem with frameless javascript browsers!) */
  
  theURL = top.location.href;

  /* find filename in URL */
  
  theStartIndex = theURL.lastIndexOf(".html");
    
  if ( theStartIndex > 0 )
  {
    theEndIndex     = theStartIndex;
   
    for( theIndex = theStartIndex; theIndex >= 0; theIndex-- )
    {
      theChar = theURL.charAt( theIndex );
      if ( theChar == "/" || theChar == "\\" )
      {
        theStartIndex = theIndex + 1;
        break;
      }
    };
    
    if ( theStartIndex != theEndIndex )
    {
      /* check english or german sub website */
      
      if ( theURL.indexOf(".en.html") > 0 )
      {
        theIndexName   = "index.en.html";
        theConfirmMsg = "This page was loaded without frames!\nCould I load the rest of the missing frames?"
      }
      else
      {
        theIndexName = "index.html";
        theConfirmMsg = "Diese Seite wurde ohne Frames geladen!\nDarf ich die fehlenden Frames nachladen?"
      }
      
      if ( confirm( theConfirmMsg ) )
      {
        /* load the index.html or index.en.html page */
      
        theNewURL = theURL.substring( 0, theStartIndex ) + theIndexName + theURL.substring( theEndIndex + 5, theURL.length );
        top.location.href = theNewURL;
        
        /* to do: frame site should be reloaded... possibly with # or ? */
      }
    }
    /* else ... do nothing! */
  }
}

/* end */