//=======================================================================================================
// DHTMLStdLib.js
//
// Chris Bartley
// HealthStream
// cpb@healthstream.com
// April 16, 1999
//
// Prerequisites: Globals.js
//=======================================================================================================
//
//    Function                                 Returned Data Type   Description
//    --------                                 ------------------   -----------
//    FlattenLayersTree()                                           For NS, creates references to ALL layers in the document at the root level.  For IE, does nothing.
//    LayerWrite(obj,content)                                       Writes the given content to the given layer.
//    GetObject(obj)                           object               Returns a valid reference to the given object.
//    GetStyleObject(obj)                      object               Returns a valid reference to the given object's style object.
//    GetParentObject(obj)                     object               Returns the parent object of the given object.
//    SetEventTrigger(obj,eventName,func)                           Associates an event handler with an event for the given object.
//    Show(obj[,obj2,...,objn])                                     Sets the visibility for the given object(s) to visible.
//    Hide(obj[,obj2,...,objn])                                     Sets the visibility for the given object(s) to hidden.
//    ToggleVisibility(obj[,obj2,...,objn])                         Toggles the visibility for the given object(s).
//    GetVisibility(obj)                       string               Returns the current visibility status of the given object.
//    GetZIndex(obj)                           integer              Returns the z-index of the given object.
//    SetZIndex(obj,z)                                              Sets the z-index of the given object to the value specified by z.
//    AdjustZIndexBy(obj,z)                                         Adjusts the z-index of the given object by the value specified by z
//    GetBorderColor(obj)                      string               Returns the border color of the given object.
//    SetBorderColor(obj,theColor)                                  Sets the border color of the given object to the value specified by theColor.
//    GetBackgroundColor(obj)                  string               Returns the background color of the given object.
//    SetBackgroundColor(obj,theColor)                              Sets the background color of the given object to the value specified by theColor.
//    GetObjectTop(obj)                        integer              Returns the top coordinate of the given object.
//    GetObjectRight(obj)                      integer              Returns the right coordinate of the given object.
//    GetObjectBottom(obj)                     integer              Returns the bottom coordinate of the given object.
//    GetObjectLeft(obj)                       integer              Returns the left coordinate of the given object.
//    SetObjectTop(obj,theTop)                                      Sets the top coordinate of the given object.
//    SetObjectRight(obj,theRight)                                  Sets the right coordinate of the given object.
//    SetObjectBottom(obj,theBottom)                                Sets the bottom coordinate of the given object.
//    SetObjectLeft(obj,theLeft)                                    Sets the left coordinate of the given object.
//    GetObjectWidth(obj)                      integer              Returns the width of the given object.
//    GetObjectHeight(obj)                     integer              Returns the height of the given object.
//    SetObjectWidth(obj,theWidth)                                  Sets the width of the given object.
//    SetObjectHeight(obj,theHeight)                                Sets the height of the given object.
//    GetObjectClip(obj)                                            Gets the clipping region of the given object.
//    SetObjectClip(obj,top,right,bottom,left)                      Sets the clipping region of the given object.
//    AdjustObjectClipBy(obj,top,right,bottom,left)                 Adjusts the clipping region of the given object by the given amounts.
//    MoveObjectTo(obj,x,y)                                         Move the given object to a specific point (x,y) in pixels
//    MoveObjectBy(obj,deltaX,deltaY)                               Move the given object deltaX pixels horizontally and deltaY pixels vertically from its current position
//
//    DHTMLStdLib_IsLoaded()                                        Used solely for determining whether this library has been loaded.  The user will probably use this function only rarely, if ever.
//
//=======================================================================================================
// FlattenLayersTree()
//
// If the user is using Netscape, this function goes through the tree of layers (DIVs) and brings them
// all to the "top".  I.e., if you have a DIV with id "MyDiv" and it contains a DIV with id "MyOtherDiv",
// this function creates a reference to the "MyOtherDiv" DIV at the same level as "MyDiv".  It basically
// makes things more like IE, where you can reference any layer in the document without worrying how deeply
// nested it is.
//
// If the user is using IE, nothing happens.
//
// NOTES:  
// * You'll most likely want to call this function with the onLoad event handler.
// * User's code should NEVER call __FlattenLayersTreeWorkhorse().
// * Use of this function requires careful naming of DIV ids...you don't want to stomp on a predefined property!
//
// Signature:  FlattenLayersTree()
//
// Input:      none
// Output:     none
//-------------------------------------------------------------------------------------------------------
function FlattenLayersTree()
	{
	var i = 0;
	
	if (Globals.IsNS())																		// only need to do this for Netscape
		{
		for (i = 0; i < document.layers.length; i++)									// loop over all layers in the document, if any
			__FlattenLayersTreeWorkhorse(document.layers[i].document);    		// for each layer, go through its child layers recursively and add references to them to the top
		}
	}
