// ******************************************************************
// ******************************************************************
//
//    Floating menu    Copyright ElmüSoft (www.netcult.ch/elmue)
//     This menu was tested on Internet Explorer 6, Netscape 8, 
//     Opera 9, Firefox 1.5, Safari
//
//    The following styles must be defined in a stylesheet:
//    .MenuHead     { color:#FFFFFF; font-family:Arial,Helvetica,Sans-serif; font-size:13px; font-weight:bold; }
//    .MenuContent  { color:#000000; font-family:Arial,Helvetica,Sans-serif; font-size:13px; }
//    .MenuBackgr   { background-color:#CCDDCC; }
//    .MenuBorder   { border:1px solid; border-color:#000000; }
//    .MenuLink     { color:#222222; }
//    .MenuLinkBig  { color:#331100; font-weight:bold; }
//
//    The following images are required:
//     menu-close.gif
//     menu-arrow-white.gif
//     menu-arrow-black.gif
//
// ******************************************************************
// ******************************************************************

gsHighlight   = "#CCFFCC"; // onMouseOver highlight color
arOpenMenus   = new Array();
gsCurMenu     = "";
gbContentOpen = false;
gbFloatOpen   = false;
gScrollLast   = -1;
gMouseX       = 0;
gMouseY       = 0;
gOverMenu     = "";
gOverSubMenu  = "";
gSite         = "gruppen.greenpeace.de/aachen";

// ############### FLOATING MENU ##############

PrintMenuStart("FloatingMenu");

PrintFloatingMenu("Navigations Men&uuml;", "MenuMain");

PrintMenuEnd();

// ############### MAIN MENU ##############

PrintMenuStart("MenuMain");

PrintHeaderWithCloseButton("Themen");
PrintMenuEntry("Wald / Papier",                       "wald-index.html",       "MenuUrwald",    true);
PrintMenuEntry("Meere",                               "meere.html",            "MenuMeere",     true);
PrintMenuEntry("Energie",                             "energie-index.html",    "MenuEnergie",   true);
PrintMenuEntry("Gentechnik",                          "gentechnik.html",       "",              true);
PrintMenuEntry("Pestizide in Lebensmitteln",          "http://www.greenpeace-aachen.de/archiv/pestizide.php",     "",              true);
PrintMenuEntry("Klima Erw&auml;rmung",                "klima-erwaermung.html", "",              true);
PrintMenuEntry("Dieselru&szlig;",                     "http://www.greenpeace-aachen.de/archiv/dieselruss.php",       "",              true);
PrintMenuEntry("&Ouml;kologisches Bauen",             "http://www.greenpeace-aachen.de/archiv/bauen.php");
PrintMenuEntry("Thermografie",                        "http://www.greenpeace-aachen.de/archiv/thermografie.php");
PrintMenuEntry("Chemie / Gifte",                      "http://www.greenpeace-aachen.de/archiv/chemie.php");
PrintMenuEntry("Verkehr",                             "http://www.greenpeace-aachen.de/archiv/verkehr.php");
PrintMenuEntry("Rede von H&auml;uptling Seattle",     "indianer.html");
PrintMenuEntry("Kommentierte Linksammlung",           "http://www.greenpeace-aachen.de/links/links.php");
PrintMenuEntry("Startseite",                          "http://www.greenpeace-aachen.de/");

PrintHeader("Greenpeace Aachen");
PrintMenuEntry("Greenteams",                  "http://www.greenpeace-aachen.de/gruppe/greenteam.php",       "", true);
PrintMenuEntry("Jugendgruppe",                "jag.html",             "", true);
PrintMenuEntry("Team 50+",                    "http://www.greenpeace-aachen.de/gruppe/tfp.php",          "", true);
PrintMenuEntry("Einkaufsf&uuml;hrer Aachen",  "http://www.greenpeace-aachen.de/einkaufsfuehrer/einkaufsfuehrer.php", "", true);
PrintMenuEntry("Aktionen in Aachen",          "http://www.greenpeace-aachen.de/aktionen");
PrintMenuEntry("Kontakt / Impressum",         "http://www.greenpeace-aachen.de/gruppe/kontakt.php");
PrintMenuEntry("Email / Spenden / Newsletter","gast.html");

