/*************************************************************************
  dw_viewport.js  
  free code from dyn-web.com
  version date: mar 2008
*************************************************************************/  
  
var viewport = {
		winfunc: null
		,
		winInner: function(){
			this.width = window.innerWidth - 18;
			this.height = window.innerHeight - 18;
		},
		winDocEl: function(){
			this.width = document.documentElement.clientWidth;
			this.height = document.documentElement.clientHeight;
		},
		winDocBody: function(){
			this.width = document.body.clientWidth;
			this.height = document.body.clientHeight;
		},
		winnotdefined: function(){
			this.width = 0
			this.height = 0
		},
		checkWinFunc: function(){
			if (window.innerWidth) 
				this.winfunc = this.winInner;
			else if (document.documentElement && !isNaN(document.documentElement.clientWidth)) 
				this.winfunc = this.winDocEl;
			else if (document.body && !isNaN(document.body.clientWidth)) 
				this.winfunc = this.winDocBody;
			else
				this.winfunc = this.winnotdefined;
		},
		
		
		scrollfunc: null,
		scrollOffset: function(){
			this.scrollX = window.pageXOffset;
			this.scrollY = window.pageYOffset;
		},
		scrollDocEl: function(){
			this.scrollX = document.documentElement.scrollLeft;
			this.scrollY = document.documentElement.scrollTop;
		},
		scrollBody: function(){
			this.scrollX = document.body.scrollLeft;
			this.scrollY = document.body.scrollTop;
		},
		scrollWinXY: function(){
			this.scrollX = window.scrollX;
			this.scrollY = window.scrollY;
		},
		scrollnotdefined: function(){
			this.scrollX = 0;
			this.scrollY = 0;
		},
		checkScrollFunc: function(){
			if (typeof(window.pageXOffset) == "number") 
				this.scrollfunc = this.scrollOffset;
			else if (document.documentElement && !isNaN(document.documentElement.scrollLeft))
				this.scrollfunc = this.scrollDocEl;
			else if (document.body && !isNaN(document.body.scrollLeft))
				this.scrollfunc = this.scrollBody;
			else if (window.scrollX) 
				this.scrollfunc = this.scrollWinXY;
			else
				this.scrollfunc = this.scrollnotdefined;
		},
    
    getAll: function () {
		if(this.winfunc==null) this.checkWinFunc();
		this.winfunc();
		if(this.scrollfunc==null) this.checkScrollFunc();
		this.scrollfunc();
    }
  
}
