var ContentWindow = {
	container: null,
	defaultX: 0,
	hiddenX: '-9999em',
	initialised: false,
	
	init: function() {
		this.container = document.getElementById('content-layer')
		this.defaultX = this.container.style.left;
		this.initialised = true;
		this.container.style.position = 'absolute';
	}
	,
	show: function() {
		this.container.style.left = this.defaultX;
		this.container.style.display = 'block';
	}
	,
	hide: function() {
		this.container.style.display = 'none';
		this.defaultX = this.container.style.left;
		this.container.style.left = this.hiddenX;
	}
	,
	isVisible: function() {
		return new Boolean(this.container.style.display == 'block');
	}
	,
	open: function() {
		return this.show();
	}
	,
	close: function() {
		return this.hide();
	}
	,
	isOpen: function() {
		return this.isVisible();
	}
	,
	scrollbars: function(visible) {
		if (!visible) {
			this.getFrame().scrolling = 'no';
		} else {
			this.getFrame().scrolling = 'auto';
		}
	}
	,
	toggle: function() {
		if (this.container.style.display == 'none') {
			this.show();
		} else {
			this.hide();
		}
	}
	,
	getFrame: function() {
		return this.container.getElementsByTagName('iframe')[0];
	}
	,
	getFrameDocument: function() {
		var doc = this.getFrame().contentWindow || this.getFrame().contentDocument;
	    return doc;
	}
	,
	getOffsetContainer: function() {
		return document.getElementById('content-layer-offset');
	}
	,
	clearOffset: function() {
		this.setOffset(0,0);
	}
	,
	setOffset: function(x,y) {
		this.getOffsetContainer().style.position = 'absolute';
		this.getOffsetContainer().style.left = x + 'px';
		this.getOffsetContainer().style.top = y + 'px';
	}
	,
	setPosition: function(top,left) {
		if (!left) {
			//this.container.style.left = 'auto';
			this.defaultX = this.container.style.left;
		} else {
			this.container.style.marginLeft = '0px';
			this.container.style.marginRight = '0px';
			this.container.style.left = left + 'px';
		}
		this.container.style.top = top + 'px';
		this.clearOffset();
	}
	,
	setPositionCentered: function() {
		this.container.style.margin = '0 auto';
		this.container.style.left = 'auto';
		var r = new RegExp('([0-9]+)[^0-9]*');
		var w = this.container.style.width.match(r);
		w = (w.length == 2) ? w[1] : 0;
		this.container.style.left = '50%';
		this.container.style.marginLeft = '-' + new String(w/2) + 'px';
		this.defaultX = this.container.style.left;
	}
	,
	setSize: function(w,h) {
		this.container.style.width = w + 'px';
		this.container.style.height = h + 'px';
	    this.getOffsetContainer().style.width = w + 'px';
		this.getOffsetContainer().style.height = h + 'px';
		this.setPositionCentered();
		//this.container.style.left = '50%';
		//this.container.style.marginLeft = '-' + new String(w/2) + 'px';
	}
	,
	setUrl: function(sUrl) {
		this.getFrame().src = sUrl;
	}
}