function __FlattenLayersTreeWorkhorse(theDocument)
	{
	var i = 0;
	
	for (i = 0; i < theDocument.layers.length; i++)
		{
		window.document[theDocument.layers[i].id] = theDocument.layers[i];	// add a reference to this child layer to the top level
		if (theDocument.layers[i].document.layers.length)							// recurse down if necessary...
			__FlattenLayersTreeWorkhorse(theDocument.layers[i].document);
		}
	}
//=======================================================================================================
// LayerWrite(obj,content)
//
// Writes the given content (content) to the given layer (obj).  This function overwrites whatever content
// is currently in the given layer.
//
// Signature:  LayerWrite(string|object,string)
//
// Input:      obj:      a layer's id or reference
//             content:  text to write to the layer
// Output:     none
//-------------------------------------------------------------------------------------------------------
function LayerWrite(obj,content)
	{
	obj = GetObject(obj);
	if (Globals.IsNS())
		{
		obj.document.open();
		obj.document.writeln(content);
		obj.document.close();
		}
	else
		{
		obj.innerHTML = content;
		}
	}
//=======================================================================================================
// GetObject(obj)
//
// Returns a valid reference to the given object.
//
// Signature:  GetObject(string|object) --> object
//
// Input:      obj:  an object's id or an object reference
// Output:     reference to the object represented by obj
//-------------------------------------------------------------------------------------------------------
function GetObject(obj)
	{
	if (typeof obj == "string")
		return eval("document." + Globals.Coll() + obj);
	else
		return obj;
	}
//=======================================================================================================
// GetStyleObject(obj)
// 
// Returns a valid reference to the given object's style object.
//
// Signature:  GetStyleObject(string|object) --> object
//
// Input:      obj:  an object's id or an object reference
// Output:     reference to the style object of the object represented by obj
//-------------------------------------------------------------------------------------------------------
function GetStyleObject(obj)
	{
	if (typeof obj == "string")
		return eval("document." + Globals.Coll() + obj + Globals.StyleObj());
	else if (Globals.IsIE())
		return obj.style;
	else
		return obj;
	}
//=======================================================================================================
// GetParentObject(obj)
//
// Returns the parent object of the given object.
//
// Signature:  GetParentObject(string|object) --> object
//
// Input:      obj:  an object's id or an object reference
// Output:     reference to the parent object of the object represented by obj
//-------------------------------------------------------------------------------------------------------
function GetParentObject(obj)
	{
	if (Globals.IsNS())
		{
		return GetObject(obj).parentLayer;
		}
	else
		{
		return GetObject(obj).parentElement;
		}
	}
//=======================================================================================================
// SetEventTrigger(obj,eventName,triggerFunction)
//
// Associates an event handler with an event for the given object.
//
// Signature:  SetEventTrigger(string|object,string,function)
//
// Input:      obj:              an object's id or an object reference
//             eventName:        name of event with which to associate the event handler function
//             triggerFunction:  the name of the event handler function
// Output:     none
//-------------------------------------------------------------------------------------------------------
function SetEventTrigger(obj,eventName,triggerFunction)
	{
	obj = GetObject(obj);

	if (Globals.IsNS())
		{
		obj.captureEvents(Event[eventName.toUpperCase()]);
		}
	obj['on'+eventName.toLowerCase()] = triggerFunction;
	}
//=======================================================================================================
// Show(obj[,obj2,obj3,...,objn])
//
// Sets the visibility for the given object(s) to visible.  Any number of objects may be passed, and this
// function will set all their visibilities to visible.
//
// Signature:  Show(string|object[,string|object,string|object,...,string|object])
//
// Input:      obj:  an object's id or an object reference
// Output:     none
//-------------------------------------------------------------------------------------------------------
function Show(obj)
	{
	var obj;
	
	for (var i=0; i < Show.arguments.length; i++)
		{
		obj = GetObject(Show.arguments[i]);
		
		// show the tied objects, if necessary
		if (window.Ties_IsLoaded)
			{
			Ties_SetCurrentlyTiedObjectsVisibility(obj,'visible');
			}
	
		// show the object
		GetStyleObject(obj).visibility = "visible";
		}
	}
