/* **************************************************************
* name:          dhtml.js                                       *
* description:   Object-oriented DHTML library                  *
* author:        Tim Poulsen, Sr. Curriculum Dev., Element K    *
* version:       2.1.a                                            *
* last update:   August 17, 2001                                *
* license:       This library is free and without restrictions  *
*                except that this initial comment/message must  *
*                remain intact and you credit the author for it.*
*                Please send fixes or changes to the author at  *
*                poulsen@netacc.net or tim_poulsen@elementk.com *
************************************************************** */

/* *************************************************************
*  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;
//alert(parseInt(navigator.appVersion))
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 = this.elem.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;
    	}
  	}

/* ***************************************
   Begin library of functions that will
   become methods of our prototype object
*****************************************/
function moveItTo(x, y)
	{
	if(isNav4)
		{
		this.css.left = x;
		this.css.top = y;
		this.x = x;
		this.y = y;
		}
	if(isGecko)
		{
		this.css.left = x + "px";
		this.css.top = y + "px";
		this.x = x;
		this.y = y;
		}
	else
		{
		this.css.pixelLeft = x;
		this.css.pixelTop = y;
		this.x = x;
		this.y = y;
		}
	}
ActiveElement.prototype.moveTo = moveItTo;

function moveItBy(dX, dY)
	{
	if(isNav4)
		{
		this.css.left += dX;
		this.css.top += dY;
		this.x = this.x + dX;
		this.y = this.y + dY;
		}
	if(isGecko)
		{
		this.css.left = this.x + dX + "px";
		this.css.top = this.y + dY + "px";
		this.x = this.x + dX;
		this.y = this.y + dY;
		}
	else
		{
		this.css.pixelLeft = this.x + dX;
		this.css.pixelTop = this.y +  dY;
		this.x = this.x + dX;
		this.y = this.y + dY;
		}
	}
ActiveElement.prototype.moveBy = moveItBy;

function setZIndex(zInd)
  {
  this.css.zIndex = zInd;
  }
ActiveElement.prototype.setZ = setZIndex;

function showIt()
  {
  if(isNav4) this.css.visibility = "show"
  else this.css.visibility = "visible";
  }
ActiveElement.prototype.show = showIt;

function hideIt()
  {
  if(isNav4) this.css.visibility = "hide";
  else this.css.visibility = "hidden";
  }
ActiveElement.prototype.hide = hideIt;

function toggleVis()
  {
  if(isNav)
    {
    (this.css.visibility == "show") ? this.css.visibility = "hide" : this.css.visibility = "show";
    }
  else
    {
    (this.css.visibility == "visible") ? this.css.visibility = "hidden" : this.css.visibility = "visible";
    }
  }
ActiveElement.prototype.toggle = toggleVis;

function setBGCol(color)
  {
  (isNav4) ? this.css.bgColor = color : this.css.backgroundColor = color;
  }
ActiveElement.prototype.setBGColor = setBGCol;

function dynoWrite(html)
  {
  if(isNav4)
    {
    this.css.document.open();
    this.css.document.write(html);
    this.css.document.close();
    }
  if(isGecko)
    {
    this.elem.innerHTML = html;
    }
  else
    {
    this.elem.innerHTML = html;
    }
  }
ActiveElement.prototype.write = dynoWrite;
