var iDelay=500 // Delay to hide in milliseconds
var sDisplayTimer = null, oLastItem

function getRealPos(i,which) {
  iPos = 0
  while (i!=null) {
    iPos += i["offset" + which]
    i = i.offsetParent
  }
  return iPos
}

function showDetails(i,sDest) {
  var dest = document.getElementById(sDest);
  if (dest) {
    stopTimer()
    if ((oLastItem!=null) && (oLastItem!=dest))
      hideItem();
    if (dest) {
      dest.style.left = getRealPos(i,"Left") + i.offsetWidth + 5 + "px";
      dest.style.top = getRealPos(i,"Top") + "px";
      dest.style.visibility = "visible";
    }
    oLastItem = dest
  }
}

function stopTimer() {
  clearTimeout(sDisplayTimer)
}

function startTimer(el) {
  stopTimer()
  sDisplayTimer = setTimeout("hideItem()",iDelay)
}

function hideItem() {
  if (oLastItem)
    oLastItem.style.visibility="hidden"
}

function checkOver(e) {
  var targ;
  if (!e) var e = window.event;
  if (e.target) targ = e.target;
  else if (e.srcElement) targ = e.srcElement;
  if (oLastItem) {
    if (isAncestor(oLastItem,targ)) {
      stopTimer()
    }
  }
}

function checkOut(e) {
  var targ, dest;
  if (!e) var e = window.event;
  if (e.target) targ = e.target;
  else if (e.srcElement) targ = e.srcElement;
  if (e.relatedTarget) dest = e.relatedTarget;
  else if (e.toElement) dest = e.toElement;
  if (oLastItem==targ)
    if (!isAncestor(targ,dest))
      startTimer(targ,dest)
}

function isAncestor(a,b) {
  var p=b;
  while (p=p.parentNode) {
    if (a==p) return true;
  }
  return false;
}

function isEmail(str) {
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported)
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}

function checkForm(form) {
  if (isEmail(form.user.value)) {
    return true;
  } else {
    alert("Please enter a valid email address.");
    form.email.focus();
    return false;
  }
}

document.onmouseover = checkOver
document.onmouseout = checkOut

if (top.location != location) top.location.href = document.location.href;