//=======================================================================================================
// Hide(obj[,obj2,obj3,...,objn])
//
// Sets the visibility for the given object(s) to hidden.  Any number of objects may be passed, and this
// function will set all their visibilities to hidden.
//
// Signature:  Hide(string|object[,string|object,string|object,...,string|object])
//
// Input:      obj:  an object's id or an object reference
// Output:     none
//-------------------------------------------------------------------------------------------------------
function Hide(obj)
	{
	var obj;
	
	for (var i=0; i < Hide.arguments.length; i++)
		{
		obj = GetObject(Hide.arguments[i]);
		
		// hide the tied objects, if necessary
		if (window.Ties_IsLoaded)
			{
			Ties_SetCurrentlyTiedObjectsVisibility(obj,'hidden');
			}
	
		// hide the object
		GetStyleObject(obj).visibility = "hidden";
		}
	}
//=======================================================================================================
// ToggleVisibility(obj[,obj2,obj3,...,objn])
//
// Toggles the visibility for the given object(s).  All currently visible given objects are hidden and all
// hidden given objects are made visible.  The visibility of objects with a visibility setting of something
// other than "visible" or "hidden" (as returned by GetVisibility()) is not changed.  Any number of objects
// may be passed, and this function will toggle all their visibilities.
//
// NOTE:  Stupid IE doesn't set visibility correctly if you set visibility in <STYLE> tags.  The object
// is displayed properly, but the object's visibility property will be an empty string.  This bug causes
// this function to not do anything since action is only taken if the visibility is "visible" or "hidden".
// To get around this, simply make sure to call Show() or Hide() on all objects you might be toggling before
// you call ToggleVisibility().  A good place to do this might be in an onLoad init function.  You might also
// simlpy set the object's visibility in the style attribute of the object's tag--doing that causes the
// visibility property to be set correctly.
//
// Signature:  ToggleVisibility(string|object[,string|object,string|object,...,string|object])
//
// Input:      obj:  an object's id or an object reference
// Output:     none
//-------------------------------------------------------------------------------------------------------
function ToggleVisibility(obj)
	{
	var obj;
	var currentVisibility;
	
	for (var i=0; i < arguments.length; i++)
		{
		obj = GetObject(arguments[i]);
		currentVisibility = GetVisibility(obj);
		if (currentVisibility == "visible")
			Hide(obj);
		else if (currentVisibility == "hidden")
			Show(obj);
		}
	}
//=======================================================================================================
// GetVisibility(obj)
//
// Returns the current visibility status of the given object.  Objects with a visibility setting of "show"
// or "visible" return "visible".  Objects with a visibility setting of "hide" or "hidden" return "hidden".
// Objects with any other visibility setting simply return that setting.
//
// Note: See the note about for ToggleVisibility() regarding IE and visibility.
//
// Signature:  GetVisibility(string|object) --> string
//
// Input:      obj:  an object's id or an object reference
// Output:     the current visibility status of the object
//-------------------------------------------------------------------------------------------------------
function GetVisibility(obj)
	{
	obj = GetObject(obj);
	var styleObj = GetStyleObject(obj);
	if ((styleObj.visibility == "show") || (styleObj.visibility == "visible"))
		return "visible";
	else if ((styleObj.visibility == "hide") || (styleObj.visibility == "hidden"))
		return "hidden";
	else
		return styleObj.visibility;
	}
//=======================================================================================================
// GetZIndex(obj)
//
// Returns the z-index of the given object.
//
// Signature:  GetZIndex(string|object) --> integer
//
// Input:      obj:  an object's id or an object reference
// Output:     the z-index of the object
//-------------------------------------------------------------------------------------------------------
function GetZIndex(obj)
	{
	return GetStyleObject(obj).zIndex;
	}
