﻿/*
 * DO NOT REMOVE THIS NOTICE
 *
 * PROJECT:   MyGosuMenu
 * VERSION:   1.5.5
 * COPYRIGHT: (c) 2003-2009 Cezary Tomczak
 * LINK:      http://www.gosu.pl/MyGosuMenu/
 * LICENSE:   BSD revised (free for any use)
 */
 
 var barMenu0 ;
 var barMenu1 ; 
 var barMenu2 ; 

 
 var hmenu0   = [
 [ 2, "Startseite"       , "index.php" ],
 [ 1, "Über uns"         , "html/uber_uns.html" ],
 [ 1, "Firmengeschichte" , "html/firmengeschichte.html" ],
 [ 1, "Leitlinien"       , "html/leitlinien.html" ],
 [ 1, "Kompetenz"        , "html/kompetenz.html" ],
 [ 2, "Produkte"         , "html/produkte.html" ],
 [ 1, "Evolit Heizelement","html/evolit.html" ],
 [ 1, "Material"         , "html/material.html" ],
 [ 1, "AESA"             , "html/aesa.html" ],
 [ 1, "Gütesiegel"       , "html/evolit_gutesiegel.html" ],
 [ 1, "Elektroheizung"   , "html/elektroheizung.html" ],
 [ 1, "Kamine"           , "html/kamine.html" ],
 [ 1, "Zubehör"          , "html/zubehor.html" ],
 [ 1, "Ökoline"          , "html/okoline.html" ],
 [ 1, "Konformität"      , "html/konformitat.html" ],
 [ 1, "Einsatzgebiete"   , "html/einsatzgebiete.php" ],
 [ 2, "Infos"            , "html/infos.html" ],
 [ 1, "Vorteile"         , "html/vorteile.html" ],
 [ 1, "Sicherheit"       , "html/sicherheit.html" ],
 [ 1, "Umwelt"           , "html/umwelt.html" ],
 [ 1, "Wartung"          , "html/wartung.html" ],
 [ 1, "Funktion"         , "html/funktion.html" ],
 [ 1, "Günstiger Strom"  , "html/gunstiger_strom.html" ],
 [ 1, "Weberhaus"        , "html/das_weberhaus.html" ],
 [ 1, "Heizverhalten"    , "html/heizverhalten.html" ],
 [ 1, "Radiatoren"       , "html/flachenheizung_radiatoren.html" ],
 [ 1, "Faq Inhalt"       , "html/faq_inhalt.php" ],
 [ 1, "Faq details"      , "html/faq_details.php" ],
 [ 2, "Kontakte   "      , "html/formular.html" ],
 [ 1, "Wärmebedarf"      , "html/elektroheizung_warmebedarf.html" ],
 [ 1, "Info-Formular"    , "html/elektroheizung_info.html" ],
 [ 2, "Impressum"        , "html/impressum.html" ],
 [ 1, "AGB"              , "html/agb.html" ],
 [ 2, "Jobs"             , "html/jobs.html" ],
 [ 1, "Handelsvertreter" , "html/handelsvertreter.html" ],
 [ 1, "Monteure"         , "html/monteure.html" ],
 [ 2, "Bildergalerie"    , "html/bildergalerien.html" ],
 [ 1, "Katalog"          , "html/katalog.html" ],
 [ 1, "Technik"          , "html/technik.php" ],
 [ 1, "Zubehör"          , "html/zubehor1.html" ],
 [ 1, "Kamine"           , "html/kamine1.html" ],
 [ 1, "Produktion"       , "html/produktion.html" ],
 [ 1, "Verwaltung"       , "html/verwaltung.html" ],
 [ 1, "Elektroheizung"   , "html/elektroheizungen.html" ],
 [ 2, "Download"         , "html/download.html" ],
 [ 2, "Pressemitteilung" , "html/pressemitteilung.html" ],
 [ 1, "Medienberichte"   , "html/medienberichte.php" ],
 [ 2, "Sitemap"          , "html/sitemap.html" ]
 ];

var hmenu1   = [
 [ 0, "Top-Themen"       , "" ],
 [ 1, "Schnelle Wärme"   , "html/schnelle_warme.html" ],
 [ 1, "Energiesparend"   , "html/energiesparend.html" ],
 [ 1, "Umweltschonend"   , "html/umweltschonend.html" ],
 [ 1, "Gesunde Wärme"    , "html/strahlungswarme.html" ],
 [ 1, "Bequemes Heizen"  , "html/bequemes_heizen.html" ],
 [ 1, "Kostengünstig"    , "html/planung.html" ],
 [ 1, "weitere Vorteile" , "html/vorteile.html" ],
 [ 1, "Faq Inhalt"       , "html/faq_inhalt.php" ],
 [ 1, "Infos"            , "html/infos.html" ],
 [ 1, "Radiatoren"       , "html/flachenheizung_radiatoren.html" ]
 ];
 
