//-----------------------------------------------------------------------
// Module name   : lfloatImg.js
// Author        : Paul Battersby
// Creation Date : Oct 02/07
// Description   :
//  NOTE: this requires the presence of lutil.js
//
//  This contains routines to display and hide an image that will float above
//  the web page.
//
//  The appearance of the image can be controlled via css. The div that contains
//  the image has a classm id and name of "lfloatDiv". The image has a class,
//  id and name of "lfloatImg"
//
// $Log: lfloatImg.js $
// Revision 1.1  2007-10-11 14:38:22-04  Battersby
// Initial revision
//
//------------------------------------------------------------------------*/

/*---------------------------- INCLUDE FILES ----------------------------*/


/*----------------------------- CONSTANTS -------------------------------*/


/*----------------------------- VARIABLES -------------------------------*/


/*----------------------------- FUNCTIONS -------------------------------*/

//************************************************************************
// Name   : LFLOATIMG_init
// Author : Paul Battersby
// Description :
//  Places a hidden div and image tag on the web page optionally configuring
//  a border when the image is eventually displayed
//
// Pre :
//  (nothing)
//
// Params :
//  border - true indicates the image is to have a single pixel border
//
// Post :
//  see description
//
// Returns :
//  (nothing)
//*************************************************************************/
function LFLOATIMG_init(border)
{
  // determine if a border is desired
  var borderString = border ? "border='1'" : "";

  // create a hidden image tag
  document.write("<div class='lfloatDiv' id='lfloatDiv' name='lfloatDiv' style='position:absolute; z-index:2; display:none'><img class='lfloatImg' id='lfloatImg' name='lfloatImg' src='' " + borderString + "></div>");
} /* end of LFLOATIMG_init */

//************************************************************************
// Name   : LFLOATIMG_show
// Author : Paul Battersby
// Description :
//  This displays the floating image box and places the given image in the
//  box. The box is also moved to the specified absolute location (taking the
//  current page scrolling into account
//
// Pre :
//  LFLOATIMG_init() has been called
//
// Params :
//  imgName    - path to the image to be displayed
//  xpos, ypos - absolute location where image is to be placed
//
// Post :
//  image has been displayed at the given co-ords
//
// Returns :
//  (nothing)
//*************************************************************************/
function LFLOATIMG_show(imgName,xpos,ypos)
{
  var img = LUTIL_getRefById("lfloatImg");
  var div = LUTIL_getRefById("lfloatDiv");


  // determine if this is IE and if so, is it an old or new version
  var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body

  // use scroll left or pageXOffset depending on Netscape or IE
  var scrollLeft = document.all ? iebody.scrollLeft : pageXOffset;
  var scrollTop  = document.all ? iebody.scrollTop  : pageYOffset;

  div.style.left = xpos + scrollLeft + "px";
  div.style.top = xpos + scrollTop + "px";

  img.src = imgName;
  div.style.display = "";

} /* end of LFLOATIMG_show */

//************************************************************************
// Name   : LFLOATIMG_hide
// Author : Paul Battersby
// Description :
//  This hides the floating image
//
// Pre :
//  LFLOATIMG_init() has been called
//
// Params :
//  imgName - path to the image to be displayed
//  xpos, ypos - absolute location where image is to be placed
//
// Post :
//  the floating image is hidden
//
// Returns :
//  (nothing)
//*************************************************************************/
function LFLOATIMG_hide()
{
  var div = LUTIL_getRefById("lfloatDiv");
  div.style.display = "none";
//  img.src = "";

} /* end of LFLOATIMG_hide */