//=======================================================================================================
// SetZIndex(obj,z)
//
// Sets the z-index of the given object to the value specified by z.
//
// Signature:  SetZIndex(string|object,string|integer)
//
// Input:      obj:  an object's id or an object reference
//             z     new z-index for the object
// Output:     none
//-------------------------------------------------------------------------------------------------------
function SetZIndex(obj,z)
	{
	obj = GetObject(obj);
	z = CPBParseInt(z);
	
	// set the z-index of the tied objects, if necessary
	if (window.Ties_IsLoaded)
		{
		Ties_SetCurrentlyTiedObjectsZIndex(obj,z);
		}

	// set the z-index of the object
	GetStyleObject(obj).zIndex = z;
	}
//=======================================================================================================
// AdjustZIndexBy(obj,z)
//
// Adjusts the z-index of the given object by the value specified by z.
//
// Signature:  AdjustZIndexBy(string|object,string|integer)
//
// Input:      obj:  an object's id or an object reference
//             z     amount by which to adjust (raise/lower) the z-index for the object
// Output:     none
//-------------------------------------------------------------------------------------------------------
function AdjustZIndexBy(obj,z)
	{
	obj = GetObject(obj);
	z = CPBParseInt(z);
	
	// adjust the z-index of the tied objects, if necessary
	if (window.Ties_IsLoaded)
		{
		Ties_AdjustCurrentlyTiedObjectsZIndexBy(obj,z);
		}

	// adjust the z-index of the object
	GetStyleObject(obj).zIndex += z;
	}
//=======================================================================================================
// GetBorderColor(obj,theColor)
//
// Returns the border color of the given object.
//
// Signature:  GetBorderColor(string|object) --> string
//
// Input:      obj:       an object's id or an object reference
//             theColor:  the current border color for the object
// Output:     none
//-------------------------------------------------------------------------------------------------------
function GetBorderColor(obj)
	{
	return GetStyleObject(obj).borderColor;
	}
//=======================================================================================================
// SetBorderColor(obj,theColor)
//
// Sets the border color of the given object to the value specified by theColor.
//
// You can specify up to four values (top, right, bottom, left) for Internet Explorer (see the O'Reilly
// book _Dynamic HTML: The Definitive Reference_ 1st edition page 852 for more info).  Netscape only allows
// one color, and sets all borders to that color.
//
// NOTE:  Despite the documentation, Netscape doesn't seem to do anything when setting the border color by
// any means other than via CSS.  No clue why.
//
// Signature:  SetBorderColor(string|object,string)
//
// Input:      obj:       an object's id or an object reference
//             theColor:  new border color for the object
// Output:     none
//-------------------------------------------------------------------------------------------------------
function SetBorderColor(obj,theColor)
	{
	GetStyleObject(obj).borderColor = theColor;
	}
//=======================================================================================================
// GetBackgroundColor(obj,theColor)
//
// Returns the background color of the given object.
//
// Signature:  GetBackgroundColor(string|object) --> string
//
// Input:      obj:       an object's id or an object reference
//             theColor:  the current background color for the object
// Output:     none
//-------------------------------------------------------------------------------------------------------
function GetBackgroundColor(obj)
	{
	if (Globals.IsNS())
		{
		return GetStyleObject(obj).bgColor;
		}
	else
		{
		return GetStyleObject(obj).backgroundColor;
		}
	}
//=======================================================================================================
// SetBackgroundColor(obj,theColor)
//
// Sets the background color of the given object to the value specified by theColor.
//
// Signature:  SetBackgroundColor(string|object,string)
//
// Input:      obj:       an object's id or an object reference
//             theColor:  new background color for the object
// Output:     none
//-------------------------------------------------------------------------------------------------------
function SetBackgroundColor(obj,theColor)
	{
	if (Globals.IsNS())
		{
		GetStyleObject(obj).bgColor = theColor;
		}
	else
		{
		GetStyleObject(obj).backgroundColor = theColor;
		}
	}
//=======================================================================================================
// GetObjectTop(obj)
//
// Returns the top coordinate of the given object.
//
// Signature:  GetObjectTop(string|object) --> integer
//
// Input:      obj:  an object's id or an object reference
// Output:     top coordinate of the object
//-------------------------------------------------------------------------------------------------------
function GetObjectTop(obj)
	{
	if (Globals.IsNS())
		{
		return GetStyleObject(obj).top;
		}
	else
		{
		return GetStyleObject(obj).pixelTop;
		}
	}
