/* **************************************************************
* name:          dhtml.js                                       *
* description:   Object-oriented DHTML library                  *
* author:        Tim Poulsen, Sr. Curriculum Dev., Element K    *
* version:       2.2                                            *
* last update:   September 25, 2001                             *
************************************************************** */

/* *************************************************************
*  FOR A PRODUCTION WEB PAGE, DELETE THE FOLLOWING COMMENTS!   *
*                                                              *
* Include in page with <SCRIPT LANGUAGE="JavaScript" SRC =     *
* "dhtml.js"></SCRIPT> tag                                     *
*                                                              *
*  DHTML core library turns divs and spans into objects        *
*  and gives them properties and methods that make them        *
*  "manipulatible"                                             *
*                                                              *
* This script includes browser detection and defines           *
* the following variables:                                     *
* ----------------------------------------------------         *
* Browser brand variables, isNav and isIE, with a value of     *
* true when those browsers (any version) are in use            *
*                                                              *
* Browser- and version-specific variables, isNav3, isNav4,     *
* isGecko, isIE3, isIE4, isIE5, isIE6, and isDOM when those    *
* particular browsers are in use                               *
*                                                              *
************************************************************** */

/* ***************************************
   Browser detection and handling
*****************************************/
var isNav4 = false;
var isGecko = false;
var isNav = false
var isIE4 = false;
var isIE5 = false;
var isIE6 = false;
var isIE = false;
var isDOM = false;
if(navigator.appName=="Netscape")
  {
  isNav=true;
  if(parseInt(navigator.appVersion) >= 4 && parseInt(navigator.appVersion) < 5) isNav4 = true;
  if(parseInt(navigator.appVersion) >= 5) isGecko = true;
  }
else if(navigator.appName=="Microsoft Internet Explorer")
  {
  isIE=true;
  if(navigator.appVersion.indexOf("MSIE 4") != -1) isIE4=true;
  if(navigator.appVersion.indexOf("MSIE 5") != -1) isIE5=true;
  if(navigator.appVersion.indexOf("MSIE 6") != -1) isIE6=true;
  }
if(isGecko || isIE6) isDOM = true;

// now, handle Nav4 resize bug where CSS objects don't get redrawn properly
// also re-positions manually positioned CSS objects after a resize
var origHeight, origWidth
function startResizeFix()
  {
  origHeight = (isNav4) ? window.outerHeight : document.body.offsetHeight;
  origWidth = (isNav4) ? window.outerWidth : document.body.offsetWidth;
  }
function resizeFix()
  {
  currHeight = (isNav4) ? window.outerHeight : document.body.offsetHeight;
  currWidth = (isNav4) ? window.outerWidth : document.body.offsetWidth;
  if(currHeight != origHeight || currWidth != origWidth) location.reload();
  }
/* **************************************************
 CALL startResizeFix() and resizeFix() IN BODY TAG
<body onLoad="startResizeFix();" onResize="resizeFix();">
 ***************************************************/

/* *************************************************************
   ActiveElement constructor function, pass it the DIV or SPAN's
   ID (string). For Navigator 4.x, include the full document.layers[]
   notation of the LAYER that contains the current DIV
 ************************************************************** */
function ActiveElement(obj, parent)
  {
  if(isGecko || isIE6)
    {
    this.name = obj;
    this.elem = document.getElementById(obj);
    this.css = document.getElementById(obj).style;
    this.x = parseInt(this.css.left);
    this.y = parseInt(this.css.top);
    this.h = parseInt(this.css.height);
    this.w = parseInt(this.css.width);
    }
  else if(isNav4)
    {
    this.name = obj;
    this.css = (parent) ? eval("document." + parent + ".document.layers['" + obj + "']") : document.layers[obj];
    this.elem = this.css;
    this.x = this.css.left;
    this.y = this.css.top;
    this.h = this.css.clip.height;
    this.w = this.css.clip.width;
    this.elem.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP | Event.MOUSEMOVE | Event.CLICK);
    }
  else if(isIE5)
    {
    this.name = obj;
    this.css = document.all[obj].style;
    this.elem = document.all[obj];
    this.x = this.elem.offsetLeft;
    this.y = this.elem.offsetTop;
    this.h = this.elem.offsetHeight;
    this.w = this.elem.offsetWidth;
    }
  else if(isIE4)
    {
    this.name = obj;
    this.css = document.all[obj].style;
    this.elem = document.all[obj];
    this.x = this.css.pixelLeft;
    this.y = this.css.pixelTop;
    this.h = this.css.pixelHeight;
    this.w = this.css.pixelWidth;
    }
  this.css.position='absolute';
  }

