//\//////////////////////////////////////////////////////////////////////////////////
//\  Addendum for overLIB 3.33 to clean up RIGHT, CENTER, LEFT, BELOW and VAUTO.
//\  Dennis Sandow dsandow@garden.net June 10, 2001
//\  Usage:
//\   <script type="text/javascript" src="overlib.js"></script>
//\   <script type="text/javascript" src="over333b.js"></script>
//\//////////////////////////////////////////////////////////////////////////////////
function placeLayer(){
  var placeX, placeY;
  if(olNs4||olNs6)SomeSmallNumber=25; else SomeSmallNumber=0;
  if(olIe4){
    winoffset=o3_frame.document.body.scrollLeft;
    iwidth=o3_frame.document.body.clientWidth;
    winTop=o3_frame.document.body.scrollTop;
    iheight=o3_frame.document.body.clientHeight;
    objRef=o3_frame.document.all['overDiv']; popwidth=objRef.scrollWidth;
    o3_aboveheight=objRef.scrollHeight;
  };
  if(olNs4||olNs6){
    winoffset=o3_frame.pageXOffset;
    iwidth=o3_frame.innerWidth; 
    winTop=o3_frame.pageYOffset;
    iheight=o3_frame.innerHeight;
  };
  if(olNs4){
    popwidth=over.clip.width; 
    o3_aboveheight=over.clip.height; 
  };
  if(olNs6){
    popwidth=over.offsetWidth;
    o3_aboveheight=over.offsetHeight; 
  };
  if(o3_fixx != -1){
    placeX=o3_fixx;
    if (o3_fixx >= 0 ) {
      placeX = winoffset + o3_fixx ;
    } else {
      placeX = winoffset  + o3_fixx+ iwidth - popwidth - SomeSmallNumber ;
    };
  } else {
    if(o3_hauto == 1){
      o3_offsetx=Math.abs(o3_offsetx)
      if((o3_x-winoffset)>((eval(iwidth))/ 2))o3_hpos=LEFT; else o3_hpos=RIGHT;
    };
    nojustx=o3_offsetx-ol_offsetx
    if(o3_hpos == CENTER)placeX=o3_x-popwidth/2+(nojustx?o3_offsetx:0);
    if(o3_hpos == RIGHT)placeX=o3_x+o3_offsetx;
    if(o3_hpos == RIGHT || o3_hpos == CENTER ){
      if(o3_snapx > 1)placeX=placeX +(o3_snapx-placeX % o3_snapx);
      if(!nojustx&&(eval(placeX)+eval(popwidth))>(winoffset+iwidth-SomeSmallNumber)){
        placeX=iwidth+winoffset-popwidth-SomeSmallNumber ;
      };
    };
    if(o3_hpos == LEFT){
      placeX=o3_x-o3_offsetx-popwidth;
      if(o3_snapx > 1)placeX=placeX-(o3_x % o3_snapx);
    };
    if(!nojustx&&(placeX<winoffset))placeX=winoffset;
  };
  if(o3_fixy != -1){
    placeY=o3_fixy;
    if (o3_fixy >= 0 ) {
      placeY = winTop + o3_fixy ;
    } else {
      placeY = winTop  + o3_fixy+ iheight - o3_aboveheight ;
    };
  } else {
    if(o3_vauto == 1){
      o3_offsety=Math.abs(o3_offsety);
      if((o3_y-winTop)> iheight/2)o3_vpos=ABOVE; else o3_vpos=BELOW;
    };
    nojusty=o3_offsety-ol_offsety
    if(o3_aboveheight > 0 && o3_vpos == ABOVE){
      placeY=o3_y -(o3_aboveheight+o3_offsety);
      if(o3_snapy > 1)placeY=placeY-(o3_y % o3_snapy);
    } else {
      placeY=o3_y+o3_offsety;
      if(o3_snapy > 1)placeY=placeY +(o3_snapy-placeY % o3_snapy);
      if(!nojusty&&((placeY+o3_aboveheight)>(winTop+iheight)))placeY=winTop+iheight-o3_aboveheight ;
    };
    if(!nojusty&&(placeY<winTop))placeY=winTop ;
  };
  repositionTo(over, placeX, placeY);
};