PrintHeader("Suche");
PrintGoogleSuche();

PrintMenuEnd();

// ############### URWALD MENU ##############

PrintMenuStart("MenuUrwald");

PrintHeader("Urw&auml;lder");
PrintMenuEntry("Tropische Urw&auml;lder",       "urwald.html",          "", true);
PrintMenuEntry("Nordische Urw&auml;lder",       "wald.html",            "", true);

PrintHeader("Papier");
PrintMenuEntry("Recycling Papier",              "recyclingpapier.html", "", true);
PrintMenuEntry("Unerw&uuml;nschte Werbung",     "werbung.html");

PrintHeader("Aachen");
PrintMenuEntry("Ausgustinerwald",               "aachenerwald.html");
PrintMenuEntry("Fotowettbewerb Ausgustinerwald","augustinerwald.html");

PrintHeader("Fotosammlung");
PrintMenuEntry("W&auml;lder Fotos",             "wald-index.html",      "MenuWaldFotos");

PrintMenuEnd();

// ############### WALD FOTOS MENU ##############

PrintMenuStart("MenuWaldFotos");

PrintHeader("Fotos Nordische Urw&auml;lder");
PrintMenuEntry("Kanadische Urw&auml;lder",          "wald-fotos-kanada-urwaelder.html");
PrintMenuEntry("Kahlschl&auml;ge und GP Aktionen",  "wald-fotos-rodung-kanada.html");

PrintHeader("Fotos Amazonas Urw&auml;lder");
PrintMenuEntry("Amazonas Urw&auml;lder",            "wald-fotos-amazonas.html");
PrintMenuEntry("Indianer",                          "wald-fotos-indianer.html");
PrintMenuEntry("Zerst&ouml;rung",                   "wald-fotos-zerstoerung.html");

PrintHeader("Fotos Deutsche W&auml;lder");
PrintMenuEntry("Waldsterben",                       "wald-fotos-waldsterben.html");
PrintMenuEntry("&Ouml;kologische Waldnutzung / FSC","wald-fotos-oekologische-nutzung.html");

PrintMenuEnd();

// ############### MEERE MENU ##############

PrintMenuStart("MenuMeere");

PrintHeader("Meere");
PrintMenuEntry("Fischerei",               "fischerei.html",  "", true);
PrintMenuEntry("Walfang",                 "walfang.html",    "", true);
PrintMenuEntry("&Ouml;ltanker Havarien",  "oeltanker.html",  "", true);

PrintHeader("Fotosammlung");
PrintMenuEntry("Meere Fotos",                         "meere.html",            "MenuMeereFotos");
PrintMenuEnd();

// ############### MEERE FOTOS MENU ##############

PrintMenuStart("MenuMeereFotos");

PrintHeader("Fotos Robben");
PrintMenuEntry("Robben",                  "meere-fotos-robben.html");

PrintHeader("Fotos Wale und Delfine");
PrintMenuEntry("Bartenwale",              "meere-fotos-bartenwale.html");
PrintMenuEntry("Zahnwale",                "meere-fotos-zahnwale.html");
PrintMenuEntry("Walfang",                 "meere-fotos-walfang.html");
PrintMenuEntry("Definfang",               "meere-fotos-delphinfang.html");
PrintMenuEntry("Alternativen",            "meere-fotos-alternativen.html");

PrintHeader("Fotos Fischerei");
PrintMenuEntry("Treibnetze / Langleinen", "meere-fotos-treibnetz.html");

PrintHeader("Fotos Verschmutzung");
PrintMenuEntry("Meeresverschmutzung",     "meere-fotos-verschmutzung.html");

PrintMenuEnd();

// ############### ENERGIE MENU ##############

PrintMenuStart("MenuEnergie");

PrintHeader("Energie");
PrintMenuEntry("Atomenergie",                     "atomenergie.html",               "", true);
PrintMenuEntry("&Ouml;l Ecuador",                 "westlb.html");
PrintMenuEntry("&Ouml;l Ru&szlig;land",           "oel.html");
PrintMenuEntry("&Ouml;l Esso / Exxon",            "oel-esso.html");

