/*----------------------------------------------
       2005-6-29  code
  ---------------------------------------------

  $Record=array();
  while( $row=...){
   
     $id=$row[....]

     $Record[$id]=$row[..........]
     $mouse="onMouseover='ShowFollowBlock($id)' onMouseout='HideFollowBlock($id)'"; 
     <td $mouse ></td
  }

  while( list($k,$row)=each($Record) ){
     $c=( $row[parent]==0 )?"#DDF3FF":"#DDFFDD"; 
     echo "\n
         <div id='B$k' style='display:none;width:400px;position:absolute;border:1px solid green;padding:2px;background:$c' >
             Subject: $row[subject]<br>   
            <div>$row[body]</div> 
        </div>";


---------------------------------------------------*/

function ShowFollowBlock( tk , me ){
   var obj=document.getElementById( 'B'+tk );
   if( obj==null ) return ; 
 
   obj.style.display="block";

  isIE    = false;  // Internet Explorer
  isNS    = false;  // Netscape



  s = "Netscape6";
  if( navigator.userAgent.indexOf(s) >= 0) { isNS = true; }

  s = "MSIE";
  if( navigator.userAgent.indexOf(s)>0  ){ isIE = true; }


  if( isIE  ){
      var y =getPageOffsetTop(  window.event.srcElement );
      var x =getPageOffsetLeft( window.event.srcElement );

      y+=window.event.srcElement.offsetHeight *2 ;
      x+=window.event.srcElement.offsetParent.clientLeft;
      x= x - parseInt(obj.style.width)-10;
  }else {

     var y=getPageOffsetTop(me)+me.offsetHeight*2;

      //( window.innerHeight-parseInt(obj.offsetHeight) )/2;
     var x=( window.innerWidth-parseInt(obj.style.width)   ) /2 ;
  }




   var maxX, maxY;

   if ( isIE) {
     maxX = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft) +
        (document.documentElement.clientWidth != 0 ? document.documentElement.clientWidth : document.body.clientWidth);
     maxY = Math.max(document.documentElement.scrollTop, document.body.scrollTop) +
       (document.documentElement.clientHeight != 0 ? document.documentElement.clientHeight : document.body.clientHeight);
   }else {
     maxX = window.scrollX + window.innerWidth;
     maxY = window.scrollY + window.innerHeight;
   }


   if( x <=0 ) x=( maxX - parseInt(obj.style.width) )/2;
    

   if( x > maxX  )                x = Math.max(0, x - obj.offsetWidth  );
   if( y+obj.offsetHeight >maxY ) y = Math.max(0, y-obj.offsetHeight-80 );


   
   if(   isIE &&  y<= document.body.scrollTop ){
       y=document.body.scrollTop+10;     
   }else if(  !isIE  && y<=window.scrollY  ){
       y=window.scrollY+10;
   }


   obj.style.left=x;
   obj.style.top =y;

   //alert(window.document.offsetHeight);
   //alert(screen.availHeight);
   
}
function HideFollowBlock( tk ){
   var obj=document.getElementById( 'B'+tk );
   if( obj==null ) return ; 

   obj.style.display="none";   
}

function getPageOffsetTop(el) {

  var y;
  // Return the x coordinate of an element relative to the page.
  y = el.offsetTop;
  if (el.offsetParent != null) y += getPageOffsetTop(el.offsetParent);

  return y;
}
function getPageOffsetLeft(el) {

  var x;
  // Return the x coordinate of an element relative to the page.
  x = el.offsetLeft;
  if (el.offsetParent != null) x += getPageOffsetLeft(el.offsetParent);
  return x;
}

