
///////////////////////////////////////////////////////menu


var menuTimeout = 400

var menuSections = new Array()
var menuCountHide = new Array()
var menuSections2 = new Array()
var menuCountHide2 = new Array()

var menuSectionCnt = 0
var menuBoxCnt = 0

var menuSectionCnt2 = 0
var menuBoxCnt2 = 0

function menuShow(section, elements) {
    for (var i = 0; i < menuSections.length; i++) {
        if (menuSections[i] != section) {
            menuHide(menuSections[i], menuCountNodes(menuSections[i]))
        }
    }
    for (var i = 1; i <= elements; i++) {
        document.getElementById(section + '-' + i).style.visibility = 'visible'
    }
}

function menuHide(section, elements) {
    for (var i = 1; i <= elements; i++) {
        document.getElementById(section + '-' + i).style.visibility = 'hidden'
        document.getElementById(section).style.zIndex = -1
    }
}

function menuTryHide(section, elements, countHide) {
    if (countHide != menuCountHide[section]) {
        return
    }
    menuHide(section, elements)
}

function menuCountNodes(element) {
    ret = 0
    nodes = document.getElementById(element).childNodes.length
    for (var i = 0; i < nodes; i++) {
        if (document.getElementById(element).childNodes[i].nodeType == 1) {
            ret++
        }
    }
    return ret
}

function menuInitSection(section) {
    var elements = menuCountNodes(section)
    for (var i = 0; i <= elements; i++) {
        var s = (i == 0 ? (section + '-top') : (section + '-' + i))
        if (i == 0) {
            document.getElementById(s).onmouseover = function() {
                menuShow(section, elements)
                menuCountHide[section]++
                for (var ii = 0; ii < menuSections.length; ii++) {
                    document.getElementById(section).style.zIndex = 1
                    if (menuSections[ii] != section) {
                        document.getElementById(menuSections[ii]).style.zIndex = -1
                    }
                }
            }
        } else {
            document.getElementById(s).onmouseover = function() {
                menuShow(section, elements)
                menuCountHide[section]++
            }
        }
        document.getElementById(s).onmouseout = function() {
            setTimeout("menuTryHide('" + section + "', " + elements + ", " + menuCountHide[section] + ")", menuTimeout)
        }
    }
}

function menuMakeId(nodes) {
    for (var i = 0; i < nodes.length; i++) {
        switch (nodes[i].className) {
            case 'top':
                menuSectionCnt++
                menuBoxCnt = 0
                nodes[i].id = 'menu-' + menuSectionCnt + '-top'
                break
            case 'section':
                nodes[i].id = 'menu-' + menuSectionCnt
                menuSections[menuSections.length] = nodes[i].id
                break
            case 'box':
                menuBoxCnt++
                nodes[i].id = 'menu-' + menuSectionCnt + '-' + menuBoxCnt
                break
        }
        if (nodes[i].childNodes) {
            menuMakeId(nodes[i].childNodes)
        }
    }
}
//******************************
function menuInit() {
    menuMakeId(document.getElementById('menu').childNodes)
    for (var i = 0; i < menuSections.length; i++) {
        menuCountHide[menuSections[i]] = 0
    }
    for (var i = 0; i < menuSections.length; i++) {
        menuInitSection(menuSections[i])
    }
	
    menuMakeId2(document.getElementById('men2u').childNodes)
    for (var i = 0; i < menuSections2.length; i++) {
        menuCountHide2[menuSections2[i]] = 0
    }
    for (var i = 0; i < menuSections2.length; i++) {
        menuInitSection2(menuSections2[i])
    }

}
//*********************************


function menuShow2(section, elements) {
    for (var i = 0; i < menuSections2.length; i++) {
        if (menuSections2[i] != section) {
            menuHide2(menuSections2[i], menuCountNodes2(menuSections2[i]))
        }
    }
    for (var i = 1; i <= elements; i++) {
        document.getElementById(section + '-' + i).style.visibility = 'visible'
    }
}

function menuHide2(section, elements) {
    for (var i = 1; i <= elements; i++) {
        document.getElementById(section + '-' + i).style.visibility = 'hidden'
        document.getElementById(section).style.zIndex = -1
    }
}

function menuTryHide2(section, elements, countHide) {
    if (countHide != menuCountHide2[section]) {
        return
    }
    menuHide2(section, elements)
}

function menuCountNodes2(element) {
    ret = 0
    nodes = document.getElementById(element).childNodes.length
    for (var i = 0; i < nodes; i++) {
        if (document.getElementById(element).childNodes[i].nodeType == 1) {
            ret++
        }
    }
    return ret
}

