/*
* Victor A.Spirin, victor_as@mail.ru
* 2003.03.01 - 2003.06.25
*/



checkUA();

function checkUA()
	{
	var UAs = {MSIE: 'MSIE ', Gecko: 'rv:'};
		for( var n in UAs )
		{
		var ua = navigator.userAgent;
		var is = ua.indexOf(n) != -1;
			if( is ) document['version' + n] = parseFloat(ua.substring(ua.indexOf(UAs[n]) + UAs[n].length));
		document['is' + n] = is;
		}
	}



/*========= DOM CSS Methods: =========*/

	if( typeof(getComputedStyle) != 'function' )
	{
	getComputedStyle = document.isMSIE ?
	function ( e, pseudo )
		{
		return e.currentStyle;
		}
	:
	function ( e, pseudo )
		{
		return e.style;
		}
	}



	if( document.getOverrideStyle == null )
	{
	document.getOverrideStyle = document.isMSIE ?
	function ( e, pseudo )
		{
		return e.runtimeStyle;
		}
	:
	function ( e, pseudo )
		{
		return e.style;
		}
	}



/*======== Geometric Methods: ========*/

document.getElementPosition = document.isMSIE && 5.0 == document.versionMSIE ?
	function ( e )
		{
		var x = 0;
		var y = 0;
		var n = e;
			while( n != null )
			{
			x += n.offsetLeft;
			y += n.offsetTop;
			var p = n.parentElement;
				while( p != n.offsetParent )
				{
					if( p.tagName == 'TR' ) y -= p.offsetTop;
				p = p.parentElement;
				}
			n = n.offsetParent;
			}
		return {x: x, y: y};
		}
	:
	function ( e )
		{
		var x = 0;
		var y = 0;
		var n = e;
			while( n != null )
			{
			x += n.offsetLeft;
			y += n.offsetTop;
			n = n.offsetParent;
			}
		return {x: x, y: y};
		}

document.setElementPosition = function ( e, pointX, pointY )
	{
	var x = 0;
	var y = 0;
	var n = e.offsetParent;
		while( n != null )
		{
		x += n.offsetLeft;
		y += n.offsetTop;
		n = n.offsetParent;
		}
	var s = document.getOverrideStyle(e);
	s.left = pointX - x;
	s.top = pointY - y;
	}

document.getElementSize = function ( e )
	{
	return {width: e.scrollWidth, height: e.scrollHeight};
	}

document.setElementSize = function ( e, width, height )
	{
	var w = width < 1 ? 1 : width;
	var h = height < 1 ? 1 : height;
	var s = document.getOverrideStyle(e);
	s.width = w;
	s.height = h;
	s.clip = 'rect(0px ' + w + 'px ' + h + 'px 0px)';
	}

