Event.observe(window, 'load', function() 
{
	bg.resize();
});

Event.observe(window, 'resize', function() 
{
	
	bg.resize();
	
});

var bg = Class.create(
		{
			initialize: function(target,width,height) 
			{
				this.target				= $(target);
				this.original_width		= width;
				this.original_height	= height;
			},
			
			resize: function()
			{
				// breedte en hoogte van het scherm opvragen
				var height	= document.viewport.getHeight();
				var width	= document.viewport.getWidth();
				
				if ($('sfeer'))
				{
					var source			= $('sfeer');
					var factor			= this.original_width / this.original_height;
					var screen_factor 	= width/height;
					
					if (factor > screen_factor)
					{
						width = height * this.original_width / this.original_height;
						
						source.style.width = width + 'px';
						source.style.height = height + 'px';
					}
					else
					{
						height = width * this.original_height / this.original_width;
						
						source.style.width = width + 'px';
						source.style.height = height + 'px';
					}
					
					// save dimension into cookie...
					cookie.create('bg', 'width:'+width+'|height:'+height, 7);
				}
			}
});

var bg = new bg('sfeer',1024,768);