/* ***************************************
   Begin library of functions that will
   become methods of our prototype object
*****************************************/

// Define and assign write() method
function dynoWriteNav(html)
  {
  this.elem.document.open();
  this.elem.document.write(html);
  this.elem.document.close();
  }
function dynoWrite(html)
  {
  this.elem.innerHTML = html;
  }
ActiveElement.prototype.write = (!isNav4) ? dynoWrite : dynoWriteNav;



// Define and assign tooltip() method
function dynoTooltipNav(head, contents, thumbnail, large)
  {
  if(thumbnail == '' || thumbnail == 'noimage') {
	  thumb = 'images/noimage.gif';
  } else {
	  thumb = 'testimonialimages/'+thumbnail;
  }
  if(large != 'noimage' || large == '') {
	  lg = '';
  } else {
	  lg = '<img src=testimonialimages/'+large+' align=left>';
  }
  
  this.elem.document.open();
  this.elem.document.write('<a href="#" onMouseover="ddrivetip(\'<div class=heading>' + head + '</div><div class=wrapper><div class=body>' + lg + contents + '</div>\')" onMouseout="hideddrivetip()"><img src="' + thumb + '" border="0" /></a>');
  this.elem.document.close();
  }
function dynoTooltip(head, contents, thumbnail, large)
  {
  if(thumbnail == '' || thumbnail == 'noimage') {
	  thumb = 'images/noimage.gif';
  } else {
	  thumb = 'testimonialimages/'+thumbnail;
  }
  if(large == '') {
	  lg = '';
  } else {
	  lg = '<img src=testimonialimages/'+large+' align=left>';
  }
  this.elem.innerHTML = '<a href="#" onMouseover="ddrivetip(\'<div class=heading>' + head + '</div><div class=wrapper><div class=body>' + lg + contents + '</div>\')" onMouseout="hideddrivetip()"><img src="' + thumb + '" border="0" /></a>';
  }
ActiveElement.prototype.tooltip = (!isNav4) ? dynoTooltip : dynoTooltipNav;

// Define and assign moveTo() method
function moveItTo(x, y) {
	if(isIE) {
		x = x;
		y = y;
	}
	this.css.left = x+'px';
	this.css.top = y+'px';
	this.x = x;
	this.y = y;
}
function moveItToIE(x, y) {
	this.css.pixelLeft = x;
	this.css.pixelTop = y;
	this.x = x;
	this.y = y;
}
ActiveElement.prototype.moveTo = (isDOM || isNav4) ? moveItTo : moveItToIE;

// Define and assign moveBy() method
function moveItBy(dX, dY)
  {
  this.css.left = this.x + dX;
  this.css.top = this.y + dY;
  this.x += dX;
  this.y += dY;
  }
function moveItByIE(dX, dY)
  {
  this.css.pixelLeft += dX;
  this.css.pixelTop +=  dY;
  this.x += dX;
  this.y += dY;
  }
ActiveElement.prototype.moveBy = (isDOM || isNav4) ? moveItBy : moveItByIE;

// Define and assign setZ() method
function setZIndex(zInd) 
  {
  this.css.zIndex = zInd;
  }
ActiveElement.prototype.setZ = setZIndex;

// Define and assign show() method
function showItNav()
  {
  this.css.visibility = "show";
  }
function showIt()
  {
  this.css.visibility = "visible";
  }
ActiveElement.prototype.show = (!isNav4) ? showIt : showItNav;

// Define and assign hide() method
function hideItNav()
  {
  this.css.visibility = "hide";
  }
function hideIt()
  {
  this.css.visibility = "hidden";
  }
ActiveElement.prototype.hide = (!isNav4) ? hideIt : hideItNav;

// Define and assign toggle() method
function toggleVisNav()
  {
  (this.css.visibility == "show") ? this.css.visibility = "hide" : this.css.visibility = "show";
  }
function toggleVis()
  {
  (this.css.visibility == "visible") ? this.css.visibility = "hidden" : this.css.visibility = "visible";
  }
ActiveElement.prototype.toggle = (!isNav4) ? toggleVis : toggleVisNav;

// Define and assign setBGColor() method
function setBGColNav(color)
  {
  this.css.bgColor = color;
  }
function setBGCol(color)
  {
  this.css.backgroundColor = color;
  }
ActiveElement.prototype.setBGColor = (!isNav4) ? setBGCol : setBGColNav;

function showProps(obj, objName)
  {
  var out = "";
  for(var i in obj) 
    {
    if(i=="domain") continue;  // this line works around a troublesome IE5.0 bug!
    out += (objName + "." + i + "=" + obj[i] + "<BR>");
    }
  document.write(out);
  document.close();
  }
