/*
** Magic-Tours drop-down menu script
** (c) by Johanner Ernesti 2006
*/

// drop-down menus
var dropDownMenus = Array(),
    dropDownLinks = Array(),
    hideTimeout = false,
    currentCategory = "";


function createDropDownMenus(container_class, item_class)
    {
    function createMenu(category, link, items)
        {
        var m = document.createElement("div");
        m.className = container_class;
        m.setAttribute("id", "drop_" + category);
        m.category = category;
        m.onmouseover = interruptDropDownHiding;
        m.onmouseout = hideDropDownMenu;
        m.style.position = "absolute";
        m.style.display = "none";
        m.length = items.length;

        if(link != "")
            document.getElementById(category).link = link;

        for(var h1 = 0; h1 < items.length; h1++)
            {
            var item = items[h1];
            var i = document.createElement("div");
            i.className = item_class;
            i.onmouseover = dropDownItemStartHover;
            i.onmouseout = dropDownItemEndHover;
            i.onclick = dropDownMenuItemClick;
            if(item[0])
                id = item[0];
            else
                id = category + "/" + item[1];
            i.setAttribute("id", id);
            i.link = item[1];
            i.text = item[0];
            i.category = category;
            i.appendChild(document.createTextNode(item[0]));
            m.appendChild(i);

            if(link == "" && h1 == 0)
                document.getElementById(category).link = item[1];
            }

        document.getElementsByTagName("body")[0].appendChild(m);
        dropDownMenus.push(m);
        }

    function item(text, link, id)
        {
        return Array(text, link, id);
        }

    /*
      UTF-8

      ue : \xFC
      ae : \xE4
      oe : \xF6
      sz : \xDF
    */

     createMenu("navi_start", "home_start.php", Array());
//         Array(item("Stichwortverzeichnis", "fixme"),
//               item("Hilfe/Service", "http://www.h1.de")
//         ));

    createMenu("navi_lastminute", "", Array(item("Lastminute & more", "http://www.lmweb.de/scripts/lmplusi.dll?CFG=539&FORM=msk/family.htm")));

    createMenu("navi_pauschalreisen", "",
        Array(item("Katalogreisen", "http://www.lmweb.de/scripts/lmplusi.dll?CFG=539&FORM=msk/family.htm"),
              item("Fr\xFChbucherreisen", "http://www.lmweb.de/scripts/lmplusi.dll?CFG=539&FORM=msk/family.htm"),
              item("Selbst kombinieren", "http://www.myfti.de/home.jsp?benum=10488"),
              item("Familenreisen", "http://www.lmweb.de/scripts/lmplusi.dll?CFG=539&FORM=msk/family.htm"),
              item("Skireisen", "http://www.sysvier.de/Auto/lmweb.dll?CFG=539&FORM=msk/ski1.htm"),
              item("St\xE4dtereisen", "http://www.sysvier.de/Auto/lmweb.dll?CFG=539&FORM=msk/city1.htm"),
              item("Single-Urlaub", "http://www.lmweb.de/scripts/lmplusi.dll?CFG=539&FORM=msk/single.htm"),
              item("Sprachreisen", "http://www.lal.de/ibe/home.jsp?benum=1818")
        ));

    createMenu("navi_flug", "",
        Array(item("Charterfl\xFCge", "http://www.lmweb.de/scripts/lmplusi.dll?CFG=539&FORM=msk/7.htm"),
              item("Linienfl\xFCge", "http://b2c.fti.temyra.net/Autologin_globe.asp?Login=129922&Pwd=46535 "),
              item("fly & drive", "http://www.lmweb.de/scripts/lmplusi.dll?CFG=539&FORM=msk/fly-drive.htm")
        ));

    createMenu("navi_hotelsUndFewo", "",
        Array(item("Hotels weltweit", "http://www.lmweb.de/scripts/lmplusi.dll?CFG=539&FORM=msk/nh.htm"),
              item("Wellness", "http://www.sysvier.de/Auto/lmweb.dll?CFG=539&FORM=msk/wellness1.htm"),
              item("Ferienwohnungen", "nach.html"),
              item("Skiurlaub", "http://www.sysvier.de/Auto/lmweb.dll?CFG=539&FORM=msk/ski1.htm"),
              item("Fincas", "http://www.lmweb.de/scripts/lmplusi.dll?CFG=539&FORM=msk/finca.htm"),
              item("Camper", "http://www.fti-campermarkt.de/home.jsp?benum=847"),
              item("Freizeitparks", "http://www.sysvier.de/Auto/lmweb.dll?CFG=539&FORM=msk/park.htm")
        ));

    createMenu("navi_mietwagen", "",
        Array(item("Mietwagen", "http://www.sunnycars.com/mode/rentaldata.html?sid=bdd4fa7b0b6f43caa2911f0221142945&lid=deu"),
              item("fly & drive", "http://www.lmweb.de/scripts/lmplusi.dll?CFG=539&FORM=msk/fly-drive.htm")
        ));

    createMenu("navi_kreuzfahrten",  "", Array(item("Kreuzfahrten", "http://affiliate.aida.de/?media=6d9d6b4150650916be0252e1fa325988_19677_235234_101_0_1")));

    createMenu("navi_bueros", "",
        Array(item("Dinslaken (46537)", "offices/office_dinslaken_46537.html"),
              item("Mitarbeiter", "offices/employees.html")
        ));
    }


function getDropDownMenu(category)
    {
    for(var h1 = 0; h1 < dropDownMenus.length; h1++)
        {
        if(dropDownMenus[h1].category == category && dropDownMenus[h1].length > 0)
            return dropDownMenus[h1];
        }
    return false;
    }

function showDropDownMenu(category)
    {
    if(getDropDownMenu(category))
        {
        if(category == currentCategory)
            interruptDropDownHiding();
        p = getLeftBottom(category);
        s = getDropDownMenu(category).style;
        s.left = p.x + "px";
        s.top = p.y + "px";
        s.display = "block";
        currentCategory = category;

        for(var h1 = 0; h1 < dropDownMenus.length; h1++)
            {
            if(dropDownMenus[h1].category != category)
                reallyHideDropDownMenu(dropDownMenus[h1].category);
            }
        }
    }

function hideDropDownMenu(category)
    {
    if(this.category)
        category = this.category;
    if(getDropDownMenu(category))
        {
        if(hideTimeout)
            window.clearTimeout(hideTimeout);
        hideTimeout = window.setTimeout("reallyHideDropDownMenu('" + category + "')", 1);
        hidingInterrupted = false;
        }
    }

function reallyHideDropDownMenu(category)
    {
    var menu = getDropDownMenu(category);
    if(menu)
        menu.style.display = "none";
    }

function interruptDropDownHiding()
    {
    if(hideTimeout)
        {
        window.clearTimeout(hideTimeout);
        hideTimeout = false;
        }
    }


// returns the position of the left down corner of the element identified with id
function getLeftBottom(id)
    {
    var e = document.getElementById(id);

    var p = new Object();
    p.x = 0;
    p.y = 0;
    p.y += e.offsetHeight;

    while(e.offsetParent != null)
        {
        p.x += e.offsetLeft;
        p.y += e.offsetTop;
        e = e.offsetParent;
        }

    return p;
    }