//=======================================================================================================
// GetObjectRight(obj)
//
// Returns the right coordinate of the given object.
//
// Signature:  GetObjectRight(string|object) --> integer
//
// Input:      obj:  an object's id or an object reference
// Output:     right coordinate of the object
//-------------------------------------------------------------------------------------------------------
function GetObjectRight(obj)
	{
	if (Globals.IsNS())
		{
		return (GetStyleObject(obj).left + GetObjectWidth(obj));
		}
	else
		{
		return (GetStyleObject(obj).pixelLeft + GetObjectWidth(obj));
		}
	}
//=======================================================================================================
// GetObjectBottom(obj)
//
// Returns the bottom coordinate of the given object.
//
// Signature:  GetObjectBottom(string|object) --> integer
//
// Input:      obj:  an object's id or an object reference
// Output:     bottom coordinate of the object
//-------------------------------------------------------------------------------------------------------
function GetObjectBottom(obj)
	{
	if (Globals.IsNS())
		{
		return (GetStyleObject(obj).top + GetObjectHeight(obj));
		}
	else
		{
		return (GetStyleObject(obj).pixelTop + GetObjectHeight(obj));
		}
	}
//=======================================================================================================
// GetObjectLeft(obj)
//
// Returns the left coordinate of the given object.
//
// Signature:  GetObjectLeft(string|object) --> integer
//
// Input:      obj:  an object's id or an object reference
// Output:     left coordinate of the object
//-------------------------------------------------------------------------------------------------------
function GetObjectLeft(obj)
	{
	if (Globals.IsNS())
		{
		return GetStyleObject(obj).left;
		}
	else
		{
		return GetStyleObject(obj).pixelLeft;
		}
	}
//=======================================================================================================
// SetObjectTop(obj,theTop)
//
// Sets the top coordinate of the given object.
//
// Signature:  SetObjectTop(string|object,string|integer)
//
// Input:      obj:     an object's id or an object reference
//             theTop:  new top coordinate of the object
// Output:     none
//-------------------------------------------------------------------------------------------------------
function SetObjectTop(obj,theTop)
	{
	var deltaY;
	obj = GetObject(obj);
	theTop = CPBParseInt(theTop);

	// move the tied objects, if necessary
	if (window.Ties_IsLoaded)
		{
		deltaY = theTop - GetObjectTop(obj);
		Ties_MoveCurrentlyTiedObjectsBy(obj,0,deltaY);
		}

	// move the object
	if (Globals.IsNS())
		{
		GetStyleObject(obj).top = theTop;
		}
	else
		{
		GetStyleObject(obj).pixelTop = theTop;
		}
	}
//=======================================================================================================
// SetObjectRight(obj,theRight)
//
// Sets the right coordinate of the given object.
//
// Signature:  SetObjectRight(string|object,string|integer)
//
// Input:      obj:       an object's id or an object reference
//             theRight:  new right coordinate of the object
// Output:     none
//-------------------------------------------------------------------------------------------------------
function SetObjectRight(obj,theRight)
	{
	var deltaX;
	obj = GetObject(obj);
	theRight = CPBParseInt(theRight);
	
	// move the tied objects, if necessary
	if (window.Ties_IsLoaded)
		{
		deltaX = theRight - GetObjectRight(obj);
		Ties_MoveCurrentlyTiedObjectsBy(obj,deltaX,0);
		}

	// move the object
	if (Globals.IsNS())
		{
		GetStyleObject(obj).left = theRight - GetObjectWidth(obj);
		}
	else
		{
		GetStyleObject(obj).pixelLeft = theRight - GetObjectWidth(obj);
		}
	}
//=======================================================================================================
// SetObjectBottom(obj,theBottom)
//
// Sets the bottom coordinate of the given object.
//
// Signature:  SetObjectBottom(string|object,string|integer)
//
// Input:      obj:        an object's id or an object reference
//             theBottom:  new top coordinate of the object
// Output:     none
//-------------------------------------------------------------------------------------------------------
function SetObjectBottom(obj,theBottom)
	{
	var deltaY;
	obj = GetObject(obj);
	theBottom = CPBParseInt(theBottom);

	// move the tied objects, if necessary
	if (window.Ties_IsLoaded)
		{
		deltaY = theBottom - GetObjectBottom(obj);
		Ties_MoveCurrentlyTiedObjectsBy(obj,0,deltaY);
		}

	// move the object
	if (Globals.IsNS())
		{
		GetStyleObject(obj).top = theBottom - GetObjectHeight(obj);
		}
	else
		{
		GetStyleObject(obj).pixelTop = theBottom - GetObjectHeight(obj);
		}
	}
