﻿//块在页面中居中显示
	function m_UI(container)
	{
		this.form = document.getElementById(container);
		this.timeoutId = null;
		this.SaveHeight = null;
		this.SaveWidth = null;
		this.init = function ()
		{
			if(this.form){
				this.form.style.visibility = "hidden";
				this.form.style.position = "absolute";
				this.form.ui = this;
				var _this = this;
				var _fun = function ()
				{
					_this.SetForm();
				}
				this.timeoutid = window.setInterval(_fun,500);
			}
		}
	}
	

// JavaScript Document
	m_UI.prototype.clientHeight =function (){//取位
			if (window.innerHeight) 
			{
					return window.innerHeight;
			}
			else 
			{
					if (document.documentElement && document.documentElement.clientHeight) 
					{
							return document.documentElement.clientHeight;
					}
					else if (document.body) 
					{
							return document.body.clientHeight;
					}
			}
			return 0;
	}
	m_UI.prototype.clientWidth = function (){//取位
			if (window.innerWidth) 
			{
					return window.innerWidth;
			}
			else 
			{
					if (document.documentElement && document.documentElement.clientWidth) 
					{
							return document.documentElement.clientWidth;
					}
					else if (document.body) 
					{
							return document.body.clientWidth;
					}
			}
			return 0;
	}
	m_UI.prototype.SetForm = function (){
		if(this.SaveHeight!=this.clientHeight() || this.SaveWidth!=this.clientWidth){
			this.SaveHeight = this.clientHeight();
			this.SaveWidth = this.clientWidth();
			
			if(this.SaveHeight>this.form.clientHeight){
				this.form.style.top = (this.SaveHeight-this.form.clientHeight)/2+"px";
			}else{
				this.form.style.top = "0px";
			}
			if(this.SaveWidth>this.form.clientWidth){
				this.form.style.left = (this.SaveWidth-this.form.clientWidth)/2+"px";
			}else{
				this.form.style.left = "0px";
			}
		}
		this.form.style.visibility = "visible";
	}
