    var AxDebugDiv=null;
    var AxDebugMonitors=new Array();
    var AxDebugMonitorsIndex=0;

    function AxDebugInit() {
        AxDebugDiv=document.createElement('div');
        AxDebugDiv.style.position='absolute';
        AxDebugDiv.style.width='200px';
        AxDebugDiv.style.height='100px';
        AxDebugDiv.style.top='0px';
        AxDebugDiv.style.left='0px';
        AxDebugDiv.style.backgroundColor='red';
        AxDebugDiv.style.display='block';
        AxDebugDiv.innerHTML='AxDebug inited.';
        AxDebugDiv.id='AxDebugDiv';
        document.body.appendChild(AxDebugDiv);
        window.setInterval(AxDebugRefresh,500);
    }



    function AxDebugRefresh() {
        var Content='';
        for (i=0; i<AxDebugMonitorsIndex; i++) {
            Content+=AxDebugMonitors[i]+' = '+eval(AxDebugMonitors[i])+' ['+typeof(eval(AxDebugMonitors[i]))+']<br>';
        }
        AxDebugDiv.innerHTML=Content;
    }


    function AxDebugMonitorAdd(VarName) {
        AxDebugMonitors[AxDebugMonitorsIndex++]=VarName;
    }



function supportsOpacity( el ) {
    if ( el.style.opacity != undefined )
        return true;
    if( el.style.MozOpacity != undefined )
        return true;

    if ( el.style.filter != undefined )
        return true;
    return false;
}

function setOpacity( el, opaciLevel ) {

    if ( el.style.opacity != undefined ) {
        if (opaciLevel!=1) {
            el.style.opacity = opaciLevel;
        } else {
            el.style.opacity = 0.99;
        }
    } else if( el.style.MozOpacity != undefined ) {
        el.style.MozOpacity = opaciLevel;
    } else if ( el.style.filter != undefined ) {
        var oplvl = Math.round(opaciLevel*100);
        el.style.filter="alpha(opacity=" + oplvl + ")";
    }
}

function fadeIn( id, currentOpacity ) {
    var counterLimit = 6;
    var el = document.getElementById( id );
    if( !currentOpacity ) {
        currentOpacity = 1;
    }
    if( currentOpacity > counterLimit ) {
        return;
    }
    setOpacity( el, ( currentOpacity/counterLimit ) );
    currentOpacity++;
    var func = "fadeIn( '" + id + "', " + currentOpacity + ")";
    window.setTimeout( func, 30);
}

var OpenedMenusNumber=new Array();
var OpenedMenus=new Array();
var OpenedMenusClasses=new Array();
var OpenedMenusSourceObjects=new Array();
var ChildsNumber=new Array();
var DontHideThisMenu=null;
var DontHideThisSubMenu=null;

AxDebugMonitorAdd('DontHideThisSubMenu');

function SetMenuPosition(SourceObject,MenuObject,Offset) {

    element=SourceObject; x=0; y=0;
    while (element) {
        x += element.offsetLeft;
        y += element.offsetTop;
        element = element.offsetParent;
    }
    switch(Offset) {
        case 'offsetRight': x+=SourceObject.offsetWidth; break;
        case 'offsetLeft': x-=SourceObject.offsetWidth; break;
        case 'offsetBottom': y+=SourceObject.offsetHeight; break;
    }

    MenuObject.style.left=x+'px';
    MenuObject.style.top=y+'px';
}

function ShowMenuDiv(MenuObject,MenuID) {

    var ReturnVal=false;
    
    if (MenuObject.style.display!='block') { ReturnVal=true; }

    //menu.style.display='block';
    if( supportsOpacity(MenuObject)) {
        // first set 0% opacity to make it completely transparent
        setOpacity(MenuObject, 0);
        // when we set display = "block" it's still invisible
        MenuObject.style.display = "block";
        // call the function to gradually increase opacity
        fadeIn(MenuID);
    } else {
        // can't modify opacity, so just make it visible...
        MenuObject.style.display = "block";
    }
    
    return ReturnVal;
}

function ShowMainMenu(SourceObject,ClassNameOver,ClassNameOut,MainMenuID,Offset) {

    MenuObject=document.getElementById(MainMenuID);
    
    if (OpenedMenusNumber[MainMenuID]>0) { return; }

    SetMenuPosition(SourceObject,MenuObject,Offset);
    
    SourceObject.className=ClassNameOver;

    ShowMenuDiv(MenuObject,MainMenuID);


    OpenedMenusNumber[MainMenuID]=1;
    
    if(!OpenedMenus[MainMenuID] ) { OpenedMenus[MainMenuID]=new Array(); }
    OpenedMenus[MainMenuID][0]=MenuObject;

    OpenedMenusClasses[MainMenuID]=ClassNameOut;
    OpenedMenusSourceObjects[MainMenuID]=SourceObject;

}


