/*@FILE INFORMATION
----------------------------------------
Author:		Mark Wise 
File:		Viewport_1.0.1.js 
Created:	11/19/08 12:31 PM
Updated:	1/28/10 6:04 PM

/*@END--------------------------------*/

$Viewport = {
	align: function(a){
		var ele = (typeof a == "string")? document.getElementById(a) : a;
		
		//Vertical align middle
		var v = this.relativeHeight() / 2;
		ele.style.top = (v - (ele.offsetHeight / 2)) + this.scrollY() + "px";
	
		//Horizontal align middle
		var h = this.relativeWidth() / 2;
		ele.style.left = (h - (ele.offsetWidth / 2)) + this.scrollX() + "px";
								
	},
	scrollX: function(){
		if(typeof window.scrollX == "undefined"){
			return document.documentElement.scrollLeft;
						
		}else{
			return window.scrollX;
		
		}
				
	},
	scrollY: function(){
		if(typeof window.scrollY == "undefined"){
			return document.documentElement.scrollTop;
						
		}else{
			return window.scrollY;
		
		}
				
	},
	relativeWidth: function(){
		var html = document.documentElement;
		var body = document.body;
		
		//Is "CSS1Compat"
		if(document.compatMode == "CSS1Compat" || document.documentMode){
			return html.clientWidth;
			
		//Is "BackCompat"
		}else{
			return body.clientWidth;
																
		}
			
	},
	relativeHeight: function(){
		var html = document.documentElement;
		var body = document.body;
			
		//Is "CSS1Compat"
		if(document.compatMode == "CSS1Compat" || document.documentMode){
			return html.clientHeight;
		
		//Is "BackCompat"
		}else{
			return body.clientHeight;
														
		}
			
	},
	absoluteHeight: function(){
		/**
		Firefox, Safari and Opera always return "CSS1Compat" when testing (document.compatMode) 
		regardless of the doctype chosen. Internet Explorer will always returns "CSS1Compat" with a 
		XHTML1.1 doctype and "BackCompat" with any other doctype. It is important to note that 
		Microsoft has replaced (document.compatMode) in IE8 with (document.documentMode).
		read more on this here: http://msdn.microsoft.com/en-us/library/cc288325(VS.85).aspx
		*/
		var html = document.documentElement;
		var body = document.body;
		var client_height;
		var scroll_height;
				
		//Is "CSS1Compat"
		if(document.compatMode == "CSS1Compat" || document.documentMode){
			client_height = html.clientHeight;
			scroll_height = html.scrollHeight;
		
		//Is "BackCompat"
		}else{
			client_height = body.clientHeight;
			scroll_height = body.scrollHeight;
														
		}
		return (scroll_height > client_height)? scroll_height : client_height;
				
	}
						
}

















