PrintHeader("Alternativen");
PrintMenuEntry("&Ouml;kostrom Anbieter",          "http://www.greenpeace-aachen.de/energie/oekostrom.php", "", true);
PrintMenuEntry("Energiespartipps",                "energiespartipps.html",          "", true);
PrintMenuEntry("Thermografie",                    "constr-thermo.html");

PrintHeader("Aachen");
PrintMenuEntry("Stawag, E.On, &Ouml;kosteuer...", "energie2.html",                  "", true);
PrintMenuEntry("Karlspreis 2003",                 "karlspreis.html");

PrintHeader("Spiegel");
PrintMenuEntry("Zerrbild der Windenergie",        "energie-spiegel-wahn.html");
PrintMenuEntry("Machtkampf um den Energiemix",    "energie-harald-schumann.html");

PrintMenuEnd();



// ############### FUNCTIONS ##############

function ShowMenu(sMenuName)
{
    if (!sMenuName.length)
        return;

    sLastMenu = "";
    if (arOpenMenus.length)
    {
        sLastMenu = arOpenMenus.pop();
        arOpenMenus.push(sLastMenu);
    }

    Menu   = document.getElementById(sMenuName);
    Parent = document.getElementById(sLastMenu);

    PosX   = 0;
    PosY   = document.body.scrollTop;
    if (arOpenMenus.length >= 2)
    {
        PosY = Math.max(PosY, gMouseY -5);
    }

    if (Parent)
    {
        Lleft  = Parent.style.left;
        P      = Lleft.indexOf("p"); // cut off "px"
        if (P>0) Lleft = Lleft.substr(0, P);
        PosX   = Math.max(0, Lleft) + Parent.offsetWidth -1;
    }

    if (Menu && Menu.style.visibility != "visible")
    {
        Menu.style.left = PosX;
        Menu.style.top  = PosY;
        Menu.style.visibility = "visible";

        arOpenMenus.push(sMenuName);
    }
}

function CloseMenu(sMenuName)
{
    while (arOpenMenus.length)
    {
        sMenu = arOpenMenus.pop();
        document.getElementById(sMenu).style.visibility = "hidden";

        if (sMenu == sMenuName)
            return;
    }
}

function CloseSubMenus(sMenuName)
{
	if (!sMenuName.length)
		return;
	
    while (arOpenMenus.length)
    {
        sMenu = arOpenMenus.pop();

        if (sMenu == sMenuName)
        {
            arOpenMenus.push(sMenu);
            return;
        }

        document.getElementById(sMenu).style.visibility = "hidden";
    }
}

function PrintMenuStart(sMenuName)
{
    document.write("<div id='" + sMenuName + "' style='position:absolute; z-index:1; left: 0px; top: 0px; visibility: hidden;'>");
    document.write("<table cellspacing=2 cellpadding=0 bordercolor=#003300 bgcolor=#006600 class='MenuBorder'>");
    gsCurMenu = sMenuName;
}

function PrintMenuEnd()
{
    if (gbContentOpen)
    {
        gbContentOpen = false;
        document.write("</td></tr>");
    }
    document.write("</table>");
    document.write("</div>");
    gsCurMenu = "";
}

function PrintHeader(Text)
{
    if (gbContentOpen)
    {
        gbContentOpen = false;
        document.write("</td></tr>");
    }

    document.write("<tr>");
    document.write("<td style='cursor:default' bgcolor=#006600 class=MenuHead>&nbsp;" + Text + "&nbsp;</td>");
    document.write("</tr>");
}

function PrintHeaderWithCloseButton(Text)
{
    if (gbContentOpen)
    {
        gbContentOpen = false;
        document.write("</td></tr>");
    }
    document.write("<tr><td>");

    document.write("<table cellspacing=0 cellpadding=0 width=100% class=MenuHead><tr>");
    document.write("<td style='cursor:default'>&nbsp;" + Text + "&nbsp;</td>");
    document.write("<td width=14><img src='menu-close.gif' alt='Men&uuml; schlie&szlig;en' width=14 height=14 onClick='CloseMenu(\""+gsCurMenu+"\")'></td>");
    document.write("</tr></table>");

    document.write("</td></tr>");
}

