function OpenVeil(w,x,y)
{
	var o = document.getElementById("veil");
	var p = document.getElementById("veilBox");
	var q = document.getElementById("veilHead");
	var r = document.getElementById("veilBody");
	
	o.style.display = "inline";
	p.style.display = "inline";
	p.style.width = w;
	
	q.innerHTML = "<img alt=\"Close\" id=\"veilX\" src=\"http://www.webcorp.com/images/veil/x.gif\" onClick=\"javascript: VeilObj.Close(); return false;\" />" + x;
	r.innerHTML = y;
	
	VeilObj.Initialize();
}

var VeilObj = 
{
	DisableScrollbars: true,
	
	Close : function()
	{
		document.getElementById("veilBody").innerHTML = "";
		this.Veil.style.display = "none";
		this.VeilBox.style.display = "none";
		if (this.DisableScrollbars && window.XMLHttpRequest)
			this.DocBody.style.overflow = "auto";
	},

	FindScrollbarWidth : function()
	{
		var ScrollbarWidth = window.innerWidth - (this.Veil.offsetLeft + this.Veil.offsetWidth);
		this.ScrollbarWidth = (typeof ScrollbarWidth == "number") ? ScrollbarWidth : this.ScrollbarWidth;
	},

	HideScrollbar : function()
	{
		if (this.DisableScrollbars == true)
		{
			if (window.XMLHttpRequest) //ie7, firefox, opera 8+, safari
				this.DocBody.style.overflow = "hidden";
			else
				window.scrollTo(0,0);
		}
	},

	Initialize : function()
	{
		this.DocBody = (document.compatMode == "CSS1Compat") ? document.documentElement : document.body;
		this.Veil = document.getElementById("veil");
		this.VeilBox = document.getElementById("veilBox");
		this.HideScrollbar();
		this.FindScrollbarWidth();
		this.Open();
		this.Listen(window, function(){VeilObj.Open()}, "resize");
	},

	Listen : function(x,y,z) //onload, onunload, etc...
	{
		var z = (window.addEventListener) ? z : "on" + z;
		if (x.addEventListener)
			x.addEventListener(z,y,false);
		else if (x.attachEvent)
			x.attachEvent(z,y);
	},
	
	Open : function()
	{
		var Ie = document.all && !window.opera;
		var ScrollTop = (Ie) ? this.DocBody.scrollTop : window.pageYOffset;
		var DocWidth = (Ie) ? this.DocBody.clientWidth : window.innerWidth - this.ScrollbarWidth;
		var DocHeight = (Ie) ? this.DocBody.clientHeight : window.innerHeight;
		var DocHeightTotal = (this.DocBody.offsetHeight > this.DocBody.scrollHeight) ? this.DocBody.offsetHeight : this.DocBody.scrollHeight;
		var BoxWidth = this.VeilBox.offsetWidth;
		var BoxHeight = this.VeilBox.offsetHeight;
		
		this.Veil.style.width = DocWidth + "px";
		this.Veil.style.height = DocHeightTotal + "px";
		this.Veil.style.left = 0;
		this.Veil.style.top = 0;
		this.Veil.style.visibility = "visible";
		
		this.VeilBox.style.left = DocWidth / 2 - BoxWidth / 2 + "px";
		this.VeilBox.style.top = Math.floor(parseInt((DocHeight > BoxHeight) ? ScrollTop + DocHeight / 2 - BoxHeight / 2 + "px" : ScrollTop + 5 + "px")) + "px";
		this.VeilBox.style.visibility = "visible";
	}
}
