var DHTML = false, DOM = false, MSIE4 = false, NS4 = false, OP = false;

// initialization
if ( document.getElementById )
{
   DHTML = true;
   DOM = true;
}
else {
   if (document.all)
   {
      DHTML = true;
      MSIE4 = true;
   }
   else {
      if (document.layers) {
         DHTML = true;
         NS4 = true;
      }
   }
}
if (window.opera) {
   OP = true;
}

function getElement ( Mode, Identifier, ElementNumber )
{
/*
      document.layers[id].left = x;
      document.layers[id].top = y;
   else if ( MSIE4 )
      document.all[id].style.left = x;
      document.all[id].style.top = y;
*/
   var Element, ElementList;

   if ( DOM )
   {
      if (Mode.toLowerCase() == "id")
      {
         Element = document.getElementById(Identifier);
         if (!Element) {
            Element = false;
         }
         return Element;
      }
      if (Mode.toLowerCase() == "name") {
         ElementList = document.getElementsByName(Identifier);
         Element = ElementList[ElementNumber];
         if (!Element) {
            Element = false;
         }
         return Element;
      }
      if (Mode.toLowerCase() == "tagname") {
         ElementList = document.getElementsByTagName(Identifier);
         Element = ElementList[ElementNumber];
         if (!Element) {
            Element = false;
         }
         return Element;
      }
      return false;
   } // DOM
   if ( MSIE4 )
   {
      if (Mode.toLowerCase() == "id" || Mode.toLowerCase() == "name")
      {
         Element = document.all(Identifier);
         if (!Element) {
            Element = false;
         }
         return Element;
      }
      if (Mode.toLowerCase() == "tagname")
      {
         ElementList = document.all.tags(Identifier);
         Element = ElementList[ElementNumber];
         if (!Element) {
            Element = false;
         }
         return Element;
      }
      return false;
   } // MSIE4
   if ( NS4 )
   {
      if ( Mode.toLowerCase() == "id" || Mode.toLowerCase() == "name" )
      {
         Element = document[Identifier];
         if (!Element) {
            Element = document.anchors[Identifier];
         }
         if (!Element) {
            Element = false;
         }
         return Element;
       }
       if ( Mode.toLowerCase() == "layerindex" )
       {
          Element = document.layers[Identifier];
          if (!Element) {
            Element = false;
          }
          return Element;
       }
       return false;
   } // NS4
   return false;
}

var menuBaseHeight = 268;
var menuVSpace = 34;
var mbuttonwidth = 152;
/*
      if ( document.layers ) {
      checkWidth = window.innerWidth;
      checkHeight = window.innerHeight;
      window.onResize = resizeFix;
   }

   function resizeFix() {
      if (widthCheck != window.innerWidth || heightCheck != window.innerHeight)
      document.location.href = document.location.href
   }
*/

//%---------------------------------------------------------------------------
function winWidth()
{
   if ( window.innerWidth ) {
      return window.innerWidth;
   } else if ( document.body && document.body.offsetWidth ) {
      return document.body.offsetWidth;
   } else {
      return 0;
   }
}

function winHeight()
{
   if ( window.innerHeight ) {
      return window.innerHeight;
   } else if ( document.body && document.body.offsetHeight ) {
      return document.body.offsetHeight;
   } else {
      return 0;
   }
}

function doResize()
{
   computeMenus();
   if ( Weite != winWidth() || Hoehe != winHeight() ) {
      location.href = location.href;
   }
   Weite = winWidth();
   Hoehe = winHeight();
}

if ( document.layers ) {
   window.onResize = doResize;
}

//%---------------------------------------------------------------------------
function tbMenu( text, link, width )
{
   this.text = text;
   this.link = link;
   this.itemcount = 0;
   this.items = new Array(0);
   this.width = width;

   this.addItem = addMenuItem;
}

function tbMenuItem( text, link )
{
   this.text = text;
   this.link = link;
}

