var background_image = new function() {
	this.image_width = 1200;
	this.image_height = 560;
	this.container_top = 35;
	this.container_bottom = 0;
	this.z_index = 10;

	this.container = null;
	this.image = null;
	
	this.setup = function(src) {
		//create the container
		this.container = jQuery("<div />").css({
			'position': 'fixed',
			'top': background_image.container_top + "px",
			'width': '100%',
			'bottom': background_image.container_bottom + "px",
			'left': '0',
			'z-index': background_image.z_index
		});
		
		if (jQuery.browser.msie && jQuery.browser.version.substr(0,1)<7) {
			this.container.css({position: 'absolute'});
		}
		
		//create image
		var new_image = jQuery("<img />").css({
				'position': 'absolute',
				'top': 0,
				'left': 0,
				'width': '100%',
				'height': '100%'				  
			}).attr('src', src);			
		this.image = new_image;
			
		//append image to container
		this.container.append(new_image);

		//append everything to the body
		jQuery('body').append(this.container);
		
		//set window resize handler
		jQuery(window).resize(function() { background_image.resize(); });
		this.resize();
	};
	
	this.resize = function() {
		var img_width = this.image_width;
		var img_height = this.image_height;
		
		var display_width = jQuery(window).width();
		var display_height = jQuery(window).height() - this.container_top - this.container_bottom;
		
		if (display_width < this.image_min_width)
			display_width = this.image_min_width;
		if (display_height < this.image_min_height)
			display_height = this.image_min_height;
		
		var width_ratio = display_width / img_width;
		var height_ratio = display_height / img_height;
		
		if (width_ratio > height_ratio) {
			//use width ratio / use full width
			var new_width = display_width;
			var new_height = img_height * width_ratio;
		} else {
			var new_height = display_height;
			var new_width = img_width * height_ratio;
		}
		
		var new_top = (display_height-new_height)/2;
		
		this.image.css({'width': new_width + "px", 'height' : new_height + "px",
					   'top': new_top + "px"});
	};
};
