Position.windowInfo = function() {
  var windowWidth, windowHeight;
  var pageWidth, pageHeight;

  if (window.innerHeight && window.scrollMaxY) {
    pageWidth = document.body.scrollWidth;
    pageHeight = window.innerHeight + window.scrollMaxY;
  } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
    pageWidth = document.body.scrollWidth;
    pageHeight = document.body.scrollHeight;
  } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
    pageWidth = document.body.offsetWidth;
    pageHeight = document.body.offsetHeight;
  }

  if (self.innerHeight) { // all except Explorer
    windowWidth = self.innerWidth;
    windowHeight = self.innerHeight;
  } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
    windowWidth = document.documentElement.clientWidth;
    windowHeight = document.documentElement.clientHeight;
  } else if (document.body) { // other Explorers
    windowWidth = document.body.clientWidth;
    windowHeight = document.body.clientHeight;
  }
  var xScroll = document.documentElement.scrollLeft || document.body.scrollLeft;
  var yScroll = document.documentElement.scrollTop || document.body.scrollTop;

  // for small pages with total height less then height of the viewport
  pageHeight = Math.max(windowHeight, pageHeight);

  // for small pages with total width less then width of the viewport
  pageWidth = Math.max(windowWidth, pageWidth);
  return { width: windowWidth, height: windowHeight, pageWidth: pageWidth, pageHeight: pageHeight, xScroll: xScroll, yScroll: yScroll};
}

var _indicator_waiting = false;
var _indicator_loading = null;

Indicator = {
	// opacity of loading element
	opacity: 0.8,

	// Start waiting status - show loading element
	show: function(element, className, timeUntilShow) {
		if (typeof element == 'string')
			element = $(element);
		if (className == undefined)
			className = 'waiting';

		_indicator_waiting = true;
		if (!_indicator_loading) {
			var e = document.createElement('div');
			(element.offsetParent || document.body).appendChild(_indicator_loading = e);
			try {e.style.opacity = Indicator.opacity;} catch(e) {}
			try {e.style.MozOpacity = Indicator.opacity;} catch(e) {}
			try {e.style.filter = 'alpha(opacity='+Math.round(Indicator.opacity * 100)+')';} catch(e) {}
			try {e.style.KhtmlOpacity = Indicator.opacity;} catch(e) {}
		}
		_indicator_loading.className = className;

        var position = Position.cumulativeOffset(element);
        var dimension = element.getDimensions();
        _indicator_loading.style.left = position[0] + "px";
        _indicator_loading.style.top = position[1] + "px";
        _indicator_loading.style.width =  dimension.width + "px";
        _indicator_loading.style.height = dimension.height + "px";
        _indicator_loading.style.display = 'inline';
	},

	// Stop waiting status - hide loading element
	hide: function() {
		if (_indicator_waiting) {
			_indicator_waiting = false;
			_indicator_loading.parentNode.removeChild(_indicator_loading);
			_indicator_loading = null;
		}
	}
};