var Background = {
	container: null,
	image: null,
	src: null,
	dimensions: null,
	onPageLoad: function()
	{
		var img = new Image();
		img.onload = function() {
			var b = new Element('div', {'id':'background'}).setStyle({'width':'100%','top':'0','left':'0','overflow':'hidden'});
			this.container = $(document.body.insertBefore(b, $('background-fill')));
			this.image = $(this.container.appendChild(this.image));
			this.dimensions = this.image.getDimensions();
			Event.observe(document.onresize ? document : window, "resize", this.resize.bindAsEventListener(this));
			this.resize();
		}.bind(this);
		this.image = img;
		this.image.src = this.src;
	},
	resize: function()
	{
		var viewport = document.viewport.getDimensions();
		var height = ((viewport.width / this.dimensions.width) * this.dimensions.height);
		this.container.setStyle({height: viewport.height+'px'});
		this.image.setStyle({width: viewport.width+'px', height: height+'px'});
	}
};
document.observe('dom:loaded', Background.onPageLoad.bindAsEventListener(Background));