//=======================================================================================================
// SetObjectLeft(obj,theLeft)
//
// Sets the left coordinate of the given object.
//
// Signature:  SetObjectLeft(string|object,string|integer)
//
// Input:      obj:      an object's id or an object reference
//             theLeft:  new left coordinate of the object
// Output:     none
//-------------------------------------------------------------------------------------------------------
function SetObjectLeft(obj,theLeft)
	{
	var deltaX;
	obj = GetObject(obj);
	theLeft = CPBParseInt(theLeft);
	
	// move the tied objects, if necessary
	if (window.Ties_IsLoaded)
		{
		deltaX = theLeft - GetObjectLeft(obj);
		Ties_MoveCurrentlyTiedObjectsBy(obj,deltaX,0);
		}

	// move the object
	if (Globals.IsNS())
		{
		GetStyleObject(obj).left = theLeft;
		}
	else
		{
		GetStyleObject(obj).pixelLeft = theLeft;
		}
	}
//=======================================================================================================
// GetObjectWidth(obj)
//
// Returns the width of the given object.
//
// Signature:  GetObjectWidth(string|object) --> integer
//
// Input:      obj:  an object's id or an object reference
// Output:     width of the object
//-------------------------------------------------------------------------------------------------------
function GetObjectWidth(obj)
	{
	if (Globals.IsNS())
		{
		return GetStyleObject(obj).clip.width;
		}
	else
		{
		return GetObject(obj).clientWidth;
		}
	}
//=======================================================================================================
// GetObjectHeight(obj)
//
// Returns the height of the given object.
//
// Signature:  GetObjectHeight(string|object) --> integer
//
// Input:      obj:  an object's id or an object reference
// Output:     height of the object
//-------------------------------------------------------------------------------------------------------
function GetObjectHeight(obj)
	{
	if (Globals.IsNS())
		{
		return GetStyleObject(obj).clip.height;
		}
	else
		{
		return GetObject(obj).clientHeight;
		}
	}
//=======================================================================================================
// SetObjectWidth(obj,theWidth)
//
// Sets the width of the given object.
//
// Signature:  SetObjectWidth(string|object,string|integer)
//
// Input:      obj:       an object's id or an object reference
//             theWidth:  the new width of the object
// Output:     none
//-------------------------------------------------------------------------------------------------------
function SetObjectWidth(obj,theWidth)
	{
	if (Globals.IsNS())
		{
		GetStyleObject(obj).clip.width = CPBParseInt(theWidth);
		}
	else
		{
		GetStyleObject(obj).pixelWidth = CPBParseInt(theWidth);
		}
	}
//=======================================================================================================
// SetObjectHeight(obj,theHeight)
//
// Sets the height of the given object.
//
// Signature:  SetObjectHeight(string|object,string|integer)
//
// Input:      obj:        an object's id or an object reference
//             theHeight:  the new height of the object
// Output:     none
//-------------------------------------------------------------------------------------------------------
function SetObjectHeight(obj,theHeight)
	{
	if (Globals.IsNS())
		{
		GetStyleObject(obj).clip.height = CPBParseInt(theHeight);
		}
	else
		{
		GetStyleObject(obj).pixelHeight = CPBParseInt(theHeight);
		}
	}
//=======================================================================================================
// GetObjectClip(obj)
//
// Returns a 4-element array holding the clipping region of the given object.  The elements in top, right,
// bottom, left order.
//
// NOTE: Stupid IE4 for the Mac doesn't seem to handle clipping correctly.
//
// Signature:  GetObjectClip(string|object) --> array
//
// Input:      obj:        an object's id or an object reference
// Output:     a 4-element array holding the clipping region of the given object
//-------------------------------------------------------------------------------------------------------
function GetObjectClip(obj)
	{
	var theStyleObject = GetStyleObject(obj);
	var clipArray = new Array(4);
	
	if (Globals.IsNS())
		{
		clipArray[0] = CPBParseInt(theStyleObject.clip.top);
		clipArray[1] = CPBParseInt(theStyleObject.clip.right);
		clipArray[2] = CPBParseInt(theStyleObject.clip.bottom);
		clipArray[3] = CPBParseInt(theStyleObject.clip.left);
		}
	else
		{
		var startPos = theStyleObject.clip.indexOf('(');
		var endPos = theStyleObject.clip.lastIndexOf(')');
		if ((startPos != -1) && (endPos != -1))
			{
			var clipArray = theStyleObject.clip.substring(startPos+1,endPos).split(' ');
			clipArray[0] = CPBParseInt(clipArray[0]);
			clipArray[1] = CPBParseInt(clipArray[1]);
			clipArray[2] = CPBParseInt(clipArray[2]);
			clipArray[3] = CPBParseInt(clipArray[3]);
			}
		}
	return clipArray;
	}
