function ConfirmVeilClose(z)
{
	var x = confirm(z)
	if (x == true)
		VeilObj.Close()
}

function OpenVeil(w,x,y,z)
{
	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.style.display = "block";
	
	if (z == "")
		q.innerHTML = "<img alt=\"Close\" id=\"veilX\" src=\"http://www.travelhotels.info/images/veil/x.png\" onClick=\"javascript: VeilObj.Close(); return false;\" />" + x;
	else if (z == "none")
		q.style.display = "none";
	else
		q.innerHTML = "<img alt=\"Close\" id=\"veilX\" src=\"http://www.travelhotels.info/images/veil/x.png\" onClick=\"javascript: ConfirmVeilClose('" + z + "'); return false;\" />" + x;
	
	r.innerHTML = y;
	VeilObj.Initialize();
}

function OpenVeilLoading(w,h,p,f,c)
{
	var x = "<div class=\"veilLoading\">";
	x = x + "<h1>" + h + "</h1>";
	x = x + "<p>" + p + "</p>";
	x = x + "<div class=\"s\"><img alt=\"\" id=\"spinner\" src=\"" + Spin64.src + "\" title=\"\" /></div>";
	x = x + "<div class=\"f\">" + f + "</div>";
	x = x + "</div>";
	OpenVeil(w,h,x,c);
	
	// Reset the animated GIF to work with problematic browsers.
	var p = document.getElementById("spinner");
	setTimeout(function() {p.src = p.src + "?rnd" + new Date().getTime()}, 200);
}

function OpenVeilUrl(w,x,u,z)
{
	if (window.ActiveXObject) {try {r = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {try {r = new ActiveXObject("Microsoft.XMLHTTP");} catch (e) {}}}
	else if (window.XMLHttpRequest) {r = new XMLHttpRequest();}//Mozilla, Safari, etc.
	else {return false;}
	r.onreadystatechange = function() {ReturnVeilUrl(w,x,r,z)};
	r.open("GET", u+((u.search("\\?")==-1)?"?":"&")+"cache="+new Date().getTime(), true);// open(Method, Url, Async)
	r.send(null);
}

function ReturnVeilUrl(w,x,r,z)
{
	OpenVeilLoading("350px", "Loading....", "Please wait while we load your information.", "This may take a few seconds.", "none");
	if (r.readyState == 4 && (r.status==200 || window.location.href.indexOf("http")==-1))
	{
		VeilObj.Close();
		OpenVeil(w,x,r.responseText,z);
	}
	else if (r.readyState == 4)
	{
		VeilObj.Close();
		alert("There was a connection timeout. Please try your selection again. If you continue to experience problems, please try a different browser such as Internet Explorer 7.0 (or above) or FireFox 2.0 (or above).");
	}
}

function ShowVeilObj()
{
	document.write("<div id=\"veil\"></div><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" id=\"veilBox\"><tr><td class=\"c\"><img alt=\"\" src=\"http://www.travelhotels.info/images/veil/1.png\" /></td><td class=\"h\"><img alt=\"\" src=\"http://www.travelhotels.info/images/pixel.gif\" /></td><td class=\"c\"><img alt=\"\" src=\"http://www.travelhotels.info/images/veil/2.png\" /></td></tr><tr><td class=\"v\"><img alt=\"\" src=\"http://www.travelhotels.info/images/pixel.gif\" /></td><td><div id=\"veilHead\"></div><div id=\"veilBody\"></div></td><td class=\"v\"><img alt=\"\" src=\"http://www.travelhotels.info/images/pixel.gif\" /></td></tr><tr><td class=\"c\"><img alt=\"\" src=\"http://www.travelhotels.info/images/veil/3.png\" /></td><td class=\"h\"><img alt=\"\" src=\"http://www.travelhotels.info/images/pixel.gif\" /></td><td class=\"c\"><img alt=\"\" src=\"http://www.travelhotels.info/images/veil/4.png\" /></td></tr></table>");
}

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";
	}
}

