function showValidate(windowID, obj, horizPadding, vertPadding, align)
{
   var w = document.getElementById(windowID);
   if (w != null)
   {      
      w.style.display = 'block';
      w.style.visibility = 'visible';      
      if (getAscendingTops(obj) + vertPadding < 0) w.style.top = 0;
      var curr_width = w.offsetWidth; 
      var curr_height = w.offsetHeight;
      switch (align)
      {
        case 1: // right
          w.style.left = getAscendingLefts(obj) + obj.offsetWidth + horizPadding + 'px';  
          w.style.top = getAscendingTops(obj) + vertPadding + 'px';            
          break;
        case 2: // left          
          w.style.left = getAscendingLefts(obj) - curr_width - horizPadding + 'px';
          if ((getAscendingLefts(obj) - horizPadding) < 0) w.style.left = getAscendingLefts(obj) + obj.offsetWidth + horizPadding + 'px';
          w.style.top = getAscendingTops(obj) + vertPadding + 'px';            
          break;
        case 3: // top          
          w.style.left = getAscendingLefts(obj) - horizPadding + 'px';
          w.style.top = getAscendingTops(obj) - curr_height + 'px';  
          break;        
        case 4: // bottom
          w.style.left = getAscendingLefts(obj) - horizPadding + 'px';          
          w.style.top = getAscendingTops(obj) + getAscendingHeight(obj) + 'px';
          break;
      }      
   }
} 

function hideValidate(windowID)
{
  var w = document.getElementById(windowID);
  if (w != null)
  {
    w.style.display = 'none';
    w.style.visibility = 'hidden';
    
    w.top = -999;
    w.left = -999;
  }
}  

function getAscendingLefts(elem){
  if (elem==null)
    return 0;
  else
    return elem.offsetLeft+getAscendingLefts(elem.offsetParent);
}

function getAscendingTops(elem){
  if (elem==null)
    return 0;
  else
    return elem.offsetTop+getAscendingTops(elem.offsetParent);
}

function getAscendingHeight(elem)
{
  if (elem==null)
    return 0;
  else
    return elem.offsetHeight;
}