function menuInitSection2(section) {
    var elements = menuCountNodes2(section)
    for (var i = 0; i <= elements; i++) {
        var s = (i == 0 ? (section + '-top') : (section + '-' + i))
        if (i == 0) {
            document.getElementById(s).onmouseover = function() {
                menuShow2(section, elements)
                menuCountHide2[section]++
                for (var ii = 0; ii < menuSections2.length; ii++) {
                    document.getElementById(section).style.zIndex = 1
                    if (menuSections2[ii] != section) {
                        document.getElementById(menuSections2[ii]).style.zIndex = -1
                    }
                }
            }
        } else {
            document.getElementById(s).onmouseover = function() {
                menuShow2(section, elements)
                menuCountHide2[section]++
            }
        }
        document.getElementById(s).onmouseout = function() {
            setTimeout("menuTryHide2('" + section + "', " + elements + ", " + menuCountHide2[section] + ")", menuTimeout)
        }
    }
}

function menuMakeId2(nodes) {
    for (var i = 0; i < nodes.length; i++) {
        switch (nodes[i].className) {
            case 'top':
                menuSectionCnt2++
                menuBoxCnt2 = 0
                nodes[i].id = 'men2u-' + menuSectionCnt2 + '-top'
                break
            case 'section':
                nodes[i].id = 'men2u-' + menuSectionCnt2
                menuSections2[menuSections2.length] = nodes[i].id
                break
            case 'box':
                menuBoxCnt2++
                nodes[i].id = 'men2u-' + menuSectionCnt2 + '-' + menuBoxCnt2
                break
        }
        if (nodes[i].childNodes) {
            menuMakeId2(nodes[i].childNodes)
        }
    }
}




////// menuuuuuuuuuuuu











function pokaz(html,x,y,sb)
{
    config='toolbar=no,location=no,directories=no,status=no,menubar=no,width='+x+',height='+y+',scrollbars='+sb+',top=0,left=0,screenX=0,screenY=0';
    id = window.open (html,'',config);
    id.focus();
}

function pokaz_foto_domku(x,y,nazwa,link)
{
    config='toolbar=no,location=no,directories=no,status=no,menubar=no,width='+x+',height='+y+',top=100,left=100,screenX=0,screenY=0';

    nazw = window.open ('','',config);

    nazw.document.write('<title>'+nazwa+'</title>');
    nazw.document.write('<body style="margin:0">');
    nazw.document.write('<IMG SRC="'+link+'">');
    nazw.document.write('</body>');
    nazw.document.close();
    nazw.focus();
}

function showDetails(x,y,nazwa,link)
{
    config='toolbar=no,location=no,directories=no,status=no,menubar=no,width='+x+',height='+y+',top=100,left=100,screenX=0,screenY=0';

    config='toolbar=no,location=no,directories=no,status=no,menubar=no,width='+x+',height='+y+',scrollbars=yes,top=100,left=100,screenX=0,screenY=0';
    okno = window.open (link,nazwa,config);
    okno.focus();
}
 
function okno(link)
{
//    config='toolbar=no,location=no,directories=no,status=no,menubar=no,width=640,height=480,top=100,left=100,screenX=0,screenY=0';

    var dir = location.href.substring(0,location.href.lastIndexOf('/'));
    var dir2 = dir.substring(0,dir.lastIndexOf('/')+1);

    var address=dir2+link;

    config='toolbar=no,location=no,directories=no,status=no,menubar=no,width=640,height=480,scrollbars=yes,top=100,left=100,screenX=0,screenY=0';

    var my_window = window.open (address,"mywindow", config);
    my_window.focus();
}

function pokaz_foto(x,y,link)
{
    config='toolbar=no,location=no,directories=no,status=no,menubar=no,width='+x+',height='+y+',top=100,left=100,screenX=0,screenY=0';

    nazw = window.open ('','',config);

    nazw.document.write('<html><head><title>foto</title></head>');
    nazw.document.write('<body style="margin:0">');
    nazw.document.write('<IMG SRC="'+link+'">');
    nazw.document.write('</body>');
    nazw.document.write('</html>');
    nazw.document.close();
    nazw.focus();
}

function getImageWidth(myImage) {
    var x, obj;
    if (document.layers) {
        var img = getImage(myImage);
        return img.width;
    } else {
        return getElementWidth(myImage);
    }
    return -1;
}

function getImageHeight(myImage) {
    var y, obj;
    if (document.layers) {
        var img = getImage(myImage);
        return img.height;
    } else {
        return getElementHeight(myImage);
    }
    return -1;
}