function addMenuItem( text, link )
{
   var len = this.items.length;
   this.itemcount = len+1;
   temp = new Array( this.itemcount );
   for( i=0; i<len; i++ ) {
      temp[i] = this.items[i];
   }
   temp[len] = new tbMenuItem( text, link );
   this.items = temp;
}

//%---------------------------------------------------------------------------
function showMenu( id )
{
   if (NS4)
   {
      for( i=0; i<menuCount; i++ ) {
         hide( 'content'+i );
      }
      document.menu.layers[id].visibility = "show";
   }
   else if ( MSIE4 || DOM )
   {
      for( i=0; i<menuCount; i++ )
      {
         hide( 'content'+i );
      }
      show( id );
      // document.all[id].style.visibility = "visible";
   }
}

//%---------------------------------------------------------------------------
/*
function hideMenu() {
   alert( "hideMenu" );
	if (NS4) {
      document.layers[this.name].visibility = "hide";
   }
	else if ( MSIE4 ) {
       document.all[this.name].style.visibility = "hidden";
   }
}
*/

//%---------------------------------------------------------------------------
function writeMenu()
{
   width = getMenuXPos();
// document.write("Halloooooooooooooo");
// alert( "NS4 = " + NS4 + ", DOM = " + DOM + ", MSIE4 = " + MSIE4 + ", OP = " + OP );

   if  (NS4)
   {
      document.write( "<layer id=\"menu\" left=\""+width+"\" top=\""+menuBaseHeight+"\" width=\"30\" height=\"96\"  z-index=\"0\">" );
      for( i=0; i<menuCount; i++ )
      {
         // Menuitem
         document.write( "<layer id=\"item"+i+"\"  left=\"0\" top=\""+(i*menuVSpace)+"\" width=\""+mbuttonwidth+"\" height=\"34\" z-index=\""+(i*2)+1+"\">" );
         document.write(  "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>" );
         document.write( "<td  background=\"../../img/menu_button_bg.gif\"><img src=\"../../img/menu_button_l.gif\" width=\"16\" height=\"34\"></td>" );
          document.write( "<td background=\"../../img/menu_button_bg.gif\" width=\"69\" valign=\"middle\" align=\"left\"><a  href=\""+menus[i].link+"\" onMouseOver=\"showMenu('content"+i+"')\"><span class=\"mainmenu\">"+menus[i].text+"</span></a></td>" );
          document.write( "<td align=\"right\" background=\"../../img/menu_button_bg.gif\"><img src=\"../../img/menu_button_r.gif\" width=\"17\"  height=\"34\"></td>" );
         document.write( "</tr></table></layer>" );

         // Menuitem and content
         document.write(  "<layer id=\"content"+i+"\" left=\"-"+(menus[i].width+13)+"\" top=\""+(i*menuVSpace)+"\" width=\"228\" height=\"78\"  z-index=\""+(i*2)+2+"\" visibility=\"hide\" onMouseOut=\"hide('content"+i+"')\"  onMouseOver=\"show('content"+i+"')\">" );
         document.write( "<table border=\"0\" cellspacing=\"0\"  cellpadding=\"0\"><tr><td>" );
         document.write( "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" );
          document.write( "<tr valign=\"top\" align=\"left\">" );
         document.write( "<td bgcolor=\"#05066D\" width=\"7\"><img  src=\"../../img/menu_l_corner_t.gif\" width=\"7\" height=\"8\"></td>" );
         document.write( "<td width=\"100\"  bgcolor=\"#05066D\"><img src=\"../../img/menu_edge_t.gif\" width=\""+menus[i].width+"\" height=\"8\"></td></tr>" );

         // Content  i
         for( j=0; j<menus[i].itemcount; j++ )
         {
            document.write( "<tr>" );
            document.write( "<td  bgcolor=\"#05066D\"><img src=\"../../img/menu_l_edge.gif\" width=\"7\" height=\"20\"></td>" );
            document.write( "<td  bgcolor=\"#05066D\"><a href=\""+menus[i].items[j].link+"\"><span class=\"submenu\">"+menus[i].items[j].text+"</span></a></td>" );
             document.write( "</tr>" );
         } // for j

         // unterer Contentrand
         document.write( "<tr><td valign=\"top\"><img  src=\"../../img/menu_l_corner_b.gif\" width=\"7\" height=\"8\"></td>" );
         document.write( "<td valign=\"top\"><img  src=\"../../img/menu_edge_b.gif\" width=\""+menus[i].width+"\" height=\"8\"></td>" );
         document.write( "</tr></table></td>" );
          document.write( "<td align=\"left\" valign=\"top\">" );
         // Menuadapter
         document.write( "<table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" );
         document.write( "<tr valign=\"top\" align=\"left\" nowrap>" );
          document.write( "<td bgcolor=\"#05066D\" background=\"../../img/menu_button_bg.gif\"><img src=\"../../img/menu_adapter.gif\" width=\"19\"  height=\"33\"><img src=\"../../img/blank.gif\" width=\"3\" height=\"33\"></td>" );
         document.write( "</tr></table></td><td  align=\"left\" valign=\"top\">" );
         // Menu
         document.write( "<table width=\"100%\" border=\"0\" cellspacing=\"0\"  cellpadding=\"0\"><tr>" );
//         document.write( "<td background=\"../../img/menu_button_bg.gif\" align=\"left\">&nbsp;</td>" );
          // document.write( "<td background=\"../../img/menu_button_bg.gif\" width=\"69\" valign=\"middle\" align=\"left\"><a  href=\""+menus[i].link+"\" onMouseOver=\"show('content"+i+"')\"><span class=\"mainmenu\">"+menus[i].text+"</span></a></td>"  );
         // document.write( "<td align=\"right\" background=\"../../img/menu_button_bg.gif\"><img src=\"../../img/menu_button_r.gif\"  width=\"17\" height=\"34\"></td>" );
         document.write( "<td background=\"../../img/menu_button_bg.gif\" valign=\"middle\"  align=\"left\"><a href=\""+menus[i].link+"\" onMouseOver=\"show('content"+i+"')\"><span  class=\"mainmenu\">"+menus[i].text+"</span></a></td>" );
         document.write( "<td align=\"right\"  background=\"../../img/menu_button_bg.gif\"><img src=\"../../img/menu_button_r.gif\" width=\"17\" height=\"34\"></td>" );
          document.write( "</tr><tr>" );
//         document.write( "<td align=\"left\"><img src=\"../../img/blank.gif\" width=\"2\"  height=\"1\"></td>" );
         // document.write( "<td width=\"69\" valign=\"middle\" align=\"left\"><img src=\"../../img/blank.gif\"  width=\"69\" height=\"1\"></td>" );
         // document.write( "<td align=\"right\">&nbsp;</td>" );
         document.write( "<td  align=\"left\"><img src=\"../../img/blank.gif\" width=\"119\" height=\"1\"></td>" );
         document.write( "<td align=\"left\"><img  src=\"../../img/blank.gif\" width=\"17\" height=\"1\"></td>" );
         document.write( "</tr></table></td></tr></table></layer>" );
       } // for i
      document.write( "</layer>" );
      for( i=0; i<menuCount; i++ ) {
         hide( 'content'+i );
      }
    } // END: if (NS4)
   else if ( MSIE4 || DOM )
   {
      // left: 688
      document.write( "<div id=\"menu\" style=\"position:absolute; width:203px; height:99px; z-index:0; left: "+width+"px; top: "+menuBaseHeight+"px\">" );
      for( i=0; i<menuCount; i++ )
      {
          // Menuitem
         document.write( "<div id=\"item"+i+"\" style=\"position:absolute; width:"+mbuttonwidth+"px; height:34px;  z-index:"+(i*2)+1+"; left: 0px; top: "+(i*menuVSpace)+"px\">" );
         document.write( "<table width=\"100%\" border=\"0\"  cellspacing=\"0\" cellpadding=\"0\"><tr>" );
         document.write( "<td background=\"../../img/menu_button_bg.gif\" width=\"16\" ><img  src=\"../../img/menu_button_l.gif\" width=\"16\" height=\"34\"></td>" );
         document.write( "<td  background=\"../../img/menu_button_bg.gif\" valign=\"middle\" align=\"left\"><a href=\""+menus[i].link+"\"  onMouseOver=\"showMenu('content"+i+"')\"><span class=\"mainmenu\">"+menus[i].text+"</span></a></td>" );
         document.write( "<td  align=\"right\" background=\"../../img/menu_button_bg.gif\" width=\"17\" ><img src=\"../../img/menu_button_r.gif\" width=\"17\"  height=\"34\"></td>" );
         document.write( "</tr></table></div>" );

         // Menuitem and content
         document.write( "<div  id=\"content"+i+"\" style=\"position:absolute; width:228px; height:78px; z-index:"+(i*2)+2+"; left: -"+(menus[i].width+13)+"px; top:  "+(i*menuVSpace)+"px\"; visibility:hidden; onMouseOut=\"hide('content"+i+"')\" onMouseOver=\"show('content"+i+"')\">" );
          document.write( "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td>" );
         document.write( "<table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" );
         document.write( "<tr valign=\"top\" align=\"left\">" );
          document.write( "<td bgcolor=\"#05066D\" width=\"7\"><img src=\"../../img/menu_l_corner_t.gif\" width=\"7\" height=\"8\"></td>" );
          document.write( "<td width=\"100\" bgcolor=\"#05066D\"><img src=\"../../img/menu_edge_t.gif\" width=\""+menus[i].width+"\"  height=\"8\"></td></tr>" );
         // Content i
         for( j=0; j<menus[i].itemcount; j++ )
         {
            document.write(  "<tr>" );
            document.write( "<td bgcolor=\"#05066D\"><img src=\"../../img/menu_l_edge.gif\" width=\"7\" height=\"20\"></td>" );
             document.write( "<td bgcolor=\"#05066D\"><a href=\""+menus[i].items[j].link+"\"><span  class=\"submenu\">"+menus[i].items[j].text+"</span></a></td>" );
            document.write( "</tr>" );
         }
         // unterer  Contentrand
         document.write( "<tr><td valign=\"top\"><img src=\"../../img/menu_l_corner_b.gif\" width=\"7\" height=\"8\"></td>"  );
         document.write( "<td valign=\"top\"><img src=\"../../img/menu_edge_b.gif\" width=\""+menus[i].width+"\" height=\"8\"></td>"  );
         document.write( "</tr></table></td>" );
         document.write( "<td align=\"left\" valign=\"top\">" );
         //  Menuadapter
         document.write( "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" );
         document.write(  "<tr valign=\"top\" align=\"left\" nowrap>" );
         document.write( "<td bgcolor=\"#05066D\"  background=\"../../img/menu_button_bg.gif\"><img src=\"../../img/menu_adapter.gif\" width=\"19\" height=\"33\"><img  src=\"../../img/blank.gif\" width=\"3\" height=\"33\"></td>" );
         document.write( "</tr></table></td><td align=\"left\"  valign=\"top\">" );
         // Menu
         document.write( "<table width=\"100%\" border=\"0\" cellspacing=\"0\"  cellpadding=\"0\"><tr>" );
//         document.write( "<td background=\"../../img/menu_button_bg.gif\" align=\"left\">&nbsp;</td>" );
          document.write( "<td background=\"../../img/menu_button_bg.gif\" valign=\"middle\" align=\"left\"><a href=\""+menus[i].link+"\"  onMouseOver=\"show('content"+i+"')\"><span class=\"mainmenu\">"+menus[i].text+"</span></a></td>" );
         document.write( "<td  align=\"right\" background=\"../../img/menu_button_bg.gif\"><img src=\"../../img/menu_button_r.gif\" width=\"17\" height=\"34\"></td>" );
          document.write( "</tr><tr>" );
//         document.write( "<td align=\"left\"><img src=\"../../img/blank.gif\" width=\"2\"  height=\"1\"></td>" );
         document.write( "<td align=\"left\"><img src=\"../../img/blank.gif\" width=\"119\" height=\"1\"></td>" );
          document.write( "<td align=\"left\"><img src=\"../../img/blank.gif\" width=\"17\" height=\"1\"></td>" );
         document.write(  "</tr></table></td></tr></table></div>" );
      } // for i
      document.write( "</div>" );
      for( i=0; i<menuCount; i++ ) {
          hide( 'content'+i );
      }
   } // END: if ( MSIE4 )
   // computeMenus();
}


