/* ***********************************
   JavaScript DHTML code by Tim Poulsen
   Ziff-Davis Education
   **********************************/

/* ***************************************
   DHTML core library
   turns divs and spans into objects
   and gives them properties and
   methods that make them "manipulatible"
*****************************************/

/* ***************************************
   Browser detection and handling
*****************************************/
//if(!parseInt(navigator.appVersion) >= 4) 
//  {
//  alert("This page requires a 4.x or newer browser. Please download one, then re-visit.");
//  location = "http://home.netscape.com";
//  }

var isNav6 = false;
var isNav4 = false;
var isNav = false;
var isIE4 = false;
var isIE5 = false;
var isIE6 = false;
var isIE = false;
if(navigator.appName=="Netscape")
  {
  isNav=true;
  if(parseInt(navigator.appVersion) == 4) isNav4=true;
  if(parseInt(navigator.appVersion) == 5) isNav6=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;
  }

// 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();">
 ***************************************************/


/* ***************************************
   Primary function - object prototype
   pass it a DIV name and it returns
   an object with various properties
*****************************************/
function ActiveElement(obj, parent)
  {
  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);
//    this.obj = eval("this"); // uncomment to add reference to the object itself
    }
else if(isNav6)
    {
    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);
//    this.elem.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP | Event.MOUSEMOVE | Event.CLICK);
//    this.obj = eval("this"); // uncomment to add reference to the object itself
    }
  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.obj = eval("this"); // uncomment to add reference to the object itself
    }
  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;
//    this.obj = eval("this"); // uncomment to add reference to the object itself
    }
  else if(isIE6)
    {
    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;
//    this.obj = eval("this"); // uncomment to add reference to the object itself
    }
  }

/* ***************************************
   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(isNav6)
    {
    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(isNav6)
    {
    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()
  {
  this.css.visibility = (isNav4) ? "show" : "visible";
  }
ActiveElement.prototype.show = showIt;

function hideIt()
  {
  this.css.visibility = (isNav4) ? "hide" : "hidden";
  }
ActiveElement.prototype.hide = hideIt;

function setBGCol(color)
  {
  (isNav4) ? this.css.bgColor = color : this.css.backgroundColor = color;
  }
ActiveElement.prototype.setBGColor = setBGCol;

function toggleIt()
 {
  if(isNav4)
    {
	(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 = toggleIt;

function dynoWrite(html)
  {
  if(isNav4)
    {
    this.css.document.open();
    this.css.document.write(html);
    this.css.document.close();
    }
  if(isNav6)
    {
    this.elem.innerHTML = html;
    }
  else
    {
    this.elem.innerHTML = html;
    }
  }
ActiveElement.prototype.write = dynoWrite;

