// navbar.js - hb@ec-logic.com - 20.11.2001
// Globale Variablen für crossbrowser funktionen
var dom = (document.getElementById) ? true : false;
var ns = (document.layers) ? true : false;
var ie = (document.all) ? true : false;
var ie4 = ie && !dom;
var mac = (navigator.appVersion.indexOf("Mac") != -1);
var ver=parseInt(navigator.appVersion);
var active = null;
var showverb='visible';
if ((ns) && ver == 4) showverb='show';
var hideverb='hidden';
// menu array
var menu = new Array();
// array für preload images
var imgs = new Array;
var prel = false;
var active = null;
var activeparent = null;
var strRoot = '/';
//var strRoot = '/';
if (typeof(dx) == 'undefined')
	var dx=0;
if (typeof(dy) == 'undefined')
	var dy=0;
// main menue - MenuID,ParentID, Link, rel. Gifpfad, Alt, y, x
AddMenuitem('home', null, 'default.htm','web_de/inc/home_w.gif','',109, 35);
AddMenuitem('news', null, 'web_de/news/default.htm', 'web_de/inc/news_w.gif', '', 109, 80);
AddMenuitem('products', null, 'web_de/products/default.htm', 'web_de/inc/products_w.gif', '', 109, 122);
AddMenuitem('samples', null, 'web_de/samples/classic.htm', 'web_de/inc/samples_w.gif', '', 109, 181);
AddMenuitem('papers', null, 'web_de/ads/faqkonfigurator.htm', 'web_de/inc/papers_w.gif', '', 109, 227);
AddMenuitem('mission', null, 'web_de/projects/consulting.htm', 'web_de/inc/mission_w.gif', '', 109, 291);
AddMenuitem('partners', null, 'web_de/solutions/default.htm', 'web_de/inc/partners_w.gif', '', 109, 351);
AddMenuitem('company', null, 'web_de/contact/default.htm', 'web_de/inc/company_w.gif', '', 109, 404);
AddMenuitem('download', null, 'web_de/downloads/default.htm', 'web_de/inc/download_w.gif', '', 109, 480);
AddMenuitem('memo', null, 'web_de/memo.htm','web_de/inc/notices_w.gif','',109, 589);
// mail etc.
AddMenuitem('mailme', null, 'web_de/scripts/mailform.asp', 'web_de/inc/mailme_w.gif', 'Schreiben Sie uns', 30, 600);
// AddMenuitem('tella', null, 'javascript:TellAFriend();', 'web_de/inc/tella_w.gif', 'Diese Seite weiterempfehlen', 50, 600);
// News
AddMenuitem('newest', 'news', 'web_de/news/default.htm', 'web_de/inc/newest_w.gif', 'Aktuelles', 132, 35);
AddMenuitem('oldnews', 'news', 'web_de/news/archive.htm', 'web_de/inc/archive_w.gif', 'Archiv', 132, 143);
// products
AddMenuitem('overview', 'products', 'web_de/products/default.htm', 'web_de/inc/overview_w.gif', 'Übersicht GCL Technik', 132, 35);
AddMenuitem('gclrun', 'products', 'web_de/products/gclrun/default.htm', 'web_de/inc/gclrun_w.gif', 'GCLRun Runtime', 132, 187);
AddMenuitem('vgcl', 'products', 'web_de/products/vgcl/default.htm', 'web_de/inc/vgcl_w.gif', 'Visual GCL Entwicklungsumgebung', 132, 235);
AddMenuitem('eccar', 'products', 'web_de/products/eccar/default.htm', 'web_de/inc/eccar_w.gif', 'e:c:car', 132, 298);
AddMenuitem('gclauto', 'products', 'web_de/products/automotive/default.htm', 'web_de/inc/automotive_w.gif', 'GCL Automotive', 132, 336);
AddMenuitem('gclreality', 'products', 'web_de/products/reality/default.htm', 'web_de/inc/reality_w.gif', 'GCLReality Realtime 3D Visualisierung', 132, 422);
AddMenuitem('gclvis', 'products', 'web_de/products/gclvis/default.htm', 'web_de/inc/vis_w.gif', 'GCLVis 3D Visualisierung', 132, 487);
AddMenuitem('gclbdb', 'products', 'web_de/products/gclbdb/default.htm', 'web_de/inc/gclbdb_w.gif', 'GCL Business Library', 132, 531);
AddMenuitem('gclpro', 'products', 'web_de/products/profiler/default.htm', 'web_de/inc/profiler_w.gif', 'GCL Profiler', 132, 645);
// samples
AddMenuitem('classic', 'samples', 'web_de/samples/classic.htm', 'web_de/inc/classic_w.gif', 'Klassische Konfiguration', 132, 35);
AddMenuitem('vis', 'samples', 'web_de/samples/vis.htm', 'web_de/inc/viscon_w.gif', 'Konfiguration mit Visualisierung', 132, 345);
AddMenuitem('service', 'samples', 'web_de/samples/service.htm', 'web_de/inc/policy_w.gif', 'Berater und Policies', 132, 440);
AddMenuitem('finder', 'samples', 'web_de/samples/finder.htm', 'web_de/inc/finder_w.gif', 'Finder', 132, 492);
// papers
AddMenuitem('faq', 'papers', 'web_de/ads/faqkonfigurator.htm', 'web_de/inc/faq_w.gif', 'Frequently Asked Questions', 132, 231);
AddMenuitem('chronik', 'papers', 'web_de/contact/history.htm', 'web_de/inc/chronik_w.gif', 'GCL Chronik', 132, 259);
AddMenuitem('prodpdf', 'papers', 'web_de/downloads/products.htm', 'web_de/inc/prodpdf_w.gif', 'Produktbeschreibungen', 132, 327);
AddMenuitem('white', 'papers', 'web_de/downloads/whitepapers.htm', 'web_de/inc/whitepapers_w.gif', 'Whitepapers', 132, 451);
AddMenuitem('links', 'papers', 'web_de/links/default.htm', 'web_de/inc/links_w.gif', 'Links', 132, 521);
//AddMenuitem('newsletter', 'papers', 'web_de/scripts/newsletter.asp', 'web_de/inc/newsletter_w.gif', 'Newsletter', 132, 485);
// mission
AddMenuitem('prototypen', 'mission', 'web_de/projects/prototypen.htm', 'web_de/inc/prototypen_w.gif', 'Prototypen', 132, 300);
AddMenuitem('consulting', 'mission', 'web_de/projects/consulting.htm', 'web_de/inc/consulting_w.gif', 'Unsere Unterstützung', 132, 358);
AddMenuitem('workflow', 'mission', 'web_de/projects/workflow.htm', 'web_de/inc/workflow_w.gif', 'Workflow Analyse [Best Practice]', 132, 469);
// Partner
// company
AddMenuitem('history', 'company', 'web_de/contact/default.htm', 'web_de/inc/history_w.gif', 'Fakten', 132, 0);
AddMenuitem('route', 'company', 'web_de/contact/route.htm', 'web_de/inc/route_w.gif', 'Anfahrt und Adresse', 132, 476);
AddMenuitem('jobs', 'company', 'web_de/contact/jobs.htm', 'web_de/inc/jobs_w.gif', 'Jobs', 132, 520);
AddMenuitem('ref', 'company', 'web_de/contact/ref.htm', 'web_de/inc/customers_w.gif', 'Referenzen', 132, 550);
// ----------------------------------------------
// Menühilfsfunktionen
// ----------------------------------------------
function AddMenuitem(id, strParent, strUrl, strImg, strAlt, top, left)
{
   if (strUrl == null || strUrl.length == 0)
      menu[menu.length] = new Menuitem(id, strParent, null, strRoot+strImg, strAlt, top+dy, left+dx);
   else if (strUrl.indexOf("javascript:") >= 0)
      menu[menu.length] = new Menuitem(id, strParent, strUrl, strRoot+strImg, strAlt, top+dy, left+dx);
   else
      menu[menu.length] = new Menuitem(id, strParent, strRoot+strUrl, strRoot+strImg, strAlt, top+dy, left+dx);
}
// -----------------------------
// menupunkt objekt konstruktor
function Menuitem(id, strParent, strUrl, strImg, strAlt, top, left)
{
   this.mid = id;
   this.parent = strParent;
   this.url = strUrl;
   this.img = strImg;
   this.imgr = strImg.replace('_w', '_r'); // active image
   this.alt = strAlt;
   this.top = top;
   this.left = left;
}
// ------------------------------------
// menüpunkt ausgeben
function drawitem (mnu)
{
   if (mnu.mid == null)
      return null;

   var imgname;
   var vis;
   if (active == mnu.mid || activeparent == mnu.mid)
      imgname = mnu.imgr;
   else
      imgname = mnu.img;
      
   if (active == mnu.parent || active == mnu.mid || mnu.parent == null || activeparent == mnu.parent)
      vis = showverb;
   else
      vis = hideverb;

   if ((ie) && ver >= 4)
   {
      document.write ('<div style="position:absolute;top:'+mnu.top+'px;left:'+mnu.left+'px;z-index:2;'+
                      'visibility:'+vis+'" id="'+mnu.mid+'" ONMOUSEOVER="Showmenu(this.id);">');
      if (mnu.url == null)
         document.write ('<a href="javascript:Showmenu(\''+mnu.mid+'\');"><img name="' + mnu.mid + 'i" src="'+imgname+
                         '" border="0" alt="'+mnu.alt+'"></a>');
      else
         document.write ('<a href="'+mnu.url+'"'+
                         '><img name="' + mnu.mid + 'i" src="'+imgname+'" border="0" alt="'+
                         mnu.alt+'"></a>');
      document.write ('</div>');
   }
   else if ((ns) && ver >=4 && ver < 5)
   {
      document.writeln ('<layer id="'+mnu.mid+'" z-index=2 top='+mnu.top+' left='+mnu.left+
                        ' visibility='+vis+' ONMOUSEOVER="Showmenu(this.id);">');
      if (mnu.url == null)
         document.writeln ('<a href="javascript:Showmenu(\''+mnu.mid+'\');"><img name="' + mnu.mid + 'i" src="'+imgname+'" border="0" alt="'+mnu.alt+'"></a>');
      else
         document.writeln ('<a href="'+mnu.url+'"><img name="' + mnu.mid + 'i" src="'+imgname+'" border="0" alt="'+mnu.alt+'"></a>');
      document.writeln ('</layer>');
   }
   else if (dom) // netscape 6 and gecko render engine
   {
      document.write ('<div style="position:absolute;top:'+mnu.top+'px;left:'+mnu.left+'px;z-index:2');
      document.write(';visibility:'+vis);
      document.write ('" id="'+mnu.mid+'" ONMOUSEOVER="Showmenu(this.id);">');
      if (mnu.url == null)
         document.write ('<a href="'+'javascript:Showmenu(\''+mnu.mid+'\');'+'"><img name="' + mnu.mid + 'i" src="'+imgname+'" border="0" alt="'+mnu.alt+'"></a>');
      else
         document.write ('<a href="'+mnu.url+'"><img name="' + mnu.mid + 'i" src="'+imgname+'" border="0" alt="'+mnu.alt+'"></a>');
      document.write ('</div>');
   }
   return null;
}
// -------------------------------
// Menüpunkt DIV nach ID suchen
function GetItem(name)
{
   if (name == null)
      return null;
   if (ie)
      return document.all[name];
   else if (ns)
      return document.layers[name];
   else if (dom)
      return document.getElementById(name);
   return null;
}
// -------------------------------
// Menüpunkt nach ID suchen
function GetMnuItem(name)
{
   for (i=0;i<menu.length;i++)
   {
//    match?
      if (menu[i].mid == name)
         return menu[i];
   }
   return null;
}
// ---------------------------------------
// Style eines DIV suchen um Sichtbarkeit zu ändern
function GetStyle(name)
{
   if (name == null || name.length == 0)
      return null;
   if (ie)
      return document.all[name].style;
   else if (ns)
      return document.layers[name];
   else if (dom)
      return document.getElementById(name).style;
   else
      return null;
}
// -------------------------------------------
// Menügif von aktiv nach inaktiv umschalten
function SetImgState(name,activeFlag)
{
   if (document.images) 
   {
      var m = GetMnuItem(name);
      if (m != null)
      {
         if (activeFlag == true)
	         document[name+'i'].src = m.imgr;
	      else
	         document[name+'i'].src = m.img;
	   }
   }
}
// -------------------------------------------
// Menüpunkt und/oder Untermenüpunkte anzeigen
function Showmenu (name)
{
// if name isnt valid or active menu is the same as last one do nothing
   if (name == null || name.length == 0 || active == name)
      return;

   var parent = Getparent(name);
   if ((Getparent(active) == null && Getparent(name) == null) || (Getparent(active) != Getparent(name) && Getparent(name) != active))
      Hideoldmenu (active);
   SetImgState (active,false);
   SetImgState (name,true);
   active = name;
   for (i=0;i<menu.length;i++)
   {
//    show new submenu
      if (menu[i].parent == active && active != null)
      {
         entry=GetItem(menu[i].mid);
         if (entry != null)
            GetStyle(menu[i].mid).visibility=showverb;
      }
   }
// highlight parent too
   SetImgState (parent,true);
   return;
}
// -------------------------------------------
// Menüpunkt und/oder Untermenüpunkte verstecken
function Hideoldmenu (name)
{
   if (name == null || name.length == 0)
      return;
// get root item to hide
   var strHide = name;
   var parent = null;
   if (Getparent(name) != null)
      strHide = Getparent(name);
// walk all menus
   for (i=0;i<menu.length;i++)
   {
//    if menu has no parent dont hide == topmenu
      if (menu[i].parent != null)
      {
//       hide submenus of given menu item
         if (menu[i].parent == strHide)
         {
            entry = GetItem(menu[i].mid);
            if (entry != null)
               GetStyle(menu[i].mid).visibility=hideverb;
         }
      }
   }
// dim parent too
   var parent = Getparent(name);
   SetImgState (parent,false);
   return;
}
// -------------------------------------------
// Elternmenüpunkt eines Menüpunktes finden
function Getparent (name)
{
   if (name == null || name.length == 0)
      return null;
// walk all menus
   for (i=0;i<menu.length;i++)
   {
//    do names match?
      if (menu[i].mid == name)
         return menu[i].parent;
   }
   return null;
}
// -------------------------------------------
// Preload Hilfefunktion
function NewImage(strname)
{
   var img = null;
   img = new Image();
   img.src = strname;
   return img;
}
// -------------------------------------------
// preload images
function Init() // preload images
{
   var nLen = menu.length;
   for (i=0;i<nLen;i++)
   {
      imgs[imgs.length] = NewImage(menu[i].img);
      imgs[imgs.length] = NewImage(menu[i].imgr);
   }
   prel = true;
}
function TellAFriend()
{
   var par = window.parent
   var url;
   if (par != null)
   {
      url=par.document.location.toString();
      for (i=0;i<par.frames.length;i++)
      {
         var child = par.frames[i];
         url += "!" + child.name + "=" + child.document.location.toString();
      }
   }
   else
   {
      url=window.document.location.toString();
   }
   window.open(strRoot+'web_de/scripts/tellafriend.asp'+'?loc='+url, '_blank', 'width=400,height=300,menubar=no,status=no');
}
// --------- MAIN LOOP ----------------
// make menu
var nLen = menu.length;
for (i=0;i<nLen;i++)
{
   drawitem (menu[i]);
}
