
//-----------------------------------------------------------------------
// swt		1/2000
//
// Returns a reference to an object identified by the supplied identifier.
// The WM_checkIn function was modified to provide a base object to begin
// the search instead of assuming self. This allows searces for objects
// within other windows.
//
function objectGet( objBase, sId )
{
	return WM_checkIn( objBase, sId );
	
}	// objectGet

function WM_checkIn( objBase, WM_id )
{
/*
WM_checkIn()
Takes the ID of a positioned HTML element and returns an object reference.

Source: Webmonkey Code Library
(http://www.hotwired.com/webmonkey/javascript/code_library/)

Author: Taylor
Author Email: taylor@wired.com
Author URL: http://www.taylor.org/

Usage: WM_checkIn('id')
*/

  // First we initialize all the variables.
  var theObj,ss,sr,i,j,WM_layers=new Array();
  // This chunk handles the IE portion of the checkIn code.
  if (objBase.document.all)
  {
/*
    // This checks to see if the inline style declaration has 
    // a position property associated with it. If not, it will 
    // scan the global stylesheets for the ID.
    if(	(objBase.document.all[WM_id].style.position != 'absolute') &&
		(objBase.document.all[WM_id].style.position != 'relative'))
	{
      // This little loop I'm very proud of, because it's kinda 
      // slick and I wrote it all myself. It loops through all 
      // global stylesheets and all the rules in each stylesheet, 
      // tests for the selected ID, then returns that as the object.
      for (ss=0 ; ss < objBase.document.styleSheets.length; ss++)
      {
        for (sr=0 ; sr < objBase.document.styleSheets[ss].rules.length; sr++)
        { 
          if (objBase.document.styleSheets[ss].rules[sr].selectorText == '#' + WM_id)
          {
            theObj = objBase.document.styleSheets[ss].rules[sr].style;
            break;
          }
        }
      }
    }
    else
*/
    {
      // This works the same as in the light version, so you can 
      // use inline styles.
      theObj = objBase.document.all[WM_id]//.style;
    }
  } 
  else
  if(objBase.document.layers)
  {
    // Now we're in Netscapeland. The main problem here 
    // is finding the object in a maze of hierarchy.
    // I wish I could say that I'm proud of this code, 
    // because it's really slick. Unfortunately, I ripped 
    // it off from Macromedia Dreamweaver's drag layer code 
    // (with permission, of course :-) 
    // Dreamweaver/Configuration/Behaviors/Actions/Drag Layer.htm 
    // It works wonderfully and solves the problem.
    WM_layers = new Array();
    with (objBase.document)
    {
      for (i=0; i<layers.length; i++)
		WM_layers[i]=layers[i];
		
      {
        for (i=0; i<WM_layers.length; i++)
        {
          if (WM_layers[i].document && WM_layers[i].document.layers)
          {
            for (j=0; j<WM_layers[i].document.layers.length; j++)
            {
              WM_layers[WM_layers.length] = WM_layers[i].document.layers[j];
            }
            
            if(WM_layers[i].name == WM_id)
            {
              // So if the code matches the name of the layer, 
              // return the reference. 
              theObj = WM_layers[i];
            }
          }
        }
      }
    }
  }
  return theObj;
}

//-----------------------------------------------------------------------
// swt		1/2000
//
// Functions used to set the size of the frame window to match that of the
// contained document. This will ensure all elements of the document are 
// visible within the window. The function will only work when the document
// is contained within a frame. The function will only adjust the window
// dimension that corresponds to the orientation of the frameset (ie. height
// for a framset with rows and width for a framset with columns).
//
// This function is not totally complete. Only works for framesets that contain
// two frames and the frame being adjusted is the first frame in the frameset.
//
function frameAdjustSizeToDocument( sFramesetId )
{
	// First make sure the window is contained within a frameset and
	// find out if the row size or column size is to be changed.
	if ( window.parent.length == 0 )
		return false;
	
	var sLayout;
	var bRows = false;
	var bCols = false;
	// Get frameset object of parent window and determine if the frameset
	// creates rows or columns. 
	var framesetParent = objectGet( parent, sFramesetId );
	if ( framesetParent && framesetParent.tagName == "FRAMESET" )
	{
		bRows = ( framesetParent.rows != "" );
		bCols = ( framesetParent.cols != "" );
	}
	
	if ( bRows )
	{
		if ( document.all )
		{
			// IE browser
			if ( document.body.clientHeight != document.body.scrollHeight )
			{
				sLayout = document.body.scrollHeight + ",*";
			}
		}
		else
		if ( document.layers )
		{
			// Netscape browser
			if ( window.innerHeight != document.height )
			{
				sLayout = document.height + ",*";
			}
		}
		
		if ( sLayout )
		{
			framesetParent.rows = sLayout;
		}
	}
	else
	if ( bCols )
	{
		if ( document.all )
		{
			// IE browser
			if ( document.body.clientWidth != document.body.scrollWidth )
			{
				sLayout = document.body.scrollWidth + ",*";
			}
		}
		else
		if ( document.layers )
		{
			// Netscape browser
			if ( window.innerWidth != document.width )
			{
				sLayout = document.width + ",*";
			}
		}
		
		if ( sLayout )
		{
			framesetParent.cols = sLayout;
		}
	}
}	// frameAdjustSizeToDocument	

//-----------------------------------------------------------------------------
// swt		1/2000
//
// Functions used to retrieve the horizontal or vertical offset of the supplied
// object in respect to he window or document.
function offsetObjectHorzGet( obj )
{
	var nX = 0;
	if ( document.all )
	{
		// IE. Iterate from the supplied object to the top level window. Sum
		// the values of the object offsets to calculate the offset of the object
		// from the top most window. 
		var objIterator = obj;
		while ( objIterator != null && objIterator.tagName != "HTML" )
		{
			nX += objIterator.offsetLeft;
			objIterator = objIterator.offsetParent;
		}
	}
	else
	if ( document.layers )
	{
		// Netscape.  The object contains its location relative the page.
		nX += obj.pageX;
	}
	
	return nX;
	
}	// offsetObjectHorzGet

function offsetObjectVertGet( obj )
{
	var nY = 0;
	if ( document.all )
	{
		// IE. Iterate from the supplied object to the top level window. Sum
		// the values of the object offsets to calculate the offset of the object
		// from the top most window. 
		var objIterator = obj;
		while ( objIterator != null && objIterator.tagName != "HTML" )
		{
			nY += objIterator.offsetTop;
			objIterator = objIterator.offsetParent;
		}
	}
	else
	if ( document.layers )
	{
		// Netscape. The object contains its location relative the page.
		nY = obj.pageY;
	}
	
	return nY;
	
}	// offsetObjectVertGet

function objectWidthGet( obj )
{
	var nDX = 0;
	if ( document.all )
	{
		// IE.
		nDX = obj.offsetWidth;
	}
	else
	if ( document.layers )
	{
		// Netscape.
		nDX = obj.clip.width;
	}
	
	return nDX;
	
}	// objectWidthGet

function objectHeightGet( obj )
{
	var nDY = 0;
	if ( document.all )
	{
		// IE.
		nDY = obj.offsetHeight;
	}
	else
	if ( document.layers )
	{
		// Netscape.
		nDY = obj.clip.height;
	}
	
	return nDY;
	
}	// objectHeightGet

function objectTopGet( obj )
{
	return offsetObjectVertGet( obj );
}	// objectTopGet

function objectLeftGet( obj )
{
	return offsetObjectHorzGet( obj );
}	// objectLeftGet