var hmenu2   = [
 [ 0, "Top-Themen"       , "" ],
 [ 1, "Startseite"       , "index.php" ],
 [ 1, "Faq Inhalt"       , "html/faq_inhalt.php" ],
 [ 1, "Infos"            , "html/infos.html" ]
 ];
 
 var hmenu999   = [
 [ 2, "Startseite"       , "index.php" ]
 ];

function CreateMenu ( id, feld )
{
  var i,n  ;
  var mnu ;
  var titel ;
  var link ;
  
  var server = www_server ;
  var arrow1 = server + "include/arrow1.gif" ;
  var arrow2 = server + "include/arrow2.gif" ;
  var size1  = 'width="11" height="11"' ;
  var size2  = 'width="14" height="9"' ;
  
  mnu  = hmenu999 ;
  server = www_server ;
  //
  // für unterschiedliche menues
  if ( id == 0 ) mnu = hmenu0 ;
  if ( id == 1 ) mnu = hmenu1 ;
  if ( id == 2 ) mnu = hmenu2 ;
  

  // tabelle erzeugen
  document.write('<table cellspacing="0" cellpadding="0" id="'+feld+'" class="bar-menu">') ;

  // hauptmenueschleife
  for (i = 0; i < mnu.length; ++i)
  {
      titel = mnu[i][1] ;
      link  = server + mnu[i][2] ;
      n = mnu[i][0] ;
      if ( n == 0 ) // popup
      {
        if ( i > 0  ) // zwischenraum
        {
          document.write('</div>') ;
          document.write('</td></tr>' ) ;
          document.write('<tr><td height="2"></td></tr>' ) ;
        } 
        document.write('<tr><td>' ) ;
        document.write('<div class="box1">'+titel+'<img src="'+arrow1+'"'+size2+' alt="'+titel+'"></div>' ) ;
        document.write('<div class="section">') ;
      }
      else // item
      {
        if ( n == 2 ) // popup als einzelner link
        {
          if ( i > 0  ) // zwischenraum
          {
            document.write('</div>') ;
            document.write('</td></tr>' ) ;
            document.write('<tr><td height="2"></td></tr>' ) ;
          } 
          document.write('<tr><td>' ) ;
          document.write('<div class="box1">'+titel+'<img src="'+arrow1+'"'+size2+' alt=""></div>' ) ;
          document.write('<div class="section">') ;
          document.write('<div class="box2"><img src="'+arrow2+'"'+size2+'" alt="'+titel+'"><a href="'+link+'">'+titel+'</a></div>');
        }
        else
          document.write('<div class="box2"><img src="'+arrow2+'"'+size2+'" alt="'+titel+'"><a href="'+link+'">'+titel+'</a></div>');
      }
  }
  // ende hauptmenueschleife
  // tabelle ende
  document.write('</div>') ;
  document.write('</td></tr>' ) ;
  document.write('</table>' ) ;
  //
  // für unterschiedliche menus auf der seite
  
  if ( id == 0 ) {  barMenu0 = new BarMenu( feld );  barMenu0.init (); }
  if ( id == 1 ) {  barMenu1 = new BarMenu( feld );  barMenu1.init(); }
  if ( id == 2 ) {  barMenu2 = new BarMenu( feld );  barMenu2.init(); }
  
}

