 function otworz(locationText){
      if ( locationText != '' ) {
         	window.ramka.location = locationText;
     	      UkryjWarstwe(aktywnyPrzycisk);  	
	}
}	
    
var aktywnyPrzycisk = null;
var currentMenuId = 0;
var bLeft = 0;
document.onmouseover = documentMousedown;

function documentMousedown(event) {
   var element;
   if (parent.aktywnyPrzycisk == null){
      return;
   }
  if (parent.document.all){
    if ( parent.window.event ){
        element = parent.window.event.srcElement;
    }else{

        element = window.srcElement;
    }
  }else{
    if (event){
       element = (event.target.tagName ? event.target : event.target.parentNode);
    }else{
       element = (e.target.tagName ? e.target : e.target.parentNode);
    }
  }

  if (element == parent.aktywnyPrzycisk){
    return;
  }
  if (getWith(element, "DIV", "menu") == null) {
    UkryjWarstwe( parent.aktywnyPrzycisk);
    parent.aktywnyPrzycisk = null;
  }
}

function zamknij( event, menuID )
{
    var warstwa;
    if ( menuID != currentMenuId ){
    zamknijSubMenu( aktywnyPrzycisk.warstwa);
   }
}

function buttonClick(event, menuId) {
  var przycisk;
  if (document.all){
    przycisk = window.event.srcElement;
  } else{
   przycisk = event.currentTarget;
  } 
	if ( document.getElementById(menuId) != null ){
  przycisk.warstwa = document.getElementById(menuId);
	}

  if (aktywnyPrzycisk != null){
    UkryjWarstwe(aktywnyPrzycisk);
 }	


    if ( przycisk.warstwa != null ){
    PokazButton(przycisk);
    aktywnyPrzycisk = przycisk;
    }
  return false;
}

function PokazButton(przycisk) {
  var x, y;
  x = getLeft(przycisk);
  if ( bLeft == 0 ) {
    y = getTop( przycisk ) + przycisk.offsetHeight - 2;
  }else{
    y = getTop( przycisk );
  }
  if (document.all) {
    if ( bLeft == 0 ) {
     x += przycisk.offsetParent.clientLeft;
     y += przycisk.offsetParent.clientTop;
    }else{
	if(window.opera){
	        x += przycisk.offsetParent.clientLeft;
	        y += przycisk.offsetParent.clientTop - document.all('INFORMACJE').scrollTop;
	}else{
	     if (navigator.appVersion.indexOf("MSIE 6")!=-1 ) {
	        x += przycisk.offsetParent.clientLeft + przycisk.offsetParent.clientWidth;
	        y += przycisk.offsetParent.clientTop - document.all('INFORMACJE').scrollTop;
	     }else{
	        x += przycisk.offsetParent.clientLeft;
	        y += przycisk.offsetParent.clientTop - document.all('INFORMACJE').scrollTop;
	     }
	}	 
     
    }
  }else{
         x += przycisk.offsetWidth;
         y += przycisk.offsetTop - document.getElementById('INFORMACJE').scrollTop;
  }

  przycisk.warstwa.style.left = x + "px";
  przycisk.warstwa.style.top  = y + "px";
  przycisk.warstwa.style.visibility = "visible";
}

function UkryjWarstwe(przycisk) {
    if ( przycisk != null) {
       zamknijSubMenu(przycisk.warstwa);
       przycisk.warstwa.style.visibility = "hidden";
    }
}

function menuMouseover(event,menuId, LeftMenu ) {
    bLeft = LeftMenu
    buttonClick(event, menuId)
}

function menuItemMouseover(event, menuId ) {
  var menuitem, menu, x, y;
  currentMenuId = menuId;
  if (document.all){
   menuitem = getWith(window.event.srcElement, "A", "menuItem");
 }	
  else{
    menuitem = event.target;
 }
  menu = getWith(menuitem, "DIV", "menu");

  if (menu.activemenuItem != null){
    zamknijSubMenu(menu);
  }
  menu.activemenuItem = menuitem;
  if (menuitem.subMenu == null) {
    menuitem.subMenu = document.getElementById(menuId);
  }

  x = getLeft(menuitem) + menuitem.offsetWidth;
  y = getTop(menuitem);

  menuitem.subMenu.style.left = x + "px";
  menuitem.subMenu.style.top  = y + "px";
  menuitem.subMenu.style.visibility = "visible";

}

function zamknijSubMenu(menu) {
  if (menu == null || menu.activemenuItem == null)
    return;

  if (menu.activemenuItem.subMenu != null) {
    zamknijSubMenu(menu.activemenuItem.subMenu);
    menu.activemenuItem.subMenu.style.visibility = "hidden";
    menu.activemenuItem.subMenu = null;
  }
  menu.activemenuItem = null;
}

function getWith(node, tagName, className) {
  while (node != null) {
    if (node.tagName != null && node.tagName == tagName && getClassName(node, className)){
      return node;
    }
    node = node.parentNode;
  }

  return node;
}

function getClassName(element, name) {
  var i, list;
  list = element.className.split(" ");
  for (i = 0; i < list.length; i++){
    if (list[i] == name){
	      return true;
	 }
 }	  
  return false;
}


function getLeft(element) {
  var x;
  x = element.offsetLeft;
  if (element.offsetParent != null){
    x += getLeft(element.offsetParent);
  }
  return x;
}

function getTop(element) {
  var y;
  y = element.offsetTop;
  if (element.offsetParent != null){
    y += getTop(element.offsetParent);
  }
  return y;
}


