/***********************************************
* Drop Down/ Overlapping Content- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

function getposOffset(overlay, offsettype){
var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
var parentEl=overlay.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function overlay(curobj, subobjstr, opt_position){
if (document.getElementById){
var subobj=document.getElementById(subobjstr)
subobj.style.display=(subobj.style.display!="block")? "block" : "none"
var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0) 
var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)
subobj.style.left=xpos+"px"
subobj.style.top=ypos+"px"
return false
}
else
return true
}

function overlayclose(aEvent, aObj){
var el = getParent(aEvent.toElement ||
                       aEvent.relatedTarget, aObj);   
    if (el === aObj) return false;
    aObj.style.display = 'none';
}

/*
  *  Performs parent lookup by 
  *   - node object: actually it's "is child of" check
  *   - tagname: getParent(el, 'li') == getParent(el, 'tagName', 'LI')
  *   - any node attribute
  *
  *  @param DOMnode source element
  *  @param mixed DOMNode or string tagname or string attribute name
  *  @param string optional attribute value
  *  @return mixed DOMNode or null
  */
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);  
}