function TakeOverObject() {
	var selfRef = this;
	this.takeovers = null;
	this.ServerOffSet = 18000000; // 5 hours in miliseconds.
	this.body = null;
	var vOS = navigator.userAgent.indexOf("MSIE");
	var ieFix = (vOS != -1 && parseInt(navigator.userAgent.substr(vOS + 5, 1), 10) <= 6) ? true : false;
	this.windowHeight = function () { return document.compatMode == 'CSS1Compat' && !window.opera ? document.documentElement.clientHeight : document.body.clientHeight; }
	this.windowWidth = function () { return document.compatMode == 'CSS1Compat' && !window.opera ? document.documentElement.clientWidth : document.body.clientWidth; }
	this.backgroundDiv = cE("div", { style: { backgroundColor: "#000000", overflow: "hidden", position: (ieFix ? "absolute" : "fixed"), top: "0px", left: "0px", opacity: 85, zIndex: 10000} });
	this.href = null;
	this.Config = null;
	this.ServerTime = null;
	this.iframe = cE("iframe", {scrolling:"no",frameborder:0,border:0});
	this.init = function () {
		sO(window, { nfk: { closeTakeover: null} });
		window.nfk.closeTakeover = selfRef.Close;
		selfRef.body = document.getElementsByTagName("body")[0];
		var rnd = new Date().toUTCString()
		var mXML = new xml("/bin/time/lobbytime.cgi?" + rnd, selfRef.readServerTime, null, selfRef);
		var cXML = new xml("/scripts/takeover-schedule.js?" + rnd, selfRef.readConfig, null, selfRef);
	}
	this.Close = function () { selfRef.body.removeChild(selfRef.iframe); selfRef.body.removeChild(selfRef.backgroundDiv); }
	this.resize = function () {
		this.iframe.style.left = (Math.floor((this.windowWidth() - parseInt(this.iframe.width)) / 2)) + "px";
		this.iframe.style.top = (Math.floor((this.windowHeight() - parseInt(this.iframe.height)) / 2)) + "px";
		sO(this.backgroundDiv, { style: { height: this.windowHeight() + "px", width: this.windowWidth() + "px"} });
	}
	this.readConfig=function (data, myObj) {
		selfRef.Config = eval(data.responseText);
		selfRef.checkTimes();
	}
	this.readServerTime = function(data, myObj) {
		selfRef.ServerTime = cD(data.responseText)
		selfRef.checkTimes();
	}
	function readSchedule(data, Obj) { }
	this.checkTimes = function () {
		if (this.Config && this.ServerTime) {
			for (var x = 0, xl = this.Config.length; x < xl; x++) {
				var t = this.Config[x];
				if (this.ServerTime > t.Start) {
					if (t.End > this.ServerTime) {
						sO(this.iframe, { src: t.Page, width: t.Width, height: t.Height, style: { position: (ieFix ? "absolute" : "fixed"), zIndex: 10001, border: "none",display:"none"} });
						this.body.insertBefore(this.iframe, this.body.firstChild);
						addEvent(this.iframe, "load", selfRef.takeoverLoaded)
					}
				}
			}
		}
	}
	this.Draw = function () {
		this.body.insertBefore(this.backgroundDiv, this.body.firstChild);
		this.resize();
		var tmp = this;
		addEvent(window, "resize", function () { tmp.resize(); });
	}
	this.takeoverLoaded = function () {
		var tmp = (typeof selfRef.iframe.contentDocument === "undefined") ? selfRef.iframe.windowDocument.document : selfRef.iframe.contentDocument;
		if (tmp.title.match(/404/ig) == null) {
			selfRef.body.insertBefore(selfRef.backgroundDiv, selfRef.body.firstChild);
			selfRef.iframe.style.display = "block";
			selfRef.resize();
			addEvent(selfRef.backgroundDiv, "click", selfRef.Close);
			addEvent(window, "resize", selfRef.resize);
		}
	}
	//this.init = function () {
	//	sO(window, { nfk: { takeover: this} });
	//	sO(this.iframe, { nfk: this, src: a, style: { position: (ieFix ? "absolute" : "fixed"), zIndex: 10001, border: "none"} });
	//}
}

var objTakeOver = new TakeOverObject();
addEvent(window,"load", objTakeOver.init)
