var currentItem = null;

function show(e) {
	if (!e) var e = window.event;

	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode;

	var posx = 0;
	var posy = 0;

	if (e.pageX || e.pageY) {
		posx = e.pageX;
		posy = e.pageY;
	}	else if (e.clientX || e.clientY) {
		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	// posx and posy contain the mouse position relative to the document
	// Do something with this information
	
 	var item = targ.id.replace(/Button/,"");
	mainBox = document.getElementsByClassName("main")[0];
	var topPosition = posy - Position.cumulativeOffset(mainBox)[1] - 30;
	
	$(item).style.top = topPosition + "px";
  if (currentItem != null && currentItem != item) {
    hideBox();
  }
  new Effect.Appear($(item), { duration: 0.35 })
  currentItem = item;
  return false;
}

function hideBox() {
  new Effect.Fade($(currentItem), { duration: 0.35 });
  currentItem = null;
  return false;
}

function checkLegal(checkbox) {
  if (checkbox.checked) {
    checkbox.form.submit.disabled = false;
  }
  else {
    checkbox.form.submit.disabled = true;  
  }
}

function popWindow(href, target, attributes) {
  if (attributes == null) {
    attributes = "width=875,height=600,resizable=yes,scrollbars=yes,menubar=yes";
  }
  popWin = window.open(href, target, attributes);
  popWin.focus();
  return false;
}