//%---------------------------------------------------------------------------
function initialize()
{
   // evtl. Mac
   if( NS4 ) {
      loadCSSFile( "../../includes/quick_ns.css" );
   } else {
      loadCSSFile( "../../includes/quick_ie.css" );
   }
// window.setsize( 640, 480 );
}

//%---------------------------------------------------------------------------
function getMenuXPos()
{
   x = winWidth() - 172;

   if ( navigator.appName == "Netscape" ) {
      x += 4;
   }

   if( x < 590 ) {
      x = 590;
   }

   return x;
}


//%---------------------------------------------------------------------------
function computeMenus()
{
   xpos = getMenuXPos();
   moveTo( "menu", xpos, menuBaseHeight );
/*
   if ( NS4 )
   {
      for( i=0; i<menuCount; i++ ) {
         hide( 'content'+i );
      }
      document.menu.layers[id].visibility = "show";
   }
*/
}


//%---------------------------------------------------------------------------
function printCategory()
{
   document.write( g_category  );
}

//%---------------------------------------------------------------------------
function printLang( lang )
{
   img =  "../../img/lang_english_off.gif";
   imgwidth = 0;
   imgref = "../../"+lang+"/"+thisfile;

   switch ( lang )
   {
      case "de":
          imgwidth = 53;
         img = "../../img/lang_deutsch_off.gif";
         break;
      case "en":
         imgwidth = 52;
         img =  "../../img/lang_english_on.gif";
         imgref = null;
         break;
      case "fr":
         imgwidth = 54;
         img =  "../../img/lang_francais_off.gif";
         break;
      case "es":
         imgwidth = 52;
         img =  "../../img/lang_espagnol_off.gif";
         break;
   }

   if( imgref == null ) {
      document.write( "<img src=\""+img+"\"  width=\""+imgwidth+"\" height=\"20\">" );
   } else {
      document.write( "<a href=\""+imgref+"\"><img src=\""+img+"\"  width=\""+imgwidth+"\" height=\"20\" border=\"0\"></a>" );
   }
}

