checkUA();

function checkUA()
	{
	var UAs = {MSIE: 'MSIE ', Gecko: 'rv:'};
	var ua = navigator.userAgent;
		for( var n in UAs )
		{
		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;
		}
	}

	if( document.isMSIE )
	{
		if( document.versionMSIE == 6.0 )
		{
		document.getElementPosition = 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.offsetWidth/*scrollWidth*/, height: e.scrollHeight/*offsetHeight*/};
			}
		
		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)';
			}
		}
		else if( document.versionMSIE == 5.5 )
		{
		document.getElementPosition = 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};
			}
		
		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.offsetWidth/*scrollWidth*/, height: e.scrollHeight/*offsetHeight*/};
			}
		
		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)';
			}
		}
		else if( document.versionMSIE == 5.0 )
		{
		document.getElementPosition = 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.offsetWidth/*scrollWidth*/, height: e.scrollHeight/*offsetHeight*/};
			}
		
		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)';
			}
		}
		else
		{
		document.getElementPosition = 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/*offsetWidth*/, height: e.scrollHeight/*offsetHeight*/};
			}
		
		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)';
			}
		}
	}
	else if( document.isGecko )
	{
	document.getElementPosition = function ( e )
		{
		var x = e.offsetLeft;
		var y = e.offsetTop;
			if( e.nodeName == 'A' && getComputedStyle(e, null).getPropertyValue('display') != 'block' )
			{
			var ns = e.childNodes;
				for( var i = 0 ; i < ns.length ; i++ )
				{
					if( ns[i].nodeType != 1 ) continue;
				x = Math.min(x, ns[i].offsetLeft);
				y = Math.min(y, ns[i].offsetTop);
				}
			}
		var n = e.offsetParent;
			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, null);
		s.left = pointX - x;
		s.top = pointY - y;
		}
	
	document.getElementSize = function ( e )
		{
			if( e.nodeName != 'A' || getComputedStyle(e, null).getPropertyValue('display') == 'block' ) return {width: e.offsetWidth, height: e.offsetHeight};
		var x1 = e.offsetLeft;
		var x2 = e.offsetLeft + e.offsetWidth;
		var y1 = e.offsetTop;
		var y2 = e.offsetTop + e.offsetHeight;
		var ns = e.childNodes;
			for( var i = 0 ; i < ns.length ; i++ )
			{
					if( ns[i].nodeType != 1 ) continue;
			x1 = Math.min(x1, ns[i].offsetLeft);
			x2 = Math.min(x2, ns[i].offsetLeft + ns[i].offsetWidth);
			y1 = Math.min(y1, ns[i].offsetTop);
			y2 = Math.min(x2, ns[i].offsetTop + ns[i].offsetHeight);
			}
		
		return {width: x2 - x1, height: y2 - y1};
		}
	
	document.setElementSize = function ( e, width, height )
		{
		var w = width < 1 ? 1 : width;
		var h = height < 1 ? 1 : height;
		var s = document.getOverrideStyle(e, null);
		s.width = w;
		s.height = h;
		s.clip = 'rect(0px ' + w + 'px ' + h + 'px 0px)';
		}
	}

