/*
*	Package
*	baseLayer.class.js		2000.09.11
*	Victor A.Spirin,	victor_aspirin@mail.ru
*/



function baseLayer( Element )
	{
		if( window.document.layers != null )
		{
		Element.show = function ()
			{
			Element.hidden = false;
			}

		Element.hide = function ()
			{
			Element.hidden = true;
			}

		Element.getAbsolutePosition = function ()
			{
			return {X: Element.pageX, Y: Element.pageY};
			}

		Element.getSize = function ()
			{
			return {Width: Element.clip.width, Height: Element.clip.height};
			}

		Element.getBackgroundColor = function ()
			{
			return Element.bgColor;//////////////////////////////////////////
			}

		Element.setBackgroundColor = function ( HexadecimalColorString )
			{
				if( !true ) return;//////////////////////////////////////////

			Element.bgColor = HexadecimalColorString;
			}

		Element.setContent = function ( Hypertext )
			{
			var BEFORE_HYPERTEXT = '<table width="' + Element.clip.width + '" cellpadding="0" cellspacing="0" border="0">\n	<tr>\n		<td>';
			var AFTER_HYPERTEXT = '</td>\n	</tr>\n</table>';

			Element.innerHTML = Hypertext;
				with( Element.document )
				{
				open();
				write( BEFORE_HYPERTEXT + Hypertext + AFTER_HYPERTEXT );
				close();
				}
			}

		Element.updateContent = function ()
			{
				if( Element.innerHTML != null ) Element.setContent( Element.innerHTML );
			}
		}
		else if( document.all != null )
		{
		Element.show = function ()
			{
			Element.style.visibility = 'visible';
			}

		Element.hide = function ()
			{
			Element.style.visibility = 'hidden';
			}

		Element.moveToAbsolute = function ( X, Y )
			{
			var position = Element.getAbsolutePosition();
			Element.style.pixelLeft = X - position.X + Element.style.pixelLeft;
			Element.style.pixelTop = Y - position.Y + Element.style.pixelTop;
/*
			var X0 = 0;
			var Y0 = 0;
			var P = Element.offsetParent;
				while( P != null )
				{
				X0 += P.offsetLeft;
				Y0 += P.offsetTop;
				P = P.offsetParent;
				}
			Element.style.pixelLeft = X - X0;
			Element.style.pixelTop = Y - Y0;
*/
			}

		Element.resizeTo = function ( Width, Height )
			{
			Element.style.width = Math.abs( Width );
			Element.style.height = Math.abs( Height );
			Element.style.clip = 'rect( 0px, ' + Width + 'px, ' + Height + 'px, 0px)';
			}

		Element.getAbsolutePosition = function ()
			{
/*
			var PageX = 0;
			var PageY = 0;
			var E = Element;
				while( E != null )
				{
				PageX += E.offsetLeft;
				PageY += E.offsetTop;
				E = E.offsetParent;
				}
			return {X: PageX, Y: PageY};
*/
			var x = Element.style.pixelLeft;
			var y = Element.style.pixelTop;
			var p = Element;
				while( p != null )
				{
				var tag = p.tagName;
					if( tag == 'TD' || tag == 'TABLE' || tag == 'BODY' )
					{
					x += p.offsetLeft;
					y += p.offsetTop;
					}
				p = p.parentElement;
				}
			return {X: x, Y: y};
			}

		Element.getSize = function ()
			{
			return {Width: Element.offsetWidth, Height: Element.offsetHeight};
			}

		Element.getBackgroundColor = function ()
			{
			return Element.style.backgroundColor;//////////////////////////////////////////
			}

		Element.setBackgroundColor = function ( HexadecimalColorString )
			{
				if( !true ) return;//////////////////////////////////////////

			Element.style.backgroundColor = HexadecimalColorString;
			}

		Element.setContent = function ( Hypertext )
			{
			Element.innerHTML = Hypertext;
			}

		Element.updateContent = function ()
			{
			}
		}
		else return null;

	return Element;
	}
