﻿if(typeof(Element) != "undefined")
{
	Element.prototype.getLocation = function()
	{
		var x = 0;
		var y = 0;
		if(this.getBoundingClientRect)
		{
			var orect = this.getBoundingClientRect();
			x = orect.left;
			y = orect.top;
		}
		else
		{
			var t = this;
			while(t != null && t != document.body)
			{
				x += t.offsetLeft;
				y += t.offsetTop;
				t = t.offsetParent;
			}
			var sp = getScrollPos();
			x -= sp.x;
			y -= sp.y;
		}
		return {x : x, y : y};
	}
}








window.getSize = window.get_Size = function()
{
  if (typeof(window.innerWidth) == 'number') 
  {
    return new Size(window.innerWidth, window.innerHeight);
  } 
  else if (document.documentElement != null && document.documentElement.clientWidth != null) 
  {
    return new Size(document.documentElement.clientWidth, document.documentElement.clientHeight);
  } 
  else if (document.body && document.body.clientWidth) 
  {
    return new Size(document.body.clientWidth, document.body.clientHeight);
  }
  else 
  {
		return new Size(0, 0);
	}
}
function getWindowWidth() 
{
	return window.getSize().w;
}
function getWindowHeight() 
{
	return window.getSize().h;
}
















window.getScroll = function()
{
  var x = 0, y = 0;
  if( typeof( window.pageYOffset ) == 'number' ) 
  {
    x = window.pageXOffset;
    y = window.pageYOffset;
  } 
  else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) 
  {
     x = document.body.scrollLeft;
     y = document.body.scrollTop;
  } 
  else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) 
  {
    x = document.documentElement.scrollLeft;
    y = document.documentElement.scrollTop;
  }
  return new Point(x, y);
}
function getScrollPos()
{
	return window.getScroll();
}












function Point(x, y)
{
	this.x = x;
	this.y = y;
}
function Size(w, h)
{
	this.w = w;
	this.h = h;
}
