/*
    titel:  JavaScript Frame-Page-Controlling
    author: Rolf-Stephan Badura
    email:  badura@badura-software.de
    URL:    http://www.badura-software.de
    date:   2004-09-29

    (c)1999-2004 Badura Software-Entwicklung & Beratung 
    All rights reserved. Alle Rechte vorbehalten.
*/



function changeImages( )
{
	if (document.images && (gPreloadFlag == true))
	{
		for (var i=0; i<changeImages.arguments.length; i+=2)
		{
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var gActualMenu = "info"
function changeMenu( inMenuName )
{
	if ( gActualMenu != "info" )
	{
		changeImages( gActualMenu, "pictures/menu/" + gActualMenu + ".gif");
	}
	
	gActualMenu = inMenuName;
	
	if ( gActualMenu != "info" )
	{
		changeImages( gActualMenu, "pictures/menu/" + gActualMenu + ".over.gif");
	}
	return true;
}

function rolloverMenu( inMenuName )
{
	
	if ( inMenuName != gActualMenu || inMenuName == "info" )
	{
		changeImages( inMenuName, "pictures/menu/" + inMenuName + ".over.gif");
	}
	return true;
}

function rolloutMenu( inMenuName )
{
	if ( inMenuName != gActualMenu || inMenuName == "info" )
	{
		changeImages( inMenuName, "pictures/menu/" + inMenuName + ".gif");
	}
	return true;
}

function newImage( arg )
{
	if (document.images)
	{
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

var gPreloadFlag = false;
function preloadImages( )
{
	if ( document.images )
	{
		<!--info_over			= newImage("pictures/menu/info.over.gif");-->

		gPreloadFlag = true;
	}
}


function checkSubPageState( )
{
  if ( top.frames.length <= 0 )
    loadIndexPage( );    /* webpage isn't in frame context */
}


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 || theURL.indexOf(".pl.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 ( true )  /* 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! */
  }
}


function initMenuFrame( )
{
	preloadImages( );
	checkSubPageState( );
}


/* end */