function getParent (el, cp, vl) {
  if (el == null) return null;
  else if (el.nodeType == 1 && 
         (('string' == typeof vl && el[cp] == vl) || 
          ('string' == typeof cp &&
           el.tagName.toLowerCase() == cp.toLowerCase()) || 
           el == cp))
      return el; 
  else return getParent(el.parentNode, cp, vl);  
}

function getTop(o) {
  if (o.getBoundingRect)
    return o.getBoundingRect().top+document.body.scrollTop-2;

  var r=o.offsetTop;
  while (o=o.offsetParent) r+=o.offsetTop;
  return r;
}

var curPos, prevPos;

function showPosition(aEvent, aObj, aHtml) {
  if (getParent(aEvent.fromElement || aEvent.relatedTarget, aObj) === aObj) return false; 

  aObj.style.backgroundColor="#f5f5f5";

  var div = document.createElement("div");
  div.style.backgroundColor = "#ffffff";
  div.style.position        = "absolute";
  div.style.top             = getTop(aObj)+"px";
  div.style.left            = "30px";
  div.style.border          = "1px #cccccc solid";
  div.style.padding         = "3px";
  div.innerHTML             = aHtml;

  curPos = document.body.appendChild(div);
  prevPos = aObj;
}

function hidePosition(aEvent, aObj) {
  if (getParent(aEvent.toElement || aEvent.relatedTarget, aObj) === aObj) return false;
  curPos.parentNode.removeChild(curPos);
  prevPos.style.backgroundColor="#ffffff";
}

function animatein() {
  if ( parseInt(b1.top) < 0 ) {
    b1.top = ( parseInt(b1.top) + 25 ) + 'px';
  } else if ( parseInt(b2.top) < 0 ) {
    b2.top = ( parseInt(b2.top) + 25 ) + 'px';
  } else if ( parseInt(b3.top) < 0 ) {
    b3.top = ( parseInt(b3.top) + 25 ) + 'px';
  } else if ( parseInt(b4.top) < 0 ) {
    b4.top = ( parseInt(b4.top) + 25 ) + 'px';
  } else if ( parseInt(b0.left) < 0 ) {
    b0.left = ( parseInt(b0.left) + 25 ) + 'px';
  } else {
    b0.fontStyle = "normal";
    clearInterval( start );
  }
}

function flyin() {
  b0 = document.getElementById("block0").style;
  b0.position = "relative"; b0.left = "-400px"; b0.fontStyle = "italic";
  if ( document.getElementById("block1") ) {
    b1 = document.getElementById("block1").style;
    b2 = document.getElementById("block2").style;
    b3 = document.getElementById("block3").style;
    b4 = document.getElementById("block4").style;
    b1.position = b2.position = b3.position = b4.position = "relative";
    b1.top = b2.top = b3.top = b4.top = "-400px";
  } else { b1 = b2 = b3 = b4 = ''; }
  start = setInterval( "animatein()", 10 );
}
