/* A SIMPLE DHTML API
 *
 * You can use the getObj() function to gain access to the HTML element you want to influence.
 * It will pass you the HTML element you asked for, regardless of browser DOM.
 * Of course the element must have a proper ID and, if your script must work in Netscape 4, 
 * should have a position defined in the style sheet.

 * It's called like this: 
 *		var x = new getObj('layername');
 * Now the function create a new JavaScript object x. 
 * It goes through all possible DOMs and if it finds the one that the browser supports it sets this.obj and this.style. 
 * The this keyword makes sure that the two properties obj and style are added to the new object x.
 *
 * Using the object
 * Please note that you cannot do anything with the object x itself, it is merely a container for its two properties:
 *		1) .obj, giving access to the actual HTML element. You have to use this property to read out or set anything else than styles. 
 *		2) .style, giving access to the styles of the HTML element. You have to use this property to read out or set the styles of the element. 
 *
 * So to alert the ID of the object, do 
 *		alert(x.obj.id)
 * After all the ID is a property of the object itself, not of the style. 
 *
 * To change the top coordinate, do
 *		x.style.top = '20px';
 * top is a style, so you should use the style property
 */
 
function getObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
	this.obj = getObjNN4(document,name);
	this.style = this.obj;
  }
}

function getObjNN4(obj,name)
{
	var x = obj.layers;
	var foundLayer;
	for (var i=0;i<x.length;i++)
	{
		if (x[i].id == name)
		 	foundLayer = x[i];
		else if (x[i].layers.length)
			var tmp = getObjNN4(x[i],name);
		if (tmp) foundLayer = tmp;
	}
	return foundLayer;
}
