function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

function toggle(id) { 
	
	if (document.getElementById) { // DOM3 = IE5, NS6
		if (document.getElementById(id).style.display == "none"){
			document.getElementById(id).style.display = 'block';
		} else {
			document.getElementById(id).style.display = 'none';			
		}	
	} else { 
		if (document.layers) {	
			if (document.id.display == "none"){
				document.id.display = 'block';
			} else {
				document.id.display = 'none';
			}
		} else {
			if (document.all.id.style.visibility == "none"){
				document.all.id.style.display = 'block';
			} else {
				document.all.id.style.display = 'none';
			}
		}
	}
}

function flipdivs(id1, id2) {
	toggle(id1);
	toggle(id2);
}

function liveDie(id1, id2) {
	hidediv(id2);
	showdiv(id1);
}

function isMouseLeaveOrEnter(e, handler) {	
	// Lovingly dysfunctionally named function thanks to dynamic-tools.net
	if ( e.type != 'mouseout' && e.type != 'mouseover') return false;
	
	var reltg = e.relatedTarget ? e.relatedTarget : e.type == 'mouseout' ? e.toElement : e.fromElement;
	
	while (reltg && reltg != handler) reltg = reltg.parentNode;
	return (reltg != handler);
}


var _POPUP_FEATURES = 'location=0, statusbar=0, menubar=0, width=401, height=530';

function raw_popup(url, target, features) {
  if (isUndefined(features)) {
    features = _POPUP_FEATURES;
	features += ', left=' + ((screen.width - 401)/2) + ', top=' + ((screen.height - 530)/2);
  }
  if (isUndefined(target)) {
    target = '_blank';
  }
  var theWindow = window.open(url, target, features);
  theWindow.focus();
  return theWindow;
}

function link_popup(src, features) {
  return raw_popup(src.getAttribute('href'), src.getAttribute('target') || '_blank', features);
}





function addOnMouseLeave( /*DOMElement*/element, /*Function*/onmouseleave )
{
  // summary: add an onMouseLeave handler to an element
  // element: DOMElement
  //   element for which the onMouseLeave is desired
  if (!element.id) element.id = ["onmouseleaveId",Math.random()].join("");
  setLogicalParent(element, element);
  element.onmouseout = function(evt)
  {
    var toElem = evt.relatedTarget;
    if (evt.relatedTarget == evt.currentTarget) return;
    var logicalParentId = toElem.getAttribute("logicalParentId");
    if (!logicalParentId || logicalParentId != element.id)
    {
      // call the onmouseleave handler with element as this
      // and pass it the event object
      onmouseleave.apply(element, [evt]);
    }
  }
}

function setLogicalParent( /*DOMElement*/root, /*DOMElement*/logicalParent )
{
  // summary: set the logicalParent of an entire DOM subtree
  // root: DOMElement
  //   topmost element in the DOM subtree
  // logicalParent: DOMElement
  //   element which will be referenced by all in the subtree
  var children=root.childNodes;
  if (!children) return;
  for (var i=0, count=children.length; i<count; i++)
  {
    var child = children[i];
    if (!child.setAttribute) continue;
    child.setAttribute("logicalParentId", logicalParent.id);
    setLogicalParent(child, logicalParent);
  }
}

function onmouseleave(evt)
{
  alert("onmouseleave:" + evt.currentTarget.id);
}