//=======================================================================================================
// SetObjectClip(obj,theTop,theRight,theBottom,theLeft)
//
// Sets the clipping region of the given object.
//
// Signature:  SetObjectClip(string|object,string|integer,string|integer,string|integer,string|integer)
//
// NOTE: Stupid IE4 for the Mac doesn't seem to handle clipping correctly.
//
// Input:      obj:        an object's id or an object reference
//             theTop:     the top coordinate of the object's clipping region
//             theRight:   the right coordinate of the object's clipping region
//             theBottom:  the bottom coordinate of the object's clipping region
//             theLeft:    the left coordinate of the object's clipping region
// Output:     none
//-------------------------------------------------------------------------------------------------------
function SetObjectClip(obj,theTop,theRight,theBottom,theLeft)
	{
	var theStyleObject = GetStyleObject(obj);
	theTop = CPBParseInt(theTop);
	theRight = CPBParseInt(theRight);
	theBottom = CPBParseInt(theBottom);
	theLeft = CPBParseInt(theLeft);
	if (Globals.IsNS())
		{
		theStyleObject.clip.top = theTop;
		theStyleObject.clip.right = theRight;
		theStyleObject.clip.bottom = theBottom;
		theStyleObject.clip.left = theLeft;
		}
	else
		{
		theStyleObject.clip = "rect(" + theTop + "px " + theRight + "px " + theBottom + "px " + theLeft + "px)";
		}
	}
//=======================================================================================================
// AdjustObjectClipBy(obj,topDelta,rightDelta,bottomDelta,leftDelta)
//
// Adjusts the clipping region of the given object by the given amounts.
//
// Signature:  AdjustObjectClipBy(string|object,string|integer,string|integer,string|integer,string|integer)
//
// NOTE: Stupid IE4 for the Mac doesn't seem to handle clipping correctly.
//
// Input:      obj:          an object's id or an object reference
//             topDelta:     the change in top coordinate of the object's clipping region
//             rightDelta:   the change in  right coordinate of the object's clipping region
//             bottomDelta:  the change in  bottom coordinate of the object's clipping region
//             leftDelta:    the change in  left coordinate of the object's clipping region
// Output:     none
//-------------------------------------------------------------------------------------------------------
function AdjustObjectClipBy(obj,topDelta,rightDelta,bottomDelta,leftDelta)
	{
	obj = GetObject(obj);
	topDelta = CPBParseInt(topDelta);
	rightDelta = CPBParseInt(rightDelta);
	bottomDelta = CPBParseInt(bottomDelta);
	leftDelta = CPBParseInt(leftDelta);
	if (Globals.IsNS())
		{
		obj.clip.top += topDelta;
		obj.clip.right += rightDelta;
		obj.clip.bottom += bottomDelta;
		obj.clip.left += leftDelta;
		}
	else
		{
		var clipArray = GetObjectClip(obj);
		SetObjectClip(obj,clipArray[0]+topDelta,clipArray[1]+rightDelta,clipArray[2]+bottomDelta,clipArray[3]+leftDelta);
		}
	}
//=======================================================================================================
// MoveObjectTo(obj,x,y)
//
// Move the given object to a specific point (x,y) in pixels.
//
// Signature:  MoveObjectTo(string|object,integer|string,integer|string)
//
// Input:      obj:   an object's id or an object reference
//             x:     destination horizontal coordinate
//             y:     destination vertical coordinate
// Output:     none
//-------------------------------------------------------------------------------------------------------
function MoveObjectTo(obj,x,y)
	{
	// Opting for speed, I chose not to use SetObjectTop() and SetObjectLeft() in this function.
	var deltaX, deltaY;
	obj = GetObject(obj);
	x = CPBParseInt(x);				// make sure it's an integer
	y = CPBParseInt(y);				// make sure it's an integer

	// move the tied objects, if necessary
	if (window.Ties_IsLoaded)
		{
		deltaX = x - GetObjectLeft(obj);
		deltaY = y - GetObjectTop(obj);
		Ties_MoveCurrentlyTiedObjectsBy(obj,deltaX,deltaY);
		}

	// move the object
	DHTMLStdLib_MoveTo(obj,x,y);
	}
