var menu_obj = new Object();
var docFrag = document.createDocumentFragment();
//var strDomena = "marcin.osada.codivate.pl";
var strDomena = "osada.pl";

menu_obj["1"] = [
    ["Ranking aktywności", "http://"+strDomena+"/statystyki/ranking_aktywnosci.php"],
    ["Ranking fotek", "http://"+strDomena+"/statystyki/topten_fotki.php"],
    ["Ranking kont", "http://"+strDomena+"/statystyki/topten_konta.php"]
];

menu_obj["2"] = [
    ["Ostatnio Dodane", "http://"+strDomena+"/wiecej_zdjec.php"],
    ["Ranking Fotek", "http://"+strDomena+"/statystyki/topten_fotki.php"]
];

menu_obj["3"] = [
    ["Szukaj Konta", "http://"+strDomena+"/uzytkownicy.php"],
    ["Ranking Kont", "http://"+strDomena+"/statystyki/topten_konta.php"]
];

menu_obj["5"] = [
    ["Ultrastacja", "http://www.ultrastacja.pl"],
    ["Topstacja", "http://www.topstacja.pl"],
    ["Klubstacja", "http://www.klubstacja.pl"],
    ["Discostacja", "http://www.discostacja.pl"],
    ["Oglądaj ITV", "http://www.itv.net.pl/", true],
    ["Gry Online", "http://gry-online.osada.pl/"],
    ["Śmieszne Filmy", "http://smieszne-filmy.osada.pl/"]
];

menu_obj["6"] = [
	["Kontakt", "http://"+strDomena+"/kontakt.php"],
    ["Reklama", "http://"+strDomena+"/reklama.php"],
    ["Regulamin", "http://"+strDomena+"/rejestracja/regulamin.php"],
    ["Redakcja", "http://"+strDomena+"/redakcja.php"],
    ["Statystyki", "http://"+strDomena+"/statystyki/"],
    ["FAQ/Pomoc", "http://"+strDomena+"/faq.php"]
];

menu_obj["7"] = [
    ["Dane Podstawowe", "http://"+strDomena+"/panel/zmien_dane_podstawowe.php"],
    ["Prywatne Wiadomości", "http://"+strDomena+"/panel/pw.php"],
    ["Twoje Zdjęcia", "http://"+strDomena+"/panel/zdjecia.php"],
    ["Twoje Filmy", "http://"+strDomena+"/panel/pliki.php"],
    ["Miejsce Zamieszkania", "http://"+strDomena+"/panel/zmien_dane_miejscowosc.php"],
    ["Twój test", "http://"+strDomena+"/panel/testy.php"],
    ["Trzy Pytania", "http://"+strDomena+"/panel/trzy_pytania.php"],
    ["Dane Dodatkowe", "http://"+strDomena+"/panel/zmien_dane_dodatkowe.php"],
    ["Powiadomienie O Komentarzach", "http://"+strDomena+"/panel/zmien_dane_powiadomienia.php"],
    ["Komentarze Wystawione", "http://"+strDomena+"/panel/zmien_dane_komentarze.php"],
    ["Komunikatory", "http://"+strDomena+"/panel/zmien_dane_komunikatory.php"],
    ["Adresy WWW", "http://"+strDomena+"/panel/zmien_dane_www.php"],
    ["Twoje Inne Nicki", "http://"+strDomena+"/panel/zmien_dane_nicki.php"],
    ["Adres E-mail", "http://"+strDomena+"/panel/zmien_dane_email.php"],
    ["Hasło Do Profilu", "http://"+strDomena+"/panel/zmien_dane_haslo.php"]
];

menu_obj["8"] = [
    ["Weź udział", "http://"+strDomena+"/karaoke/index.html", true],
    ["Ranking", "http://"+strDomena+"/karaoke/rankingi.html", true]
];

menu_obj["9"] = [
    ["Osady Tematyczne", "http://"+strDomena+"/osady/"],
    ["Forum", "http://"+strDomena+"/forum/"]
];

function getElemPos(elemID){
    var offLeft = 165, offTop = 0;
    var offTrail = document.getElementById(elemID);

    while(offTrail){
        offLeft += offTrail.offsetLeft;
        offTop += offTrail.offsetTop;
        offTrail = offTrail.offsetParent;
    }

    return {
        left: offLeft,
        top: offTop
    };
}

function setup_menu(){
    for(m in menu_obj){
        var menuDiv = document.createElement("div");
   
        menuDiv.className = "menulist";
        menuDiv.style.top = (getElemPos("m" + m).top)+"px";
        menuDiv.style.left = (getElemPos("m" + m).left)+"px";
        menuDiv.id = "listm" + m;
        menuDiv.style.display = "none";
   
        for(a = 0; a < menu_obj[m].length; a ++){
            var menuLink = document.createElement("a");
   
            menuLink.href = menu_obj[m][a][1];
				if(menu_obj[m][a][2]==true)
				{
				menuLink.target = "_blank";
				}
            menuLink.appendChild(document.createTextNode(menu_obj[m][a][0]));
            menuDiv.appendChild(menuLink);
        }
   
        docFrag.appendChild(menuDiv);
    }
   
    document.body.appendChild(docFrag);
}


function menu_polozenie(id_obiektu){
obciete_id=id_obiektu.substr(1, 1);

var warstwa=document.getElementById("listm" + obciete_id);
if(warstwa)
{
        warstwa.style.top = (getElemPos(id_obiektu).top)+"px";
        warstwa.style.left = (getElemPos(id_obiektu).left)+"px";
}
}


function hideOthers(){
    var menuDivs = document.getElementsByTagName("div");

    for(d = 0; d < menuDivs.length; d ++){
        if(menuDivs.item(d).id.match(/^listm\d+/i)){
            if(arguments[0] && menuDivs.item(d).id == arguments[0]){
                continue;
            }
            menuDivs.item(d).style.display = "none";
        }
    }
}

function hide(obj) {
	if(obj && obj.id){
         if(document.getElementById("list" + obj.id)) {
         	var mList = document.getElementById("list" + obj.id);
            var mBar = document.getElementById(obj.id);
            mList.style.display = "none";
         }
    }
}

function showMenu(obj){
    if(obj && obj.id){
        if(document.getElementById("list" + obj.id)) {
		 	
            var mList = document.getElementById("list" + obj.id);
            var mBar = document.getElementById(obj.id);
				
				menu_polozenie(obj.id);

            hideOthers();

            mBar.style.cursor = "pointer";
            mList.style.display = "";
        }
        
    }
}

function podswietl_wlacz(obj)
{
obj.style.background='#d7d7da';
}

function podswietl_wylacz(obj)
{
obj.style.background='white';
}