//%---------------------------------------------------------------------------
function printBanner()
{
   // <span  class="text">xxx</span>
   document.write( "<img src=\"../../img/blank.gif\" width=\"16\" height=\"35\">" );
}

//%---------------------------------------------------------------------------
function printImprint()
{
   document.write( "<a  href=\"../imprint/imprint.html\" class=\"lnwhite\">" + imprint + "</a>" );
}

//%---------------------------------------------------------------------------
function loadCSSFile( cssFile )
{
   stylesheetURL = "<link  rel='stylesheet' href='"+cssFile+"' type='text/css'>";
   document.write( stylesheetURL );
}

//%---------------------------------------------------------------------------
//  Show/Hide functions for non-pointer layer/objects
function show( id )
{
   if ( NS4 ) {
      getElement( "id", id ).visibility = "show";
   }
   else {
      getElement( "id", id ).style.visibility = "visible";
   }
}

//%---------------------------------------------------------------------------
function  hide(id) {
   if ( NS4 ) {
      getElement( "id", id ).visibility = "hide";
   }
   else {
      getElement( "id", id ).style.visibility = "hidden";
   }
}

//%---------------------------------------------------------------------------
function moveTo( id, x, y )
{
   if ( NS4 ) {
      getElement( "id", id ).left = x;
      getElement( "id", id ).top = y;
   }
   else if ( MSIE4 || DOM ) {
      getElement( "id", id ).style.left = x;
      getElement( "id", id ).style.top = y;
   }
}
