/*
 * @(#)dhtml_util.js
 *
 * Copyright (C) 2008 D.TRIBE, Inc. All rights reserved.
 *
 * THIS SOFTWARE IS THE PROPRIETARY INFORMATION OF D.TRIBE, INC.
 * USE IS SUBJECT TO LICENSE TERMS.
 *
 * @author	Barney Kim
 */

var DhtmlUtil = {
	getInfo:function() {
		this.ie=document.all && !window.opera;
		this.dom_client_width = document.documentElement && parseInt(document.documentElement.clientWidth) || 100000;
		this.dom_client_height = document.documentElement && parseInt(document.documentElement.clientHeight) || 100000;
		this.standard_body=(document.compatMode=="CSS1Compat")? document.documentElement : document.body;
		this.scroll_top=(this.ie)? this.standard_body.scrollTop : window.pageYOffset;
		this.scroll_left=(this.ie)? this.standard_body.scrollLeft : window.pageXOffset;
		this.doc_width=(this.ie)? this.standard_body.clientWidth : (/Safari/i.test(navigator.userAgent))? window.innerWidth : Math.min(this.dom_client_width, window.innerWidth-16);
		this.doc_height=(this.ie)? this.standard_body.clientHeight: window.innerHeight;
		//this.page_height=this.standard_body.scrollHeight + (this.standard_body.offsetHeight - this.doc_height);
        this.page_width=this.standard_body.scrollWidth;
		this.page_height=this.standard_body.scrollHeight;
	},
	
	moveToCenter:function(dname,w,h) {
		this.getInfo();
		var d=document.getElementById(dname);
		if(d == null || d == undefined) { return; }
		if(w == undefined) {
			w = d.style.width;
			if(w.length > 2) {
				w = w.substring(0,w.length-2);
			}
		}
		if(h == undefined) {
			h = d.style.height;
			if(h.length > 2) {
				h = h.substring(0,h.length-2);
			}
		}
		if(w != "" && h != "") {
			var wx = ((this.doc_width-w)/2) + this.scroll_left;
			var wy = ((this.doc_height-h)/2) + this.scroll_top;
			if(wx < 0) { wx = 0; }
			if(wy < 0) { wy = 0; }
			d.style.left = wx + "px";
			d.style.top = wy  + "px";
			d.style.width = w + "px";
			d.style.height = h + "px";
		}
	}
};

// EOF