function PrintMenuEntry(Text, Link, SubMenu, bBig)
{
    if (!SubMenu) SubMenu = "";

    if (bBig) Text = "<span class=MenuLinkBig>&nbsp;"+Text+"&nbsp;</span>";
    else      Text = "<span class=MenuLink>&nbsp;"   +Text+"&nbsp;</span>";

    if (!gbContentOpen)
    {
        gbContentOpen = true;
        document.write("<tr><td class=MenuBackgr>");
    }

    sID = "";
    if (SubMenu.length) sID = "id='Item" +SubMenu+ "'";

    document.write("<table width=100% "+sID+" cellspacing=0 cellpadding=0 class=MenuContent onMouseover='OnMenuItemMouseOver(\""+gsCurMenu+"\", \""+SubMenu+"\", this)' onMouseout='OnMenuItemMouseOut(this)'><tr>");
    document.write("<td nowrap><a href='"+Link+"'>"+Text+"</a>&nbsp;</td>");
    if (SubMenu.length)
    document.write("<td width=10><img src='menu-arrow-black.gif' width=8 height=11></td>");
    document.write("</tr></table>");

}

function PrintGoogleSuche()
{
	document.write("<tr><td class=MenuBackgr>");
	document.write("<table cellspacing=0 cellpadding=2 onMouseOver='OnMenuItemMouseOver(\"MenuMain\")'><tr><td>");
	document.write("<Input  id='GoogleSrch' style='width:140px;' maxLength=256>");
	document.write("</td><td>");
	document.write("<Button id='GoogleBttn' style='width:32px; height:24px' onClick='SearchGoogle();'>");
	document.write("<img src='menu-search.gif' width=15 height=16>");
	document.write("</Button>");
	document.write("</td></tr></table>");
	document.write("</td></tr>");
}

function SearchGoogle()
{
	document.getElementById("GoogleBttn").blur();
	sQuery = document.getElementById("GoogleSrch").value;
	if (sQuery == "")
	{
		alert("Bitte ein Suchwort eingeben!");
		return;
	}
	document.location = "http://google.de/search?q="+sQuery+"+site:"+gSite+"&num=30";
}

function OnMenuItemMouseOver(sMenu, sSubMenu, iTable)
{
    gOverMenu    = sMenu;
    gOverSubMenu = sSubMenu;

    if (iTable) iTable.style.backgroundColor = gsHighlight;
    setTimeout("OnMenuItemMouseOverDelay()", 500);
}

function OnMenuItemMouseOverDelay()
{
    sLastMenu = arOpenMenus.pop();
    arOpenMenus.push(sLastMenu);

    if (gOverSubMenu == sLastMenu)
        return;

    CloseSubMenus(gOverMenu);
    ShowMenu     (gOverSubMenu);
}

function OnMenuItemMouseOut(iTable)
{
	gOverSubMenu = "";
	gOverMenu    = "";
    iTable.style.backgroundColor = "";
}

function PrintFloatingMenu(Text, SubMenu)
{
    document.write("<tr bgcolor=#006600 class=MenuHead>");
    document.write("<td nowrap><span style='cursor:default' onMouseover='ShowMenu(\""+SubMenu+"\")'>&nbsp;"+Text+"&nbsp;</span></td>");
    document.write("<td width=10 onMouseover='ShowMenu(\""+SubMenu+"\")'><img src='menu-arrow-white.gif' width=8 height=11></td>");
    document.write("</tr>");
}

function ScrollMenu()
{
    CurTop = document.body.scrollTop;
    if (gScrollLast != CurTop)
    {
        gScrollLast = CurTop;
        gbFloatOpen = false;
        CloseMenu("FloatingMenu");
    }
    else if (!gbFloatOpen)
    {
        gbFloatOpen = true;
        ShowMenu("FloatingMenu");
    }
}

setInterval("ScrollMenu()", 100);

function OnMouseMove(Ev)
{
    if (window.event) { gMouseX = event.x;  gMouseY = event.y + document.body.scrollTop; } // MSIE
    else if (Ev)      { gMouseX = Ev.pageX; gMouseY = Ev.pageY; } // Firefox
}

document.onmousemove= OnMouseMove;
