var TimerId = null;
var VisibleId = "";

function findPos(obj) {
  var curleft = curtop = 0;
    if (obj.offsetParent) {
	  curleft = obj.offsetLeft
	  curtop = obj.offsetTop
	  while (obj = obj.offsetParent) {
		curleft += obj.offsetLeft
		curtop += obj.offsetTop
	  }
	}
  // return [curleft,curtop];
  return curleft
}
					
function OverMenu(LayerId,Obj) { 
  if(Obj) {
    xPos = findPos(Obj)
    if (document.layers)               { document.layer[LayerId].left = xPos }
    else if (document.all)             { document.all[LayerId].style.left = xPos }
    else if (document.documentElement) { document.getElementById(LayerId).style.left = xPos }
  }
  if((VisibleId != "") && (TimerId != null)) {
    if(LayerId != VisibleId) {
      SetVisibility(VisibleId, "hidden")
    }
    clearTimeout(TimerId)
  }
  SetVisibility(LayerId, "visible");
}

function OutMenu(LayerId) {
  TimerId = window.setTimeout("HideMenu()", 500);
}

function HideMenu() {
  if(VisibleId != "") { SetVisibility(VisibleId, "hidden") }
  if(TimerId != null) { clearTimeout(TimerId) }
}

function SetVisibility(LayerId, Visibility) {
  if (document.layers)               { document.layer[LayerId].visibility = Visibility }
  else if (document.all)             { document.all[LayerId].style.visibility = Visibility }
  else if (document.documentElement) { document.getElementById(LayerId).style.visibility = Visibility }
  if(Visibility == "visible") { VisibleId = LayerId } else { VisibleId = "" }
}

function WriteMail(link) {
  link = link + "@";
  link = link + "webproject.pl";
  document.write("<a href='mailto:" + link + "'>" + link + "</a>");
}

function ShowEnlarged(picture) {
  msgWindowWidth = 600 + 30;
  msgWindowHeight = 500 + 30;
  msgWindowLeft = Math.round(screen.width / 2) - Math.round(msgWindowWidth / 2);
  msgWindowTop = Math.round(screen.height / 2) - Math.round(msgWindowHeight / 2) - 40;
  options = "resizable=no,toolbar=no,menubar=no,location=no,personalbar=no,top=" + msgWindowTop + ",left=" + msgWindowLeft + ",height=" + msgWindowHeight + ",width=" + msgWindowWidth + ",status=no,scrollbars=no";
  msgWindow = window.open('/img/' + picture, 'picture', options);
  msgWindow.focus();
}