function pokaz_foto2(link)
{
	
    var x=300;
    var y=300;
    var config='toolbar=no,location=no,directories=no,status=no,menubar=no,width='+x+',height='+y+',top=30,left=100,screenX=100,screenY=100';

		
    var okno = window.open ('', '', config);
 
    okno.document.open()
    okno.document.write('<html><head><title>foto</title></head>');
    okno.document.write('<body style="margin:0">');
    okno.document.write('<IMG id="foto"  SRC="'+link+'"/>');
    okno.document.write('</body>');
    okno.document.write('</html>');
 
    okno.document.close();

    function getWidthAndHeight() {
        okno.resizeTo((this.width)+7, (this.height)+60);
        
        return true;
    }
    function loadFailure() {
        return true;
    }

    var myImage = new Image();
    myImage.name = okno.document.getElementById('foto').src;
    myImage.onload = getWidthAndHeight;
    myImage.onerror = loadFailure;
    myImage.src = okno.document.getElementById('foto').src;

    okno.focus();


}

function pokaz_przyklad(nazwa,id)
{
    config='toolbar=no,location=no,directories=no,status=no,scrollbars=yes,menubar=no,width=500,height=200';
    id = window.open (nazwa,id,config);
    id.focus();
}






function etykietka(imie,nazwisko,ulica,nrd,nrl,kod,miasto,id)
{
    config='toolbar=no,location=no,directories=no,status=no,menubar=yes,width=200,height=100';

		
    if(typeof win != "undefined")win.close();

    var ds = window.open('','win',config);

		

    ds.document.clear();

    ds.document.write('<title>'+id+'</title>');
    ds.document.write('<body style="margin:0" ><BR>');
    ds.document.write(''+imie+' '+nazwisko+'<BR>');

    if(nrl=='')
    {

        x = ''+ulica+' '+nrd+'<BR>';
			
    }
    else
    {
        x = ''+ulica+' '+nrd+' lokal '+nrl+'<BR>';
			
    }

		

    ds.document.write(x);
    ds.document.write(''+kod+' '+miasto+'<BR>');
    ds.document.write('<A HREF="javascript:close()">zamknij</A><BR>');
    ds.document.write('</body>');
    ds.focus();
    ds.document.close();


}

function pokaz_zapytanie(user,html)
{
    var sw=window.screen.width;
    var sh=window.screen.height;

    config1='toolbar=no,location=no,directories=no,status=no,menubar=no,width=345,height='+(sh-100)+',scrollbars=yes,screenX=0,screenY=0,top=0,left=0';
		

    id1 = window.open ('zamowienie.php?link='+html+'&user='+user+'','zamowienie',config1);

    id1.focus();
		
}

function pokaz_kalkulacje(html)
{
    var sw=window.screen.width;
    var sh=window.screen.height;

    config1='toolbar=no,location=no,directories=no,status=no,menubar=no,width=345,height='+(sh-100)+',scrollbars=yes,screenX=0,screenY=0,top=0,left=0';
		

    id1 = window.open ('zamowienie.php?link='+html+'','zamowienie',config1);

    id1.focus();
		
}

function oblicz_kalkulacje(idk,idr,idm)
{

    var sw=window.screen.width;
    var sh=window.screen.height;

    config1='toolbar=no,location=no,directories=no,status=no,menubar=no,width=800,height='+(sh-100)+',scrollbars=yes,top=0,left=0';
		

    id1 = window.open ('kalkulacja_wstep.php?idk='+idk+'&idr='+idr+'&idm='+idm,'kalkulacja', config1);

    id1.focus();
		
}
function oblicz_kalkulacje(idk,idr,idm,idz)
{

    var sw=window.screen.width;
    var sh=window.screen.height;

    config1='toolbar=no,location=no,directories=no,status=no,menubar=no,width=800,height='+(sh-100)+',scrollbars=yes,top=0,left=0';


    id1 = window.open ('kalkulacja_wstep.php?idk='+idk+'&idr='+idr+'&idm='+idm+'&idz='+idz,'kalkulacja', config1);

    id1.focus();

}
 
function pokaz_rejestracje()
{
    var sw=window.screen.width;
    var sh=window.screen.height;

    config1='toolbar=no,location=no,directories=no,status=no,menubar=no,width=800,height='+(sh-100)+',scrollbars=yes,screenX=0,screenY=0,top=0,left=0';
		

    idrej = window.open ('user_konto.php?cmd=nowy&akcja=kalkulacja','rejesteracja',config1);

    idrej.focus();
		
}