//=======================================================================================================
// MoveObjectBy(obj,deltaX,deltaY)
//
// Move the given object deltaX pixels horizontally and deltaY pixels vertically from its current position.
//
// Signature:  MoveObjectBy(string|object,integer|string,integer|string)
//
// Input:      obj:     an object's id or an object reference
//             deltaX:  horizontal change in coordinate
//             deltaY:  vertical change in coordinate
// Output:     none
//-------------------------------------------------------------------------------------------------------
function MoveObjectBy(obj,deltaX,deltaY)
	{
	// Opting for speed, I chose not to use SetObjectTop() and SetObjectLeft() in this function.
	obj = GetObject(obj);
	deltaX = CPBParseInt(deltaX);				// make sure it's an integer
	deltaY = CPBParseInt(deltaY);				// make sure it's an integer

	// move the tied objects, if necessary
	if (window.Ties_IsLoaded)
		{
		Ties_MoveCurrentlyTiedObjectsBy(obj,deltaX,deltaY);
		}

	// move the object
	DHTMLStdLib_MoveBy(obj,deltaX,deltaY);
	}
//=======================================================================================================
// DHTMLStdLib_MoveTo(obj,x,y)
//
// Move the given object to a specific point (x,y) in pixels.
//
// NOTE: This function should not be called by the user.  It is intended solely for use by this library and
// other libraries that need to perform fast object movement without taking optional libraries (e.g. Ties)
// into account. No error checking is performed for x and y.
//
// Signature:  DHTMLStdLib_MoveTo(string|object,integer,integer)
//
// Input:      obj:   an object's id or an object reference
//             x:     destination horizontal coordinate
//             y:     destination vertical coordinate
// Output:     none
//-------------------------------------------------------------------------------------------------------
function DHTMLStdLib_MoveTo(obj,x,y)
	{
	if (Globals.IsNS())
		{
		GetStyleObject(obj).moveTo(x,y);
		}
	else
		{
		obj = GetStyleObject(obj);
		obj.pixelLeft = x;
		obj.pixelTop = y;
		}
	}
//=======================================================================================================
// DHTMLStdLib_MoveBy(obj,deltaX,deltaY)
//
// Move the given object deltaX pixels horizontally and deltaY pixels vertically from its current position.
//
// NOTE: This function should not be called by the user.  It is intended solely for use by this library and
// other libraries that need to perform fast object movement without taking optional libraries (e.g. Ties)
// into account. No error checking is performed for x and y.
//
// Signature:  MoveObjectBy(string|object,integer,integer)
//
// Input:      obj:     an object's id or an object reference
//             deltaX:  horizontal change in coordinate
//             deltaY:  vertical change in coordinate
// Output:     none
//-------------------------------------------------------------------------------------------------------
function DHTMLStdLib_MoveBy(obj,deltaX,deltaY)
	{
	if (Globals.IsNS())
		{
		GetStyleObject(obj).moveBy(deltaX,deltaY);
		}
	else
		{
		obj = GetStyleObject(obj);
		obj.pixelLeft += deltaX;
		obj.pixelTop += deltaY;
		}
	}
//=======================================================================================================
// DHTMLStdLib_IsLoaded()
//
// Used solely for determining whether this library has been loaded.  It is useful for libraries which may optionally
// make use of this library.  For example, before a function calls any code related to this library,
// that function might run code like this:
//
//         if (window.DHTMLStdLib_IsLoaded)
//            {
//            // code related to this library goes here
//            } 
//
// to see whether it should bother.  Note the intentional lack of parentheses in the if statement since
// we are merely detecting whether the function is defined and not explicitly calling it.  This function
// should NEVER be called explicitly because it would result in a run-time error if this library has not been loaded.
//
// Signature:  DHTMLStdLib_IsLoaded()
//
// Input:      none
// Output:     none
//-------------------------------------------------------------------------------------------------------
function DHTMLStdLib_IsLoaded()
	{
	}
//=======================================================================================================