function ShowSubMenu(SourceObject,ThisMenuID,SubMenuID,Offset,MainMenuID) {

    //forex special
    //document.getElementById('flashdiv').style.visibility='hidden';

    SubMenuObject=document.getElementById(SubMenuID);

    SetMenuPosition(SourceObject,SubMenuObject,Offset);
    
    if (ShowMenuDiv(SubMenuObject,SubMenuID)) {

        OpenedMenus[MainMenuID][OpenedMenusNumber[MainMenuID]]=SubMenuObject;
        OpenedMenusNumber[MainMenuID]++;
        if (!ChildsNumber[ThisMenuID]) { ChildsNumber[ThisMenuID]=0;}
        if (!ChildsNumber[SubMenuID]) { ChildsNumber[SubMenuID]=0;}
        ChildsNumber[ThisMenuID]++;
    }
}


function HideMainMenu(MainMenuID){

    DontHideThisMenu=null;
    menuTimeoutRes=window.setTimeout(function() { HideMainMenuNow(MainMenuID); }, 100);
    
}


function HideMainMenuNow(MainMenuID) {

    if (DontHideThisMenu==MainMenuID) { return; }
//document.body.style.background='green';

    //forex special
    //document.getElementById('flashdiv').style.visibility='visible';

    OpenedMenusSourceObjects[MainMenuID].className=OpenedMenusClasses[MainMenuID];

    for (i=0;i<OpenedMenusNumber[MainMenuID];i++) {
        OpenedMenus[MainMenuID][i].style.display='none';
    }
    OpenedMenusNumber[MainMenuID]=0;
}


function HideSubMenu(ThisMenuID,SubMenuID,MainMenuID){

//document.body.style.background='red';
    DontHideThisSubMenu=null;
    menuTimeoutRes=window.setTimeout(function() { HideSubMenuNow(ThisMenuID,SubMenuID,MainMenuID); }, 100);

}


function HideMe(PrevMenuID,SubMenuID,MainMenuID) {

    window.setTimeout(function() { HideMeNow(PrevMenuID,SubMenuID,MainMenuID); }, 100);
}

function HideMeNow(PrevMenuID,SubMenuID,MainMenuID) {

    if (DontHideThisSubMenu==SubMenuID) { return; }
    
    //forex special
    //document.getElementById('flashdiv').style.visibility='visible';
    
    //sprawdz czy nie ma otwartych podmenu dla danego menu
    if  (!ChildsNumber[SubMenuID] || ChildsNumber[SubMenuID]<1) {
        HideSubMenuNow(PrevMenuID,SubMenuID,MainMenuID);

    }
    

}

function HideSubMenuNow(ThisMenuID,SubMenuID,MainMenuID) {

    //alert(DontHideThisSubMenu+' = '+SubMenuID);
    if (DontHideThisSubMenu==SubMenuID) { return; }
    
    //forex special
    //document.getElementById('flashdiv').style.visibility='visible';

    var Close=false;

    for (i=0;i<OpenedMenusNumber[MainMenuID];i++) {

        if (!Close && OpenedMenus[MainMenuID][i].id==SubMenuID) { Close=true; }
        if (Close) {
            OpenedMenus[MainMenuID][i].style.display='none';
            for(j=i+1;j<OpenedMenus[MainMenuID].length;j++) {
                OpenedMenus[MainMenuID][j-1]=OpenedMenus[MainMenuID][j];
            }
            OpenedMenusNumber[MainMenuID]--;

            if (ChildsNumber[ThisMenuID]) {
                ChildsNumber[ThisMenuID]--;
            }
        }
    }

}


function StopHiddingThisMenu(MainMenuID) {
    DontHideThisMenu=MainMenuID;
}


function StopHiddingThisSubMenu(SubMenuID) {
    DontHideThisSubMenu=SubMenuID;
}


//window.setTimeout(function() { ShowInStatus(); }, 100);

function ShowInStatus() {
    //window.status=OpenedMenusNumber['menu_o_nas'];
    //window.setTimeout(function() { ShowInStatus(); }, 100);
}