function BarMenu(id) {
    this.box1Hover = true;
    this.box2Hover = true;
    this.highlightActive = false;

    this.init = function() {
        if (!document.getElementById(this.id)) {
            alert("Element '"+this.id+"' does not exist in this document. BarMenu cannot be initialized");
            return;
        }
        this.parse(document.getElementById(this.id).childNodes, this.tree, this.id);
        this.load();
        if (window.attachEvent) {
            window.attachEvent("onunload", function(e) { self.save(); });
        } else if (window.addEventListener) {
            window.addEventListener("unload", function(e) { self.save(); }, false);
        }
    }

    this.parse = function(nodes, tree, id) {
        for (var i = 0; i < nodes.length; i++) {
            if (nodes[i].nodeType != 1) {
                continue;
            }
            if (nodes[i].className) {
                if ("box1" == nodes[i].className.substr(0, 4)) {
                    nodes[i].id = id + "-" + tree.length;
                    tree[tree.length] = new Array();
                    eval('nodes[i].onmouseover = function() { self.box1over("'+nodes[i].id+'"); }');
                    eval('nodes[i].onmouseout = function() { self.box1out("'+nodes[i].id+'"); }');
                    eval('nodes[i].onclick = function() { self.box1click("'+nodes[i].id+'"); }');
                }
                if ("section" == nodes[i].className) {
                    id = id + "-" + (tree.length - 1);
                    nodes[i].id = id + "-section";
                    tree = tree[tree.length - 1];
                }
                if ("box2" == nodes[i].className.substr(0, 4)) {
                    nodes[i].id = id + "-" + tree.length;
                    tree[tree.length] = new Array();
                    eval('nodes[i].onmouseover = function() { self.box2over("'+nodes[i].id+'", "'+nodes[i].className+'"); }');
                    eval('nodes[i].onmouseout = function() { self.box2out("'+nodes[i].id+'", "'+nodes[i].className+'"); }');
                }
            }
            if (this.highlightActive && nodes[i].tagName && nodes[i].tagName == "A") {
                if (document.location.href == nodes[i].href) {
                    nodes[i].className = (nodes[i].className ? ' active' : 'active')
                }
            }
            if (nodes[i].childNodes) {
                this.parse(nodes[i].childNodes, tree, id);
            }
        }
    }

    this.box1over = function(id) {
        if (!this.box1Hover) return;
        if (!document.getElementById(id)) return;
        document.getElementById(id).className = (this.id_openbox == id ? "box1-open-hover" : "box1-hover");
    }

    this.box1out = function(id) {
        if (!this.box1Hover) return;
        if (!document.getElementById(id)) return;
        document.getElementById(id).className = (this.id_openbox == id ? "box1-open" : "box1");
    }

    this.box1click = function(id) {
        if (!document.getElementById(id)) {
            return;
        }
        var id_openbox = this.id_openbox;
        if (this.id_openbox) {
            if (!document.getElementById(id + "-section")) {
                return;
            }
            this.hide();
            if (id_openbox == id) {
                if (this.box1hover) {
                    document.getElementById(id_openbox).className = "box1-hover";
                } else {
                    document.getElementById(id_openbox).className = "box1";
                }
            } else {
                document.getElementById(id_openbox).className = "box1";
            }
        }
        if (id_openbox != id) {
            this.show(id);
            var className = document.getElementById(id).className;
            if ("box1-hover" == className) {
                document.getElementById(id).className = "box1-open-hover";
            }
            if ("box1" == className) {
                document.getElementById(id).className = "box1-open";
            }
        }
    }

    this.box2over = function(id, className) {
        if (!this.box2Hover) return;
        if (!document.getElementById(id)) return;
        document.getElementById(id).className = className + "-hover";
    }

    this.box2out = function(id, className) {
        if (!this.box2Hover) return;
        if (!document.getElementById(id)) return;
        document.getElementById(id).className = className;
    }

    this.show = function(id) {
        if (document.getElementById(id + "-section")) {
            document.getElementById(id + "-section").style.display = "block";
            this.id_openbox = id;
        }
    }

    this.hide = function() {
        document.getElementById(this.id_openbox + "-section").style.display = "none";
        this.id_openbox = "";
    }

    this.save = function() {
        if (this.id_openbox) {
            this.cookie.set(this.id, this.id_openbox);
        } else {
            this.cookie.del(this.id);
        }
    }

    this.load = function() {
        var id_openbox = this.cookie.get(this.id);
        if (id_openbox) {
            this.show(id_openbox);
            document.getElementById(id_openbox).className = "box1-open";
        }
    }

    function Cookie() {
        this.get = function(name) {
            var cookies = document.cookie.split(";");
            for (var i = 0; i < cookies.length; i++) {
                var a = cookies[i].split("=");
                if (a.length == 2) {
                    a[0] = a[0].trim();
                    a[1] = a[1].trim();
                    if (a[0] == name) {
                        return unescape(a[1]);
                    }
                }
            }
            return "";
        }
        this.set = function(name, value) {
            document.cookie = name + "=" + escape(value);
        }
        this.del = function(name) {
            document.cookie = name + "=; expires=Thu, 01-Jan-70 00:00:01 GMT";
        }
    }

    var self = this;
    this.id = id;
    
    this.tree = new Array();
    this.cookie = new Cookie();
    
    this.id_openbox = "";
}

if (typeof String.prototype.trim == "undefined") {
    String.prototype.trim = function() {
        var s = this.replace(/^\s*/, "");
        return s.replace(/\s*$/, "");
    }
}



