//
// Author: Shelley Powers
// copyright: 1997,1998 Shelley Powers
//


// create IE DHTML equalizer object
function ie_object(obj) {
	this.css1 = obj;
	this.name = obj.id;
	this.objResizeBy = objResizeBy;
	this.objHide = objHide;
	this.objShow = objShow;
	this.objGetLeft = objGetLeft;
	this.objGetTop = objGetTop;
	this.objSetTop = objSetTop;
	this.objSetLeft = objSetLeft;
	this.objMoveAbsolute = objMoveAbsolute;
	this.objMoveRelative = objMoveRelative;
	this.objGetWidth = objGetWidth;
	this.objGetHeight = objGetHeight;
	this.objSetHeight = objSetHeight;
	this.objSetWidth = objSetWidth;
	this.objSetZIndex = objSetZIndex;
	this.objGetZIndex = objGetZIndex;
	this.objSetClipRect = objSetClipRect;
	this.objGetClipLeft = objGetClipLeft;
	this.objGetClipRight = objGetClipRight;
	this.objGetClipTop = objGetClipTop;
	this.objGetClipBottom = objGetClipBottom;
	this.replace_html = replace_html;
      this.objGetVisibility = objGetVisibility;
	this.objChangeSource = objChangeSource;
}


function objGetVisibility() {
    return this.css1.style.visibility;
}

function objResizeBy(wincr,hincr) {
	this.css1.style.pixelLeft-=hincr;
	this.css1.style.pixelTop-=wincr;
	this.css1.style.pixelWidth+=(2 * hincr);
	this.css1.style.pixelHeight+=(2 * wincr);
}


function replace_html(html_string) {
	this.css1.innerHTML = html_string;
}

// hide element
function objHide() {
	this.css1.style.visibility = "hidden";
}

// show element
function objShow() {
	this.css1.style.visibility = "inherit";
}

// element's left position
function objGetLeft() {
	return this.css1.style.pixelLeft;
}

// element's top position
function objGetTop () {
	return this.css1.style.pixelTop;
}

// set element's top position
function objSetTop (top) {
	this.css1.style.pixelTop = top;
}

// set element's left position
function objSetLeft(left) {
	this.css1.style.pixelLeft = left;
}

// make absolute move
function objMoveAbsolute(newleft, newtop) {
	this.objSetLeft(newleft);
      this.objSetTop(newtop);
}

// move relative to current location
function objMoveRelative(left, top) {
	this.objSetLeft(left + this.objGetLeft());
	this.objSetTop(top + this.objGetTop());
}

// get element's width
function objGetWidth() {
	return this.css1.style.pixelWidth;
}

// get element's height
function objGetHeight() {
	return this.css1.style.pixelHeight;
}

// set element's height
function objSetHeight(height) {
	this.css1.style.pixelHeight = height;
}

// set element's width
function objSetWidth(width) {
	this.css1.style.pixelWidth = width;
}

// set element's zindex order
function objSetZIndex(zindex) {
	this.css1.style.zIndex = zindex;
}

// get element's current zindex order
function objGetZIndex(zindex) {
	return this.css1.style.zIndex;
}

// clip object
function objSetClipRect(top,left, bottom, right) {
	if (top == null) top = this.objGetClipTop();
	if (left == null) left = this.objGetClipLeft();
	if (bottom == null) bottom = this.objGetClipBottom();
	if (right == null) right = this.objGetClipRight();
      strng = "rect(" + top + "," + right + "," + bottom + "," + left + ")";
	this.css1.style.clip = strng;
}

// convert string to value
function convert(strng) {
      var i = parseInt(strng.slice(0,strng.length-2));
	return i;
}

function get_entry(obj,indx) {
	strng = obj.css1.style.clip;
	strng = strng.slice(5,strng.length-1);
	var entries = strng.split(" ");
	if (indx == "top")
		if (entries[0] == "auto") 
		   return obj.objGetTop();
		else
		   return convert(entries[0]);
	else if (indx == "left")
		if (entries[3] == "auto") 
		   return obj.objGetLeft();
		else
		   return convert(entries[3]);
	else if (indx == "bottom")
		if (entries[2] == "auto") 
		   return obj.objGetHeight();
		else
		   return convert(entries[2]);
	else if (indx == "right")
		if (entries[1] == "auto") 
		   return obj.objGetWidth();
		else
		   return convert(entries[1]);
	
}
	
// clip object on left
function objGetClipLeft() {
	return get_entry(this,"left");
}

// clip object on right
function objGetClipRight() {
	return get_entry(this, "right");
}

// clip object at top
function objGetClipTop() {
	return get_entry(this,"top");
}

// clip object at bottom
function objGetClipBottom() {
	return get_entry(this,"bottom");
}

function replace_html(html_string) {
	this.css1.innerHTML = html_string;
} 

function objChangeSource(sourcefile,width) {
  var name = this.name;
  this.obj.src = sourcefile;
}


// function to create named and unnamed objects
function create_objects() {
   theelements = document.all;
   theobjs = new Array();
   thenobjs = new Array();
   for (i = 0; i < theelements.length; i++){
      if (theelements[i].id != "") {
	   theobjs[theelements[i].id] = new ie_object(theelements[i]);
         thenobjs[i] = theelements[i].id;
	   }
      }
}

// function to create named and unnamed objects
function sample_create_objects() {
   theelements = document.all.tags("DIV");
   thesobjs = new Array();
   for (i = 0; i < theelements.length; i++){
      if (theelements[i].id != "") {
	   thesobjs[theelements[i].id] = new ie_object(theelements[i]);
	   }
      }
}
